summaryrefslogtreecommitdiffstats
path: root/libblkid/src/verify.c
Commit message (Collapse)AuthorAgeFilesLines
* libblkid: fix file descriptor leak in blkid_verify()Karel Zak2019-07-311-1/+3
| | | | | | | | | | | | | | 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: 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>
* libblkid: ignore private Stratis devicesTony Asleson2018-03-091-1/+1
| | | | | | | | [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: don't use CDROM_GET_CAPABILITY ioctl for DM devicesKarel Zak2017-07-121-1/+1
| | | | | | | | | For some reason kernel commit e980f62353c697cbf0c4325e43df6e44399aeb64 add extra warning when the ioctl is used for DM devices. It seems we can avoid this ioctl when the device has dm/uuid. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1469532 Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-02-201-2/+2
| | | | | | | | | | text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer Since many 'struct option' has used zero as NULL make them more readable in same go by reindenting, and using named argument requirements. Reference: https://lwn.net/Articles/93577/ Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libblkid: fix compiler warning [-Wimplicit-function-declaration]Karel Zak2014-06-181-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: add sysfs_devno_is_lvm_private() from libblkidKarel Zak2014-06-171-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: ignore private LVM devicesKarel Zak2014-06-101-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The virtual private LVM devices do not contain any blkid relevant data and it does not make any sense to scan for superblocks or partitions on the devices, because we can interpret data from the devices in bad way. Unfortunately, for LVM has "private" very special meaning. The private LVM devices are accessible and readable (according to LVM guys it's feature, because debugging etc.). The problem is pretty visible with LVM thin provisioning where a virtual pool device contains segments from the top-level thin devices. Mountable top-level LVM-thin device: # blkid -o udev -p /dev/mapper/vg-thin1 ID_FS_UUID=57ed6490-903b-416c-91d2-6d06804ec60c ID_FS_TYPE=ext4 Virtual private LVM-pool device (contains data from all thin devices): # blkid -o udev -p /dev/mapper/vg-pool0 ID_FS_UUID=57ed6490-903b-416c-91d2-6d06804ec60c ID_FS_TYPE=ext4 ... this is incorrect, vg-pool0 is unmountable. LVM uses special UUID suffixes for private devices. All devices with uuid in format "LVM-<uuid>-<type>" are private. This patch modifies libblkid to not scan such devices. The high-level API ignores such devices at all now. The low-level API allows to assign the device to blkid_prober, but all scan functions always return nothing and library does not read anything from the device. The another functionality (get parental device, topology, sector sizes, etc.) still works as expected. The change affects only probing code. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1101345 Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: use new debug functionsKarel Zak2014-03-211-6/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: clean up DBG()Karel Zak2013-04-081-13/+10Star
| | | | | | | | | - use stderr only - use BLKID_ prefix for debug masks - don't use \n in in messages and don't use printf(), but use generic blkid_debug(). Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: Expose more ISO9660 headersZeeshan Ali (Khattak)2013-02-141-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to kill libosinfo's infamous udev rule[1], we need to make blkid report the following information as udev properties on IS09660 media so that libosinfo can make use of that for detection: 1. Volume ID (already exposed as label). 2. System ID. 3. Publisher ID. 4. Application ID. 5. Boot record's boot system ID, (almost always 'EL TORITO SPECIFICATION' if boot record is present). Example use: $ blkid -p -o udev Fedora-17-x86_64-DVD.iso ID_FS_SYSTEM_ID=LINUX ID_FS_APPLICATION_ID=GENISOIMAGE ISO 9660/HFS FILESYSTEM CREATOR (C) 1993 E.YOUNGDALE ID_FS_UUID=2012-05-22-20-55-32-00 ID_FS_UUID_ENC=2012-05-22-20-55-32-00 ID_FS_BOOT_SYSTEM_ID=EL TORITO SPECIFICATION ID_FS_LABEL=Fedora_17_x86_64 ID_FS_LABEL_ENC=Fedora\x2017\x20x86_64 ID_FS_TYPE=iso9660 ID_PART_TABLE_TYPE=dos [1] https://fedorahosted.org/libosinfo/ticket/1 [kzak@redhat.com: - add blkid_ltrim_whitespace() and use it together with blkid_rtrim_whitespace() to trim white spaces - enlarge blkid values to 128 bytes - add generic blkid_probe_set_id_label() function - always terminate all _ID with \0 - don't export the _IDs to blkid cache] Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: remove optimization from verify( funrtionKarel Zak2013-02-011-65/+11Star
| | | | | | | | | | | | | | | | Now libblkid (the cache based part) tries to probe for the cached filesystem firstly. This optimization is broken, because: * new another superblock could be on the device and the original is already obsolete * we still need to probe for partitions and raids * the code was too fragile The patch also suggests lsblk --fs in blkid.8 for end users. lsblk read information from used db. Reported-by: Andreas Hofmeister <andi@collax.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: re-read PART{UUID,LABEL} for successfully verified cached devicesKarel Zak2012-12-041-5/+15
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: cleanup arguments checksKarel Zak2012-12-041-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: remove obsolete tags from cacheKarel Zak2012-11-141-0/+20
| | | | | | | | | | | | | | | | | The libblkid cache tags are not removed if a new version of the tags is empty (e.g. label 'foo' -> ''). # mkfs.ext4 -L test_label /dev/sda15 # blkid /dev/sda15 /dev/sda15: LABEL="test_label" # tune2fs -L '' /dev/sda15 # blkid /dev/sda15 /dev/sda15: LABEL="test_label" ^^^^^^^^^^ Reported-by: Mike Fleetwood <mike.fleetwood@googlemail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: use O_CLOEXECKarel Zak2012-09-041-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: add support for PARTUUID= and PARTLABEL=Karel Zak2012-04-191-1/+13
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: use %m in format string instead of %s and strerror(errno)Petr Uzel2011-09-271-4/+4
| | | | Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* build-sys: use top-level directory for libblkid rather than shlibs/blkidKarel Zak2011-06-091-0/+231
Signed-off-by: Karel Zak <kzak@redhat.com>