1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
Commit Graph

53 Commits

Author SHA1 Message Date
Zdenek Kabelac
88ad83e3d6 makefiles: use SHOW 2024-04-08 14:52:23 +02:00
Zdenek Kabelac
f9fefaaabe refactor: update dm_strncpy to _dm_strncpy
For checked versions of dm_strncpy use inline wrapper _dm_strncpy.
2024-04-04 19:38:21 +02:00
Zdenek Kabelac
295e632e81 util: add _dm_strncpy
Add internal inline function wrapper for dm_strncpy().
Use it for calls where we test the result.
Avoids emitting warnings in Coverity for unchecked usage.
2024-04-04 19:37:13 +02:00
Zdenek Kabelac
5c0ade35e2 util: swap header file load order
Ensure libdevmapper is included before util.h since
we are going to add function that is using it.
TODO: maybe add include directly here...
2024-04-04 19:33:58 +02:00
Zdenek Kabelac
8c4b8c6e27 dmsetup: refactor getopt_long usage
Shuffle code to avoid using static variable to pass parsed option.
Code is now easier to follow and also number of coverity reports
will go away.
There should be no functional change.
2024-03-26 15:58:36 +01:00
Adam Joseph
dc8837f079 configure.ac: handle --disable-shared flag
Since LVM 2.02 it appears that compiling LVM on a platform which
lacks a shared library linker/loader will fail to produce any
binaries (dmsetup, lvm2, etc).

Adds support for the standard --disable-shared flag, and
use it to disable attempts at building shared libraries.

Modified-by: zkabelac
2023-10-13 14:25:02 +02:00
Bryn M. Reeves
9aa47f9768 Quote path value in --filemap debug messages
Improves readability of debugging output when file paths contain
whitespace.
2023-10-12 11:31:14 +00:00
Bryn M. Reeves
f0fd03b122 dmstats: use correct value for precise in _stats_create_file() 2023-10-12 11:31:14 +00:00
Peter Rajnoha
5a1248f1d4
dmsetup: support printing full column names in report headings
Add '--headings none|abbrev|full|0|1|2' command line option to select
the heading type.

  none|0   - no headings
  abbrev|1 - column name abbreviations
  full|2   - full column names (column names are equal to exact names
             that -o|--options also accepts to set report output)
2023-08-28 15:44:57 +02:00
Zdenek Kabelac
96123b9059 cleanup: use spelling synchronize
Use single spelling form for synchronize.
2023-07-10 17:13:32 +02:00
Zdenek Kabelac
d418fc14f4 cov: hide some false positives
Hide some false positives.

Note: there must not a be blank line after coverity hiding comment.
2023-05-10 16:19:46 +02:00
David Seifert
2b7fa40aac configure.ac: add STATIC_LDFLAGS
Add support for specif STATIC_LDFLAGS when linking static binaries.
2023-02-23 16:46:35 +01:00
Zdenek Kabelac
f443d16fd7 cov: fix buffer size usage
Count with extra 1 byte for buffer end '\0'.
2022-12-20 15:04:36 +01:00
Zdenek Kabelac
a5042375de dmsetup: fix udev event handling for create
With newer kernels (>5.13)  DM_CREATE no longer generates
uevent for DM devices without table.
There are even no sysfs block device entries in such case,
although device has asigned major:minor and it is being listed
by 'dmsetup info'.

So this patch calculates amount of 'table' lines and in case
no table line comes from cmdline or stdin - waiting on cookie
is avoided generically instead of disabling just case with
option --notable - which then also skipped handling of an
option --addnodeoncreate (which is however historical and
should be avoided)

As a result there should be no leaking udev cookies and endlessly
waiting commands like this:

dmsetup create mytestdev  </dev/null
2022-11-25 16:41:53 +01:00
Zdenek Kabelac
718e38d5fa dmsetup: check also for ouf of range value
Check errno result from strtoull().
2022-08-19 14:56:57 +02:00
Zdenek Kabelac
6668d6409a cov: validate subcommand existance
Before dereference of subcommand pointer, check it's not NULL
as  coverity believes there exists theoretical path for this...
2021-10-15 23:39:25 +02:00
Zdenek Kabelac
a3352f08f6 dmsetup: fix measure handling
Previous patch f853a1bc7a enabled
ima measurement unconditionally for every status call,
but it needs to be set only for 'dmsetup measure' command.
2021-09-27 18:45:25 +02:00
Alasdair G Kergon
f853a1bc7a libdm: dmsetup measure support for IMA
Add support for DM_IMA_MEASUREMENT_FLAG with
DM_TABLE_STATUS_CMD.

This feature requires DM version 4.45  (5.15+ kernels)
2021-09-23 16:49:28 +02:00
Zdenek Kabelac
b0d40109a6 cov: ignore leak of fd descriptor
There is no 'fd' leak.
2021-09-21 21:03:47 +02:00
Zdenek Kabelac
1b52451996 cov: mask some warning about leakage
Mask false-positive leak report.
2021-09-20 14:26:09 +02:00
Zdenek Kabelac
548c69f581 cov: hide reports from optarg being NULL
It's basically irrelavant which value we assing to optarg,
since it's set by getopt() function, but Coverity tool
is incorrectly reporting possibly dereference of NULL.
2021-09-20 14:26:09 +02:00
Zdenek Kabelac
ebd150366f cov: add explicit NULL pointer check
Make obvious to coverity strcmp() is not getting NULL pointer.
2021-09-20 14:26:09 +02:00
Zdenek Kabelac
825e49a244 cov: use different variable name
Better for Coverity to see no change for possibly opened handle.
2021-09-20 14:26:09 +02:00
Zdenek Kabelac
9512638656 gcc-fanalyzer: better losetup error path
Fix leaking memory on error path on _process_losetup_switches().
However real impact is close to zero as dm-loop target isn't really used.
2021-09-20 13:58:57 +02:00
Zdenek Kabelac
d388b36da2 cov: daemonize avoid leak of FD on error path
Use our common patter for reopening FDs to /dev/null
that avoids leaking FD on error path.
2021-04-23 23:00:55 +02:00
Zdenek Kabelac
aee0cd6530 makefiles: static linking enhancements 2021-04-12 09:54:15 +02:00
Zdenek Kabelac
648188df2a libdm: use libdm header util.h
Avoid using lvm header for libdm build.
2021-03-30 13:08:14 +02:00
Zdenek Kabelac
3d26bde1c0 make: cflow target works again
Restored 'make cflow' functinality.
Produces some quick referece of function chaining and usage.
2021-03-20 00:05:01 +01:00
Zdenek Kabelac
f7912635a0 cov: ensure buffer is initialized 2021-03-10 01:35:02 +01:00
Zdenek Kabelac
7342ab06fc debug: change sys_error to sys_debug
These messages do not cause command error - so changing logging level
to just 'sys_debug' (so visible only with -vvvv)
2021-03-10 01:11:52 +01:00
Zdenek Kabelac
39eee85fff makefiles: better logging
Show only filename instead of full path name when building
in builddir != srcdir
2021-03-02 22:54:40 +01:00
Zdenek Kabelac
0f377a04e5 dmsetup: initilize winsize struct
Ensure winsize struct is always defined.
2020-09-01 17:57:50 +02:00
Zdenek Kabelac
19e9c88faf gcc: do not use return with void function
Follow C norm and do not use 'return' in void function to call other
functions.
2020-08-28 21:43:03 +02:00
Zdenek Kabelac
ac38b576f9 dmsetup: no memleak on failed realocation
clang: keep old buf pointer for release on failing realloc() codepath.
2020-02-04 17:22:06 +01:00
Marian Csontos
3e01ff2783 dm: fix compilation of dmsetup
Fix: 889c88e9da
Use correct enum DM_DEVICE_GET_TARGET_VERSION.
2019-10-22 13:39:45 +02:00
Mikulas Patocka
667b33dd3b dm: introduce DM_GET_TARGET_VERSION
Adds support for the DM_GET_TARGET_VERSION to dmsetup.
It introduces a new comman "target-version" that will accept list
of targets and print their version.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2019-10-04 17:31:55 +02:00
Bryn M. Reeves
8f02f8dcd7 dmsetup: do not treat no groups as an error in dmstats list --group
Analogous to the case of a device with no regions, it is not an
error to attempt to list the stats groups on a device that has no
configured groups: just return success and continue.
2019-09-30 17:10:05 +01:00
Zdenek Kabelac
a50c127904 dmsetup: missed trailing newline 2019-08-26 17:22:58 +02:00
Zdenek Kabelac
a18f562913 dmsetup: debug print
Udev debugging is a bit tricky, so to more easily pair cookie ID,
which is the lowest 16 bit - print cookie as hexa number.
This simplify pairing of processed cookies while the 'higher bit flags'
are changed for the same cookie.
2019-08-20 12:50:44 +02:00
Alasdair G Kergon
ccfbd505fe dmsetup: Fix multi-line concise table parsing
Use the correct loop variable within the loop, instead of reusing the
initial value.  Table lines after the first don't get terminated in
the right place.

Signed-off-by: Kurt Garloff <kurt@garloff.de>
2019-02-25 13:41:51 +00:00
Zdenek Kabelac
18aa541ca2 configure: avoid repeative inclusion of configure.h
Since configure.h is a generated header and it's missing traditional
ifdefs preambule - it can be included & parsed multiple times.
Normally compiler is fine when defines have same value and there is
no warning - yet we don't need to parse this several times
and by adding -include  directive we can ensure every file
in the package is rightly compile with configure.h as the
first header file.
2018-12-21 19:19:50 +01:00
Zdenek Kabelac
0dc7abe013 makefiles: dm-tools improve Makefile 2018-12-17 10:55:20 +01:00
Zdenek Kabelac
c666e8d25e dmfilemapd: avoid linking with DL_LIBS
Dmfilemapd is not using dlopen so doesn't need to be linked with
DL_LIBS.
2018-12-14 22:27:33 +01:00
Zdenek Kabelac
0b19387dae headers: use configure.h as 1st. header
Ensure configure.h is always 1st. included header.
Maybe we could eventually introduce gcc -include option, but for now
this better uses dependency tracking.

Also move _REENTRANT and _GNU_SOURCE into configure.h so it
doesn't need to be present in various source files.
This ensures consistent compilation of headers like stdio.h since
it may produce different declaration.
2018-12-14 15:09:13 +01:00
Zdenek Kabelac
ceb2f0ad3b makefiles: updates for less verbosity 2018-11-29 23:05:43 +01:00
Zdenek Kabelac
70e3d0a613 cov: remove unused assigns 2018-11-05 17:25:11 +01:00
Zdenek Kabelac
a91ac41b93 cov: hide intentionaly ptr arithmetic report
Only single region count is ever replaced with on-stack uint64_t.
2018-11-03 16:10:32 +01:00
Bryn M. Reeves
925aaf0b87 dmsetup: fix stats report command output
Since the stats handle is neither bound nor listed before the
attempt to call dm_stats_get_nr_regions(), it will always return
zero: this prevents reporting of any dmstats regions on any
device.

Remove the dm_stats_get_nr_regions() check and instead rely on
the correct return status from dm_stats_populate() which only
returns 0 in the case that there are regions to inspect (and
which logs a specific error for all other cases).

Reported-by: Bryan Gurney <bgurney@redhat.com>
2018-11-01 17:00:06 +00:00
Zdenek Kabelac
9b71212262 cov: dmstats check for failing malloc
Add missing check for allocation success.
2018-10-15 17:49:44 +02:00
Bryn M. Reeves
29b9ccd261 dmsetup: fix error propagation in _display_info_cols()
Commit 3f35146 added a check on the value returned by the
_display_info_cols() function:

  1024         if (!_switches[COLS_ARG])
  1025                 _display_info_long(dmt, &info);
  1026         else
  1027                 r = _display_info_cols(dmt, &info);
  1028
  1029         return r;

This exposes a bug in the dmstats code in _display_info_cols:
the fact that a device has no regions is explicitly not an error
(and is documented as such in the code), but since the return
code is not changed before leaving the function it is now treated
as an error leading to:

  # dmstats list
  Command failed.

When no regions exist.

Set the return code to the correct value before returning.
2018-06-28 14:25:30 +01:00