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

1508 Commits

Author SHA1 Message Date
Zdenek Kabelac
2b198cd874 const: dmsetup long_options 2024-05-04 01:01:57 +02:00
Zdenek Kabelac
8daa702880 const: dmsetup string 2024-05-04 01:01:57 +02:00
Zdenek Kabelac
9a9db862a4 const: dmfilemapd strings 2024-05-04 01:01:57 +02:00
Zdenek Kabelac
e0bd66b73a const: use common error path
Instead of defining  _field_selection_value_alloc_failed_msg[],
use common error path code for printing field_id.
2024-05-04 01:01:57 +02:00
Zdenek Kabelac
c9f9744f50 const: libdm cmd_data_v4 2024-05-04 01:01:57 +02:00
Zdenek Kabelac
9247e754fe const: libdm tok_op 2024-05-04 01:01:57 +02:00
Zdenek Kabelac
e6f46fafe7 const: use arrays of strings 2
Next set of changes.
2024-05-04 01:01:57 +02:00
Zdenek Kabelac
efe2005022 const: drop static keyword
We don't need relocatable space to store 'const' number.
2024-05-04 01:01:57 +02:00
Zdenek Kabelac
abf7c40185 const: static array
Such array can be stored  in   .rodata   section.
2024-05-04 01:01:57 +02:00
Zdenek Kabelac
2a1e200f7a libdm: fix condition
When we switch supported_reserved_types_with_range to const
gcc repots this problem:

 warning: ‘and’ of mutually exclusive equal-tests is always 0
 !(iter->type & supported_reserved_types_with_range))) {

It's not clear from the history what was the actual intention of this
internal error test, let's assume the check wanted to make sure
that when DM_REPORT_FIELD_RESERVED_VALUE_RANGE is set,
some other fields from supported_reserved_types_with_range set
are also selected.
2024-05-04 00:58:44 +02:00
Zdenek Kabelac
9b2f9d64c0 libdm: ensure suffixes list elements are const
This was rather API mistake - the internal of libdm
do handle suffixes list as const string, just the API
was only using  'const char **'.

So the user may pass safely casted 'const char * const`.
2024-05-04 00:57:52 +02:00
Zdenek Kabelac
95fca3d1d5 makefile: avoid creating shared lib for static only build 2024-04-26 21:37:51 +02:00
Zdenek Kabelac
b0c0e8bd7a makefiles: change condition
Old system do not work well with -l% in findstring,
so use a different strategy to recognize whether -lreadline needs
another library (-ltinfo, -lncourses...)
(So we don't need to solve this via 'configure')

Also for now comment out -Wl,-z,pack-relative-relocs and leave it
for the package maintainer whether they want to use.
Possibly add some 'configure' autodetection for usable switch,
as it's relatively new feature..
2024-04-25 17:06:07 +02:00
Zdenek Kabelac
b14f29ab5b makefiles: comman escape needs this trick 2024-04-24 13:42:05 +02:00
Zdenek Kabelac
a8009f72bf makefiles: add as-needed only for newer systems
Add some -Wl flags separatly and avoid their duplication.
Also add --as-needed only when system is using 'newer' readline
library - on these older system the usage of '--as-needed'
seems to be causing some hard to solve problem - so avoid it.
2024-04-24 11:35:05 +02:00
Zdenek Kabelac
078445658c configure.ac: update ldflags args
Attach -Wl,-z,relro,-z,now,-z,pack-relative-relocs,--as-needed
to LDFLAGS, but only if LDFLAGS already doesn't contain 'relro'
(so it's not given repeatedly).

Also start to use -z,now linkage also when building libraries
with default compilation - this avoid calling symbol resolver
while library function are using function needing resolving.

Note: Fedora or RHEL rpm building is using:
CFLAGS=$(rpm --eval %{build_cflags})
LDFLAGS=$(rpm --eval %{build_ldflags})

Also split -DUSE_SD_NOTIFY into DEFS from CFLAGS.
2024-04-24 00:31:26 +02:00
Zdenek Kabelac
f022da9e5f configure.ac: leave LDFLAGS resolving on make time
Use LDFLAGS separately with every use of CLDFLAGS and leave
this flag only for handling versioning.

This will reflect any LDFLAGS setting use during make.
2024-04-24 00:30:05 +02:00
Zdenek Kabelac
84b084c9b6 configure.ac: define DEFAULT_PROC_DIR in one place
Let's move proc into include/configure.h so this define can
be easily used across the source base.

Configure defines it - but ATM we do not provide any configure
option to change it - there should be no need to ever change it.
2024-04-15 13:38:44 +02:00
Zdenek Kabelac
fa62397ff8 cov: mask false positive
This code is somewhat complex and involves recursion and pointer
shuffling which confuses coverity here.

Let's add masking comment for this warning as there is no double
free in this code.
2024-04-10 00:03:09 +02:00
Zdenek Kabelac
e7a54c1a50 cov: use safer version with size limitation
Although there is likely not much risk of having chance of overwritting
given buffers use safer variant.
Use dm_strncpy() when just copying %s.
2024-04-10 00:03:09 +02:00
Zdenek Kabelac
3ce83f923d cov: extra pointer validation
Add few more internal errors to enusure there is no use of NULL pointers
along the code path.
2024-04-10 00:03:09 +02:00
Zdenek Kabelac
22a0cfdc05 cov: use memccpy
When we want to copy string which may not be null terminated,
replace strncpy with more correct memccpy.
2024-04-10 00:03:09 +02:00
Zdenek Kabelac
88ad83e3d6 makefiles: use SHOW 2024-04-08 14:52:23 +02:00
Zdenek Kabelac
d490572410 gcc: clear some complains
Use dm_strncpy() were possible to get rid of gcc compile warnings.
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
a98709aeae cov: validate count is bigger then 0
To avoid teoretical underflow...
2024-03-29 01:36:48 +01:00
Zdenek Kabelac
93a633092a cov: store 64b flags
Alhtough no target is currently using that many bits for their flags,
preserve the size for loaded segment internally.
2024-03-29 01:36:48 +01:00
Zdenek Kabelac
0dbd90d74e gcc: match signed integers 2024-03-27 01:11:00 +01: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
Zdenek Kabelac
50ad27a4ab reporting: reuse existing _get_field
Use already existing _get_field() function that also
slightly optimizes 'strlen()' usage.
2024-03-25 11:05:05 +01:00
Zdenek Kabelac
2eff6e1974 raid: update dm_get_status_raid
Handle mismatch of reported 'dm raid' status, where the active
raid LV can be actually showing higher numebr of raid leg devices,
that the number of shown status characters.

This can happen if the raid leg is dropped during initial
resynchronization.
2024-03-25 11:05:05 +01:00
Zdenek Kabelac
68fdae1184 debug: enhace device_mapper debug log for dm tree 2024-03-17 13:17:53 +01:00
Marian Csontos
d1f0b89e65 dmstats: Fix memory leak on error path 2023-11-28 22:00:14 +01:00
Zdenek Kabelac
3f084b06e9 device_mapper: raid status handle all a chars
When getting raid status from some older kernels, we may get an 'a'
for 'A' leg when doing initial synchronization.
This may prohibit removal of newly synchronized leg until synchronization
is finished.
So in this case change the status to look like being reported
from a newer kernel version.
2023-10-31 18:52:05 +01:00
Peter Rajnoha
c36e012926
libdm: report: fix invalid JSON if using DM_REPORT_OUTPUT_MULTIPLE_TIMES and selection
When reporting in JSON format, we need to be able to find the 'last
displayed row', not just 'last row' as we did before. This is used
to decide whether to put the JSON_SEPARATOR (the ',' character)
between the lines when reporting in JSON format.

This is mainly important in case we use a combination of JSON format
and a report marked with DM_REPORT_OUTPUT_MULTIPLE_TIMES flag.
Such report may be reused several times with different selection
criteria each time. In that case, the report always contains all lines
in memory, even though some of them do not need to pass the selection
criteria that are currently used.

Without DM_REPORT_OUTPUT_MULTIPLE_TIMES flag, the report only contains
the lines that have passed the selection criteria, so the this wasn't
an issue in this case.

Fix suggested by Lars Ellenberg and reported here: https://github.com/lvmteam/lvm2/issues/130
2023-10-23 14:18:21 +02:00
Zdenek Kabelac
c6efab0111 cov: avoid resoure leaks on error path 2023-10-14 23:12:57 +02:00
Zdenek Kabelac
e8e5e6ee3c cov: check next_get token exists 2023-10-14 23:12:57 +02:00
Zdenek Kabelac
85c7629345 libdm: versionion symbol for enhanced dm_task_run
When new app links with current dm_task_run() that propagates ioctl()
errno - ensure it will not be usable with older version without this
supported feature.
2023-10-14 01:04:10 +02:00
Zdenek Kabelac
b162475391 makefiles: fix missing libs
Recent commit  dc8837f079
became actually to strict - we always want to build lib.a files.
2023-10-13 16:34:48 +02:00
Zdenek Kabelac
0bbbe08343 dmfilemapd: ensure program_id is initialized
Assing program_id before return 1,
and also stay C99 compatible with size_t declaration.
2023-10-13 16:04:25 +02: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
0ff027ae2c dmstats: only generate aux data separator if group tag is defined
Fix a bug in _stats_set_aux() that causes bogus data to appear
in the 'userdata' field of stats reports when previously grouped
regions are ungrouped:

/var/tmp/File With Spaces: Created new group with 1 region(s) as group ID 0.

Removed group ID 0 on fedora-root

Name             GrpID RgID ObjType RgStart RgSize  #Areas ArSize  ProgID  UserData
fedora-root          -    0 region    6.39g 100.00m      1 100.00m dmstats #-
                                                                           ^^
This is the aux_data separator character followed by empty user data.
The _stats_set_aux() function should only emit the separator if
there is a valid group descriptor for the region.
2023-10-12 11:31:14 +00: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
7d8981dd3f dmstats: support group aliases with embedded whitespace
Creating a group with a name that contains whitespace causes an error in
the @stats_set_aux message:

device-mapper: message ioctl on  (253:0) failed: Invalid argument
Could not create regions from file /var/tmp/File With Spaces.

Fix this by quoting the group alias and backslash escaping any
embedded space characters.
2023-10-12 11:31:14 +00:00
Bryn M. Reeves
33931431c3 Refactor _stats_parse_list_region()
Refactor the function that parses regions from @stats_list data to
separate the parsing of variable string data from the fixed parts
of the @stats_list response.
2023-10-12 11:31:14 +00:00
Bryn M. Reeves
ac41deeeac Rename _stats_set_aux() argument
The aux_data argument of _stats_set_aux() is the user-defined data
to be stored with the stats region. Rename the argument to better
reflect this.
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
Bryn M. Reeves
eda99fc383 Clean up group struct in _stats_create_group() error path
Fix a double free in the error path from _stats_create_group() by
clearing the group struct embedded in the dm_stats handle before
returning:

    device-mapper: message ioctl on  (253:0) failed: Invalid argument
    Could not create regions from file /var/tmp/File With Spaces.
    free(): double free detected in tcache 2
    Aborted (core dumped)
2023-10-12 11:31:14 +00:00