summaryrefslogtreecommitdiffstats
path: root/libblkid
Commit message (Collapse)AuthorAgeFilesLines
* libblkid: fix file descriptor leak in blkid_verify()Karel Zak2019-07-312-4/+19
| | | | | | | | | | | | | | The function blkid_verify() uses private device file descriptor and uses blkid_probe_set_device() to assign the descriptor to low-level probing code. Unfortunately, close() in this case is not enough as the prober can internally open whole-disk device too. The library API has been extended so blkid_probe_set_device() deallocates and close previously used prober for whole-disk. This new functionality is used in blkid_verify() now. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1734545 Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: (drbd) fix comment formattingKarel Zak2019-07-221-3/+4
| | | | | | ... to avoid misinterpretation by gtk-docs. Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: do not interpret NTFS as MBRKarel Zak2019-07-173-1/+31
| | | | | | | | | | | | | | | # mkntfs -Q -F /dev/sdc old version: # ./blkid -p /dev/sdc /dev/sdc: UUID="0E9E8C5F2F718479" TYPE="ntfs" USAGE="filesystem" PTTYPE="dos" new version:  # ./blkid -p /dev/sdc /dev/sdc: UUID="0E9E8C5F2F718479" TYPE="ntfs" USAGE="filesystem" Reported-by: Mike Fleetwood <mike.fleetwood@googlemail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: (drbd) simplify paddingKarel Zak2019-07-151-4/+14
| | | | | | | | | We do not need all the metadata and it seems the extra padding is problematic in some cases. Let's keep is simple and use fixed offset for the metadata rather than sizeof(). References: https://github.com/karelzak/util-linux/pull/820 Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: fix address sanitizer issuesSami Kerola2019-07-142-2/+2
| | | | | | | | | | | | | | | | | | | With aligned attribute many blkid tests fail with following error. So instead of aligning to 4K add padding that makes the struct same size without causing asan trip over. libblkid/src/superblocks/drbd.c:179:6: runtime error: member access within misaligned address 0x55913d7e6958 for type 'struct meta_data_on_disk_9', which requires 4096 byte alignment In zfs structure it seems compiler is adding padding, that does not mix well with be32_to_cpu() and other bit operations. libblkid/src/superblocks/zfs.c:109:23: runtime error: load of misaligned address 0x7ff6406540e4 for type 'uint32_t' (aka 'unsigned int'), which requires 8 byte alignment Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libblkid: check number of test_blkid_save arguments correctlySami Kerola2019-07-141-1/+1
| | | | | | | Without this running test_blkid_save without arguments will cause a crash when strdup() refers to none-exiting file name. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libblkid: fix detection of dm-integrity superblock versionMilan Broz2019-06-041-1/+1
| | | | | | | | Kernel 5.2 can use superblock version 3 for dm-integrity. Let's remove the explicit version check to be compatible with future extensions. Signed-off-by: Milan Broz <gmazyland@gmail.com>
* libblkid: remove unneeded fields from struct bcache_super_blockSami Kerola2019-05-271-46/+7Star
| | | | | | | | | | | | | | | | This started as fix to following warning. libblkid/src/superblocks/bcache.c:33:3: warning: ISO C99 doesn’t support unnamed structs/unions [-Wc99-c11-compat] But when sent to review Karel told out rather than getting rid of warnings lets get rid of everything unnecessary. [kzak@redhat.com: - use original struct member names rather than 'padN'] Reference: https://github.com/karelzak/util-linux/pull/802 Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: (silicon raid) improve checksum calculation ↵Karel Zak2019-05-221-3/+7
| | | | | | | | | | [-Waddress-of-packed-member] Let's keep compilers and static analyzers happy. The idea is to use memcpy() to copy from buffer to variable and use all label as unsigned char rather than vectorize by uint16_t. Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: make partitions reference counting more robust [coverity scan]Karel Zak2019-05-151-2/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: don't ignore blkid_probe_set_magic() errors [coverity scan]Karel Zak2019-05-151-4/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: fix possible uninitialized value use [coverity scan]Karel Zak2019-05-151-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: Set BLKID_BID_FL_VERIFIED in case revalidation is not neededNikolay Borisov2019-05-141-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | If blkid_verify deems that device revalidation is not needed since BLKID_PROBE_MIN seconds haven't elapsed since the last revalidation of the device it returns a blkid_dev. However, if this device has been read from the cache file on disk then it wont' have BLKID_BID_FL_VERIFIED bit set. This in turn could lead to a later call to blkid_dev_get free this device in case its part of a multi device configuration. This is particularly relevant to btrfs raid configurations. Namely this was exhibited by btrfs-progs which use blkid for device enumeration. In case of a multi-device filesystem (i.e raid10) running xfstest btrfs/011 would fail sporadically since cached devices read from cache were not revalidated due to being recently validated (according to timestamp in the cache file) at the same time their in-memory blkid_dev structures didn't have BLKID_BID_FL_VERIFIED set. This lead to their untimely removal from the cache from blkid_get_dev. Fix this by setting the BLKID_BID_FL_VERIFIED when returning from blkid_verify with a valid device irrespective of whether full revalidation was performed or the device is deemed valid due to being recently validated. [kzak@redhat.com: - remove also check for BLKID_BID_FL_VERIFIED, the function needs to check for elapsed time only] Signed-off-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: Don't check BLKID_PROBE_INTERVAL in blkid_verifyNikolay Borisov2019-05-141-2/+1Star
| | | | | | | | | | That constant is set to 200 seconds and is already check in probe_all(). It essentially controls how often blkid_probe_all can do a full cache revalidation. Since blkid_verify is called from within probe_all() iff at least BLKID_PROBE_INTERVAL seconds have elapsed it makes no sense to check this value in blkid_verify. Signed-off-by: Nikolay Borisov <nborisov@suse.com>
* docs: fix typos [codespell]Sami Kerola2019-02-181-1/+1
| | | | | Reference: https://github.com/codespell-project/codespell Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* various: fix 'uninitialized when used' warnings [clang]Sami Kerola2019-02-185-5/+5
| | | | | | | This change fixes "warning: variable 'var' may be uninitialized when used here [-Wconditional-uninitialized]" warnings reported in various files. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libblkid: tiny code simplificationKarel Zak2019-02-181-3/+1Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: remove dependence on libuuidKarel Zak2019-01-224-23/+1Star
| | | | | | | | | | | Currently we use libuuid to print UUID only. This code is possible to replace by one snprintf(). It seems better to duplicate this one snprintf than force all distros to keep libuuid together with libblkid. Note, this scenario has been already supported on --disable-libuuid. Reported-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: improve whole-disk detection when read /proc/partitionsKarel Zak2019-01-081-11/+14
| | | | | | | | | | | | | | | | | | blkid(8) in high-level mode checks partitions and unpartitioned whole-disk devices from the file /proc/partitions. The current heuristic assumes that partition name ends with a digit. Unfortunately, this is not correct -- for example md0 or nvme0n1 are whole-disk devices. This commit uses sysfs_devno_is_wholedisk() to make sure the device is a partition (according to kernel or DM). It's probably more expensive, because this way requires more syscalls (to read stuff from /sys etc.). The patch also adds more information to the blkid(8) man page. Addresses: https://github.com/karelzak/util-linux/issues/728 Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: (ntfs) fix compiler warning [-Wpedantic]Karel Zak2019-01-021-6/+4Star
| | | | | | | | libblkid/src/superblocks/ntfs.c:80:2: warning: ISO C restricts enumerator values to range of 'int' (4294967295 is too large) [-Wpedantic] Addressed: https://github.com/karelzak/util-linux/pull/732 Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch 'master' of https://github.com/kvanals/util-linuxKarel Zak2019-01-021-2/+0Star
|\ | | | | | | | | | | | | * 'master' of https://github.com/kvanals/util-linux: Removed BlueStore VERSION information as it is gibberish Updated BlueStore expected result Added BlueStore test image
| * Removed BlueStore VERSION information as it is gibberishKenneth Van Alstyne2018-12-181-2/+0Star
| |
* | libblkid: (bluestore) terminate magic strings arrayKarel Zak2018-12-171-1/+2
| | | | | | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* | Merge branch 'master' of https://github.com/kvanals/util-linuxKarel Zak2018-12-174-0/+57
|\| | | | | | | | | | | * 'master' of https://github.com/kvanals/util-linux: Finished up BlueStore support Added support for detecting Ceph BlueStore Block Devices
| * Finished up BlueStore supportKenneth Van Alstyne2018-12-143-0/+3
| |
| * Added support for detecting Ceph BlueStore Block DevicesKenneth Van Alstyne2018-12-141-0/+54
| |
* | libblkid: stratis: correct byte orderTony Asleson2018-12-171-2/+2
|/ | | | | | | Stratis superblock is little endian, ensure we retrieve the number of sectors and initialization time correctly. Signed-off-by: Tony Asleson <tasleson@redhat.com>
* libblkid: add check for DRBD9Roland Kammerer2018-11-211-4/+107
| | | | | | | This adds the according meta-data structs + defines and an additional function to detect DRBD9 magics. Signed-off-by: Roland Kammerer <roland.kammerer@linbit.com>
* libblkid: Fix hidding typoAndreas Henriksson2018-11-211-1/+1
| | | | | | Spelling error spotted by lintian. Signed-off-by: Andreas Henriksson <andreas@fatal.se>
* libblkid: fix detection of dm-integrity superblockMilan Broz2018-11-121-1/+1
| | | | | | | Some new features in Linux kernel 4.19 for dm-integrity use metadata format version 2, patch adds it to detection. Signed-off-by: Milan Broz <gmazyland@gmail.com>
* docs: use SPDX license namesKarel Zak2018-08-161-1/+1
| | | | | | | | | | Let's use standardized names for licenses. The names used by SPDX makes things more obvious at first glance. For complete list see: https://spdx.org/licenses/ Note, this commit does not change any license or so... Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: use xstrncpy() for PT id [coverity scan]Karel Zak2018-07-251-1/+2
| | | | | | | | It's probably unnecessary change as blkid_parttable_set_id() is used by MBR code and we use proper buffer size there, but better safe than sorry. Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: const qualifier cleanupKarel Zak2018-07-2011-53/+55
| | | | | | | | * use "const" in functions where we don't modify arguments * use "const" when cast from const buffer to any struct (superblock etc.) Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: Check for a secondary LUKS2 header.Milan Broz2018-07-111-13/+47
| | | | | | | | | | | This patch adds search for a secondary LUKS2 header, if the primary one is corrupted. This patch is primarily needed for wipefs that should wipe both signatures (otherwise LUKS2 header recovery can use secondary header and revert wipefs action). Signed-off-by: Milan Broz <gmazyland@gmail.com>
* libblkid: Add more APFS checking to avoid false positivesHarry Mallon2018-07-061-0/+62
|
* libblkid: Add very basic APFS recognitionHarry Mallon2018-06-254-1/+23
|
* libblkid: use new ul_path_* APIKarel Zak2018-06-213-42/+51
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch 'master' of https://github.com/pali/util-linuxKarel Zak2018-05-281-0/+10
|\ | | | | | | | | * 'master' of https://github.com/pali/util-linux: libblkid: udf: Fix reporting UDF 2.60 revision
| * libblkid: udf: Fix reporting UDF 2.60 revisionPali Rohár2018-05-251-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | According to the UDF 2.60 specification, the Minimum UDF Read Revision value shall be at most #0250 for all media with a UDF 2.60 file system. So in this case use Minimum UDF Write Revision as ID_FS_VERSION to distinguish between UDF 2.50 and UDF 2.60 discs. This commit also adds a testing Blu-Ray Recordable image with UDF revision 2.60 created by Nero which really sets Minimum UDF Read Revision to 2.50. Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
* | libblkid: (ntfs) fix cluster size checkKarel Zak2018-05-251-1/+1
|/ | | | | Addresses: https://github.com/karelzak/util-linux/issues/641 Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: (ntfs) enlarge cluster limit to 2MBKarel Zak2018-05-251-4/+8
| | | | | | | | | | Windows 10 Creators edition has extended the ntfs cluster limit to 2MB. As a consequence blkid does not identify recent partitions with clusters beyond 65K as ntfs ones. Addresses: https://github.com/karelzak/util-linux/issues/641 Signed-off-by: Karel Zak <kzak@redhat.com> Co-Author: Jean-Pierre André <jean-pierre.andre@wanadoo.fr>
* libblkid: (zfs) fix compiler warning [-Wmaybe-uninitialized]Karel Zak2018-05-031-1/+1
| | | | | Reported-by: L A Walsh <lkml@tlinx.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: add BitLocker detectionKarel Zak2018-04-245-0/+199
| | | | | | | | | | | | | Supported: * WinVista version * Win7 and later versions (based on NTFS) * BitLockerToGo (for removable media; based on FAT32) Unfortunately, it's without LABEL and UUID. It seems BitLocker does not use volume_label and volume_serial stuff from NTFS header. Addresses: https://github.com/karelzak/util-linux/issues/617 Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: (hfs) check allocation sizeKarel Zak2018-04-121-0/+9
| | | | | | | | | The current prober is based on signature only (two bytes!). It seems pretty fragile. Linux kernel also checks for allocation size in the superblock, let's use it too... it's better than nothing. Reported-by: Milan Broz <gmazyland@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch 'master' of https://github.com/pali/util-linuxKarel Zak2018-03-271-5/+7
|\ | | | | | | | | | | | | * 'master' of https://github.com/pali/util-linux: tests: Add tests for FAT32 labels blkid: Encode any field which starts with LABEL in same way as LABEL field libblkid: vfat: Change parsing label in special cases
| * libblkid: vfat: Change parsing label in special casesPali Rohár2017-11-251-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Use only label from the root directory and do not fallback to the label stored in boot sector. This is how MS-DOS 6.22, MS-DOS 7.10, Windows 98, Windows XP and also Windows 10 behave. Moreover Windows XP and Windows 10 do not touch label in boot sector anymore, so removing FAT label on those Windowses leads to having old label still stored in boot sector (which MS-DOS and Windows fully ignore). * Label entry "NO NAME" in root directory is treated as label "NO NAME" instead of empty label. In root directory it has no special meaning. String "NO NAME" has a special meaning (empty label) only for label stored in boot sector. * Label from the boot sector is now stored into LABEL_FATBOOT field. So if there are applications which depends or needs to read this label, they have ability. After this change LABEL always correspondent to the label from the root directory and LABEL_FATBOOT to the label stored in the boot sector. If some of those labels is missing or is not present (e.g. "NO LABEL" in boot sector) then particular field is not set. Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
* | libblkid: ignore private Stratis devicesTony Asleson2018-03-092-3/+3
| | | | | | | | | | | | | | | | [kzak@redhat.com: - tiny coding style changes] References: 20e1c3dc03399d6988ef35dedc1364cfc12e9263 Signed-off-by: Tony Asleson <tasleson@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* | libblkid:(dos) make subtypes probing more robustKarel Zak2018-02-271-7/+18
| | | | | | | | | | | | | | | | | | The current code mix partitions as defined on disk with partitions from partlist (as recognized by libblkid). It seems better to follow partlist only. Reported-by: Vaclav Dolezal <vdolezal@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* | libblkid: (mpool) checksum is LEKarel Zak2018-02-261-1/+1
| | | | | | | | | | Reported-by: Ruediger Meier <ruediger.meier@ga-group.nl> Signed-off-by: Karel Zak <kzak@redhat.com>
* | libblkid: (mpool) don't use gtkdocs-like comment blockKarel Zak2018-02-211-3/+1Star
| | | | | | | | Signed-off-by: Karel Zak <kzak@redhat.com>