summaryrefslogtreecommitdiff
path: root/libdm
Commit message (Collapse)AuthorAgeFilesLines
* cov: hide some false positivesZdenek Kabelac2023-05-102-1/+1
| | | | | | Hide some false positives. Note: there must not a be blank line after coverity hiding comment.
* configure.ac: use pkg-config to detect static libsRobin H. Johnson2023-02-231-1/+4
| | | | | | | | | | | Add some Gentoo based patches for better support of static linking. This are not tested nor supported by upstream developers. Usage requires presence of several libraries in their static form which is however not commonly available. Selinux modified by zkabelac to still work on older sofrware which did not provided libselinux.pc at a time - see keep the old check present and use pkg-config only when possible.
* configure.ac: add STATIC_LDFLAGSDavid Seifert2023-02-232-2/+3
| | | | Add support for specif STATIC_LDFLAGS when linking static binaries.
* makefiles: add pthread to libdevmapper pkgconfigDavid Seifert2023-02-231-1/+1
| | | | Add pthread to pkg_config file.
* configure.ac: use LIBSYSTEMDZdenek Kabelac2023-02-171-1/+1
| | | | | | | Convert naming SYSTEMD_CFLAGS/LIB -> LIBSYSTEMD_CFLAGS/LIBS to better fit library check for libsystemd. Build lvmlockd with SD_NOTIFY when we have defined LIBSYSTEMD_LIBS.
* makefiles: allow using configure cppflagsZdenek Kabelac2023-02-131-2/+3
| | | | | | | Configure defines 'CPPFLAGS' and we should use defined value for compilation. Reported-by: debian
* libdm: match reactivation of sibling for snapshotZdenek Kabelac2023-02-131-0/+89
| | | | | Apply same code for libdm as in device_mapper dir from commit c8a5948a71b041ae2cce03e1b3a9843f0fab023f.
* libdm: improve parallel create of control nodeZdenek Kabelac2023-02-131-2/+7
| | | | | | | | | | | When two parallel commands would have tried to create our /dev/mapper/control node at the same time, one of them could actually fail even if the 2nd. command actually mknod() this control node correctly. So for EEXIST case add detection if the control node is ok. This may possibly help with some race case in early boot.
* libdm: correcting ifdef possitionZdenek Kabelac2023-01-161-1/+3
| | | | Fix building without ioctl support.
* doc: fix typos in documentationSamanta Navarro2023-01-031-1/+1
| | | | Typos found with codespell.
* cov: fix buffer size usageZdenek Kabelac2022-12-201-1/+1
| | | | Count with extra 1 byte for buffer end '\0'.
* dmsetup: fix udev event handling for createZdenek Kabelac2022-11-251-5/+9
| | | | | | | | | | | | | | | | | | | | 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
* configure: allow for overriding of `readelf`David Seifert2022-11-252-2/+3
| | | | | | | This allows users to use e.g. `llvm-readelf` on systems with binutils as default. Bug: https://bugs.gentoo.org/840628
* make: update make.tmplZdenek Kabelac2022-09-071-5/+19
| | | | | | Add new define 'newline' for use in 'foreach()' Add new $(SHOW) for makefile printing output Add 'make print-VAR' for easier debugging of Makefiles' variables.
* libdm: report: fix escaping of JSON quote char in reported fieldsPeter Rajnoha2022-08-241-8/+3
| | | | | | | | | | | | | | | | | | Commit 73ec3c954b21522352b6f5cce9a700d6bf30ccf4 added a way to print only a part of the report string (repstr) to support decoding individual string list items out of repstr. The repstr is normally printed through _safe_repstr_output so that any JSON_QUOTE character ('"') found within the repstr is escaped to not interfere with value quoting in JSON format. However, the commit 73ec3c954b21522352b6f5cce9a700d6bf30ccf4 missed checking the 'len' argument passed to _safe_repstr_output function when adding the rest of the repstr after all previous JSON_QUOTE characters were escaped (when calling the last dm_pool_grow_object). When 'len' is 0, we need to calculate the 'len' ourselves in the function by simply calling strlen. This is because 'len' is passed to the function only if we're taking a part of repstr, not as a whole.
* dmsetup: check also for ouf of range valueZdenek Kabelac2022-08-191-1/+2
| | | | Check errno result from strtoull().
* libdm: report: use proper JSON array for string list output in JSON_STD formatPeter Rajnoha2022-08-111-4/+84
| | | | | | | | | | In JSON format, we print string list this way: "key" = "item1,item2,...,itemN" while in JSON_STD format, we print string list this way: "key" = ["item1","item2",...,"itemN"]
* libdm: report: separate basic and JSON+JSON_STD format in _output_fieldPeter Rajnoha2022-08-111-71/+94
| | | | | Use separate functions to handle basic and JSON+JSON_STD format. It's clearer this way than interleaving both in the same function.
* libdm: report: enhance the way string list is stored internallyPeter Rajnoha2022-08-111-116/+190
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before, we stored only the report string itself for a string list in field->report_string. The field->report_string has either sorted items or not, depending on what we need for a field - some report fields have sorted output, some don't... The field->sort_value.value then contains pointer to the exact field->report_string. The field->sort_value.items ALWAYS keeps sorted array of individual items, represented as '[position,length]' pairs pointing to the field->sort_value.value string. This approach was fine as far as we didn't need to apply further formatting to field->report_string. However, if we need to apply further formatting to field->report_string content, taking into account individual items, we also need to know where each item starts and what is its length. Before, we only knew this when items in report string were sorted, but not in the unsorted version. We can't rely on the delimiter (default ",") only to separate items back out of report string, because that delimiter can be contained in the item value itself. So this patch enhances the field->report_string for a string list so it also contains '[position,length]' pairs for each individual item inside field->report_string. We store this array right beyond the string itself and we encode it in the same manner we already did for field->sort_value.items before. If field->report_string has sorted items, the field->sort_value.items just points to the array of items we store beyond the report string. If field->report_string has unsorted items, we store separate array of items for both field->report_string and field->sort_value. This patch also cleans up the _report_field_string_list function a bit so it's easier and more straightforward to follow than the original version. Example. If we have "abc", "xy", "defgh" as list on input with "," as delimiter, then: - field->report_string will have: - if we need field->report_string unsorted: abc,xy,defgh\0{[3,12],[0,3],[4,2],[7,5]} |____________||________________________| string array of [pos,len] pairs |____||________________| #items items - if we need field->report_string sorted: repstr_extra | V abc,defgh,xy\0{[3,12],[0,3],[4,5],[10,2]} |____________||________________________| string array of [pos,len] pairs |____||________________| #items items - field->sort_value will have: - if field->report_string is unsorted: field->sort_value.value = field->report_string field->sort_value.items = {[0,3],[0,3],[7,5],[4,2]} (that is 'abc,defgh,xy') - if field->report_string is sorted already: field->sort_value.value = field->report_string field->sort_value.items = repstr_extra (that is also 'abc,defgh,xy')
* libdm: report: use 'null' for undefined numeric values in JSON_STD outputPeter Rajnoha2022-08-111-1/+7
| | | | | | | | | | | | | | | For JSON_STD format, use 'null' if a field has no value at all. In JSON format, we print undefined numeric values this way: "key" = "" while in JSON_STD format, we print undefined numeric values this way: "key" = null (Keep in mind that 'null' is different from 0 (zero value) which is a defined value.)
* libdm: report: remove double quotes around numeric values in JSON_STD outputPeter Rajnoha2022-08-111-7/+20
| | | | | | | | | | | | In JSON format, we print numeric values this way: "key" = "N" while in JSON_STD format, we print numeric value this way: "key" = N (Where N is a numeric value.)
* libdm: report: add DM_REPORT_GROUP_JSON_STD groupPeter Rajnoha2022-08-112-3/+13
| | | | | | | The original JSON formatting will be still available using the original DM_REPORT_GROUP_JSON identifier. Subsequent patches will add enhancements to JSON formatting code so that it adheres more to JSON standard - this will be identified by new DM_REPORT_GROUP_JSON_STD identifier.
* cov: remove unused headersZdenek Kabelac2022-07-111-1/+0
|
* libdm: unmangling UUID for DM_DEVICE_LISTZdenek Kabelac2021-12-201-8/+43
| | | | | Properly unmangle UUID if they are provided as result of DM_DEVICE_LIST ioctl on newer linux kernels.
* libdm: correct version checkZdenek Kabelac2021-12-201-4/+2
| | | | | If there ever would be API version 5, these check would give incorrect results.
* cov: validate subcommand existanceZdenek Kabelac2021-10-151-2/+2
| | | | | Before dereference of subcommand pointer, check it's not NULL as coverity believes there exists theoretical path for this...
* make: replace legacy use rindex with strrchrZdenek Kabelac2021-09-271-1/+1
| | | | | | Seems already dropped by some systems. Reported-by: adamboardman of gemian
* dmsetup: fix measure handlingZdenek Kabelac2021-09-271-1/+2
| | | | | | Previous patch f853a1bc7afdebb44aeb8c1167e8784d155cad84 enabled ima measurement unconditionally for every status call, but it needs to be set only for 'dmsetup measure' command.
* libdm: dmsetup measure support for IMAAlasdair G Kergon2021-09-237-4/+35
| | | | | | | Add support for DM_IMA_MEASUREMENT_FLAG with DM_TABLE_STATUS_CMD. This feature requires DM version 4.45 (5.15+ kernels)
* libdm: support DM_NAME_LIST_FLAGZdenek Kabelac2021-09-231-0/+14
| | | | | | | | | | | | | | | | | Kernel patch 8b638081bd4520f63db1defc660666ec5f65bc15 introduced support to return UUID in DM_LIST_DEVICES_CMD. Useful when asking for UUID of each device where the list could be now returned directly with NAME && UUID for each device. Returning UUID is done in backward-compatible way. There's one unused 32-bit word value after the event number. This patch sets the bit DM_NAME_LIST_FLAG_HAS_UUID if UUID is present and DM_NAME_LIST_FLAG_DOESNT_HAVE_UUID if it isn't (if none of these bits is set, then we have an old kernel that doesn't support returning UUIDs). The UUID is stored after this word. The 'next' value is updated to point after the UUID, so that old version of libdevmapper will skip the UUID without attempting to interpret it.
* gcc: use more zero length arraysZdenek Kabelac2021-09-224-7/+7
| | | | Define last array struct member with zero size.
* cov: ignore leak of fd descriptorZdenek Kabelac2021-09-211-5/+4
| | | | There is no 'fd' leak.
* gcc: avoid warns on missing braces with older versionZdenek Kabelac2021-09-201-1/+1
|
* cov: mask some warning about leakageZdenek Kabelac2021-09-201-0/+1
| | | | Mask false-positive leak report.
* cov: hide reports from optarg being NULLZdenek Kabelac2021-09-201-2/+2
| | | | | | 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.
* cov: add explicit NULL pointer checkZdenek Kabelac2021-09-201-3/+4
| | | | Make obvious to coverity strcmp() is not getting NULL pointer.
* cov: use different variable nameZdenek Kabelac2021-09-201-4/+4
| | | | Better for Coverity to see no change for possibly opened handle.
* gcc-fanalyzer: better losetup error pathZdenek Kabelac2021-09-201-0/+3
| | | | | 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.
* cov: hide false positive warningZdenek Kabelac2021-09-131-0/+2
| | | | | | Here we have valid use case of strncpy() which just need to fill precise buffer size - so no explicit \0 on buffer end is needed.
* cov: add some initializersZdenek Kabelac2021-09-132-6/+6
|
* libdm: enhance tracking of activated LVsZdenek Kabelac2021-09-131-29/+21
| | | | | | Existing mechanism was not able to trace root volume issue. Simplify the functionality by using simply using activated flag and trace the dtree in reverse order.
* cache: fix parentheses for migration_thresholdZdenek Kabelac2021-09-131-1/+1
| | | | | | | | | | | When generating table line for cache target line, the estimation of added arguments was incorrectly calculated as the evaluation order of "?" is made after "+". However the result was 'masked' by the Reported-by: Jian Cai jcai19
* cov: ensure bufffe size is at least 5Zdenek Kabelac2021-07-281-1/+1
| | | | | Analyzer can now see, the buffer size will have at least 5 chars on succefull path.
* clang: always initialized valuesZdenek Kabelac2021-04-231-1/+1
|
* cov: daemonize avoid leak of FD on error pathZdenek Kabelac2021-04-231-10/+13
| | | | | Use our common patter for reopening FDs to /dev/null that avoids leaking FD on error path.
* makefiles: deps also for cxxZdenek Kabelac2021-04-121-1/+1
| | | | | Generate deps also for .cxx. Remove include dir deps - there is nothing to build.
* libdm: replace deprecated security_context_tZdenek Kabelac2021-04-121-3/+3
| | | | | | | Use 'char *' instead of deprecated security_context_t. In more details i.e.: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1776
* makefiles: static linking enhancementsZdenek Kabelac2021-04-123-20/+17
|
* libdm: fix compiling with older gccZdenek Kabelac2021-04-061-1/+4
|
* makefiles: remove unneeded var changesZdenek Kabelac2021-04-061-3/+0
|