Commit Graph

595 Commits

Author SHA1 Message Date
Karel Zak 24cee7157a docs: update year in libs docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-01-06 12:59:45 +01:00
Karel Zak 63f8c66af8 Merge branch 'master' of https://github.com/dsd/util-linux
* 'master' of https://github.com/dsd/util-linux:
  libblkid: improve identification of ISO9660 partition
  isosize: move ISO size functions into a shared header
2019-12-20 12:55:49 +01:00
Karel Zak 5202d809b6 Merge branch 'master' of https://github.com/pali/util-linux
* 'master' of https://github.com/pali/util-linux:
  libblkid: udf: Fix reporting UDF 2.60 revision for Mac OS X disks
2019-12-17 12:34:18 +01:00
Bjarni Ingi Gislason eb02489380 man pages: Add a comma after "e.g." and "i.e."
Add a comma (,) after "e.g." and "i.e.", or use English words
(man-pages(7) [package "manpages"]).

  Abbreviation points should be protected (usually with the
non-printing, zero width character '\&') from being interpreted as an
end of sentence, if they are not, and that independent of their current
place on the line.

  This is important when typing, as one does not usually know in
advance when the editor jumps to a new line.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2019-12-17 12:32:43 +01:00
Daniel Drake fc84bc0a46 libblkid: improve identification of ISO9660 partition
Recent changes to the iso9660 handler attempt to better handle the case
where the media has both an ordinary ISO9660 filesystem, and a partition
table with a partition entry pointing at the ISO9660 filesystem.

Rather than assuming the presence of a partition table means that there
is an ISO9660 partition, check that such a partition exists before
deciding upon which device the metadata should be presented. One real
world example of this is the grub-mkrescue image format; add a unit test
to cover that.

Secondly, even if we find an appropriate entry in the partition table,
verify that we actually have a device that corresponds to the partition
where we would then proceed to expose this metadata. In the case of a
CD/DVD (i.e. /dev/sr0) we would not normally expect to see devices
corresponding to the partitions, in that case the ISO metadata should be
presented on the whole disk (/dev/sr0).

Fixes: 7ef86a0891 ("libblkid: improve handling of ISO files with partition tables")
Link: https://bugzilla.redhat.com/show_bug.cgi?id=1783066
Signed-off-by: Daniel Drake <drake@endlessm.com>
2019-12-16 14:29:24 +08:00
Pali Rohár 92fc937ba4 libblkid: udf: Fix reporting UDF 2.60 revision for Mac OS X disks
Apple's newfs_udf, when creating UDF 2.60 disks, sets value 2.50 into
both Minimum UDF Read Revision and Minimum UDF Write Revision fields in
LVIDIU. And sets 2.60 value into UDF revision field in LVD descriptor.

So to correctly parse and set blkid ID_FS_VERSION field, use maximum value
from Minimum UDF Read Revision in LVIDIU, Minimum UDF Write Revision in
LVDIU and UDF revision in LVD descriptor.

This commit also adds a testing UDF 2.60 disk image with 4K sectors created
by Apple's newfs_udf to verify that ID_FS_VERSION is set correctly to 2.60.
2019-12-15 12:55:41 +01:00
Karel Zak 5fbb920ed4 libblkid: improve MD I/O size calculation [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-03 14:51:31 +01:00
Karel Zak 2d1e803b08 libblkid: improve vfat entries calculation [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-03 14:49:16 +01:00
Michal Suchanek 39f5af2598 libblkid: open device in nonblock mode.
When autoclose is set (kernel default but many distributions reverse the
setting) opening a CD-rom device causes the tray to close.

The function of blkid is to report the current state of the device and
not to change it. Hence it should use O_NONBLOCK when opening the
device to avoid closing a CD-rom tray.

blkid is used liberally in scripts so it can potentially interfere with
the user operating the CD-rom hardware.

[kzak@redhat.com: add O_NONBLOCK also to:
                  - wipefs
                  - blkid_new_probe_from_filename()
                  - blkid_evaluate_tag()]

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-06 09:55:49 +01:00
Elliott Mitchell 2bb3aa36b2 cleanup: Remove some spurious spaces
Sorry detail-oriented people tend to wipe these out if they notice them.
Add in automated tools and lots of excess end-of-line spaces get wiped
out.

Addresses: https://github.com/karelzak/util-linux/pull/849
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-01 13:01:43 +02:00
Daniel Drake 7ef86a0891 libblkid: improve handling of ISO files with partition tables
The ISO format specifically leaves the first 32kb blank so that it
can be used for other purposes, such as adding a partition table.
This is commonly used (e.g. by Endless and Fedora installation media) to
have partition 0 starting at sector 0 as a mountable iso9660 filesystem,
followed by more partitions (e.g. an EFI system partition).
Such layouts can be easily created by tools such as xorriso.

When plugging in a USB disk flashed with this type of ISO, blkid presents
a somewhat confusing view of the block devices. Taking the example of
a 'sda' disk with two partitions:
 1. The "iso partition"
 2. An unformatted partition

In such a setup, before the changes here, blkid will currently report the
ISO metadata attributes ID_FS_PUBLISHER_ID, ID_FS_UUID, ID_FS_LABEL, and
ID_FS_TYPE=iso9660 on both sda *and* sda1.

Since sda2 is unformatted, it won't have any ID_FS_ attributes of it's
own. And due to the following standard udev rule:

  # for partitions import parent information
  ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_*"

sda2 will actually import all of the ID_FS_ stuff from the parent device
sda.

The result at this point is that three udev devices all have the same
ID_FS_ attribute values, leading to strange results such as three
devices all racing to own the link in /dev/disk/by-uuid, so you can't
reliably do a mount-by-UUID.

Clean up this situation by detecting such partitioned ISO disks
in the superblock probing setup. If files of this kind are detected,
we now only expose the ISO metadata attributes on the specific partition
that points to the ISO data (and not the parent disk).

Signed-off-by: Daniel Drake <drake@endlessm.com>
2019-09-25 11:41:30 +08:00
Karel Zak 351de28ae6 libblkid: remove unnecessary condition [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 15:52:34 +02:00
Sami Kerola 218b1dd6f9
misc: fix typos [codespell]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-09-12 19:41:46 +01:00
Karel Zak 2771d40b88 libblkid: (xfs) fix sector size calculation
Reported-by: Anatoly Pugachev <matorola@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-03 15:10:35 +02:00
Mikulas Patocka cd129b7d2f blkid: retport block size of a filesystem
This patch extends libblkid, so that it reports filesystem block size.

When blkid returns a specific number in the BLOCK_SIZE attribute, it
guarantees that all the bios submitted by the filesystem are aligned on
this boundary.

We need this because when we want to enable dm-integrity or dm-writecache
on an existing filesystem, we need to know filesystem block size, so that
dm-integrity or dm-writecache is initialized with matching block size.

We could always use block size 512 for dm-integrity and dm-writecache, but
that would cause metadata overhead and performance degradation. On the
other hand, if we used block size 4096, it would fail if the filesystem
has smaller blocksize.

[kzak@redhat.com: - move vfat BLOCK_SIZE to probing function
		  - remove unwanted debug fprintf from ZFS prober]

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-02 12:55:53 +02:00
Karel Zak c4d6d1c54d libblkid: fix file descriptor leak in blkid_verify()
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>
2019-07-31 16:31:10 +02:00
Karel Zak 1768d77c18 libblkid: (drbd) fix comment formatting
... to avoid misinterpretation by gtk-docs.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-22 11:49:45 +02:00
Karel Zak cdb9140967 libblkid: do not interpret NTFS as MBR
# 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>
2019-07-17 12:35:45 +02:00
Karel Zak 5c8a88356d libblkid: (drbd) simplify padding
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>
2019-07-15 12:07:42 +02:00
Sami Kerola f55dd4cc2d
libblkid: fix address sanitizer issues
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>
2019-07-14 11:53:59 +01:00
Sami Kerola 9175f39075
libblkid: check number of test_blkid_save arguments correctly
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>
2019-07-14 11:53:59 +01:00
Milan Broz 73421b953e libblkid: fix detection of dm-integrity superblock version
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>
2019-06-04 13:04:09 +02:00
Sami Kerola ebd13d3fc5 libblkid: remove unneeded fields from struct bcache_super_block
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>
2019-05-27 11:58:13 +02:00
Karel Zak 16d7868fc1 libblkid: (silicon raid) improve checksum calculation [-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>
2019-05-22 17:46:14 +02:00
Karel Zak 5b3b21128c libblkid: make partitions reference counting more robust [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-15 16:28:31 +02:00
Karel Zak 488b3a69df libblkid: don't ignore blkid_probe_set_magic() errors [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-15 16:24:51 +02:00
Karel Zak 709beed937 libblkid: fix possible uninitialized value use [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-15 16:15:15 +02:00
Nikolay Borisov 99878f5dc4 libblkid: Set BLKID_BID_FL_VERIFIED in case revalidation is not needed
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>
2019-05-14 13:35:58 +02:00
Nikolay Borisov 5de879b0f2 libblkid: Don't check BLKID_PROBE_INTERVAL in blkid_verify
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>
2019-05-14 13:33:13 +02:00
Sami Kerola 110260830d docs: fix typos [codespell]
Reference: https://github.com/codespell-project/codespell
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-02-18 13:22:43 +01:00
Sami Kerola 4813a5210f various: fix 'uninitialized when used' warnings [clang]
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>
2019-02-18 13:19:24 +01:00
Karel Zak 84084dc324 libblkid: tiny code simplification
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-18 12:32:25 +01:00
Karel Zak c2435b946f libblkid: remove dependence on libuuid
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>
2019-01-22 12:33:19 +01:00
Karel Zak 969e8cbeb1 libblkid: improve whole-disk detection when read /proc/partitions
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>
2019-01-08 12:07:18 +01:00
Karel Zak 9b13b5602e libblkid: (ntfs) fix compiler warning [-Wpedantic]
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>
2019-01-02 14:47:25 +01:00
Karel Zak 2d6cad08cf Merge branch 'master' of https://github.com/kvanals/util-linux
* 'master' of https://github.com/kvanals/util-linux:
  Removed BlueStore VERSION information as it is gibberish
  Updated BlueStore expected result
  Added BlueStore test image
2019-01-02 14:20:21 +01:00
Kenneth Van Alstyne 36b0530e12 Removed BlueStore VERSION information as it is gibberish 2018-12-17 20:21:32 -06:00
Karel Zak 200769b6c0 libblkid: (bluestore) terminate magic strings array
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-17 11:05:23 +01:00
Karel Zak be2762b862 Merge branch 'master' of https://github.com/kvanals/util-linux
* 'master' of https://github.com/kvanals/util-linux:
  Finished up BlueStore support
  Added support for detecting Ceph BlueStore Block Devices
2018-12-17 10:45:33 +01:00
Tony Asleson ae62a1751f libblkid: stratis: correct byte order
Stratis superblock is little endian, ensure we retrieve the
number of sectors and initialization time correctly.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2018-12-17 10:16:11 +01:00
Kenneth Van Alstyne 4125497278 Finished up BlueStore support 2018-12-14 14:32:13 -06:00
Kenneth Van Alstyne bd301d459f Added support for detecting Ceph BlueStore Block Devices 2018-12-14 14:27:10 -06:00
Roland Kammerer ca2071c6ea libblkid: add check for DRBD9
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>
2018-11-21 10:48:08 +01:00
Andreas Henriksson b7fb72090b libblkid: Fix hidding typo
Spelling error spotted by lintian.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2018-11-21 10:48:00 +01:00
Milan Broz 1741d2ea57 libblkid: fix detection of dm-integrity superblock
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>
2018-11-12 11:32:24 +01:00
Karel Zak 4189907e6c docs: use SPDX license names
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>
2018-08-16 14:47:21 +02:00
Karel Zak f665f6e43c libblkid: use xstrncpy() for PT id [coverity scan]
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>
2018-07-25 11:25:33 +02:00
Karel Zak 47afae0caa libblkid: const qualifier cleanup
* 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>
2018-07-20 15:05:32 +02:00
Milan Broz 8bee1a220d libblkid: Check for a secondary LUKS2 header.
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>
2018-07-11 14:18:33 +02:00
Harry Mallon 4d0bc05697 libblkid: Add more APFS checking to avoid false positives 2018-07-06 18:39:26 +01:00
Harry Mallon 084f092a62 libblkid: Add very basic APFS recognition 2018-06-25 16:19:18 +01:00
Karel Zak 708a58b665 libblkid: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak 5ac0b26994 Merge branch 'master' of https://github.com/pali/util-linux
* 'master' of https://github.com/pali/util-linux:
  libblkid: udf: Fix reporting UDF 2.60 revision
2018-05-28 09:58:19 +02:00
Karel Zak 3abbd0814c libblkid: (ntfs) fix cluster size check
Addresses: https://github.com/karelzak/util-linux/issues/641
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-25 21:02:23 +02:00
Pali Rohár 4c837d4ffe libblkid: udf: Fix reporting UDF 2.60 revision
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>
2018-05-25 17:52:31 +02:00
Karel Zak 7816ee22d5 libblkid: (ntfs) enlarge cluster limit to 2MB
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>
2018-05-25 13:53:03 +02:00
Karel Zak 9a74f82271 libblkid: (zfs) fix compiler warning [-Wmaybe-uninitialized]
Reported-by: L A Walsh <lkml@tlinx.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-03 10:32:42 +02:00
Karel Zak 136f89ce5e libblkid: add BitLocker detection
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>
2018-04-24 11:47:55 +02:00
Karel Zak 2b8ac985ba libblkid: (hfs) check allocation size
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>
2018-04-12 14:21:47 +02:00
Karel Zak 04060bc3f1 Merge branch 'master' of https://github.com/pali/util-linux
* '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
2018-03-27 12:54:53 +02:00
Tony Asleson 80ec018c6a libblkid: ignore private Stratis devices
[kzak@redhat.com: - tiny coding style changes]

References: 20e1c3dc03
Signed-off-by: Tony Asleson <tasleson@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-03-09 13:34:42 +01:00
Karel Zak 0e06893f6a libblkid:(dos) make subtypes probing more robust
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>
2018-02-27 10:36:40 +01:00
Karel Zak 54b3434f68 libblkid: (mpool) checksum is LE
Reported-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-26 23:48:45 +01:00
Karel Zak 7748dd7bd0 libblkid: (mpool) don't use gtkdocs-like comment block
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-21 11:40:39 +01:00
Ruediger Meier 73afd3f8e8 misc: fix typos using codespell
Some more funny typos, please review carefully.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-02-16 11:12:52 +01:00
Karel Zak dcca7846c0 libblkid: make mpool independent on libuuid
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-13 10:30:39 +01:00
Karel Zak 63c9c05d35 misc: remove %p from debug messages
From libs where suid program may be executed by non-root user.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-01 13:18:57 +01:00
Vaclav Dolezal 046351760f libblkid: atari - reject devices with blocksize != 512
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-01-30 13:50:15 +01:00
Vaclav Dolezal 568419b1aa libblkid: atari - don't add duplicate entries
This should protect against looped XGMs.

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-01-24 14:40:21 +01:00
Vaclav Dolezal 98d87b95de libblkid: atari - test if any partition fits disk size
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-01-24 14:40:21 +01:00
Vaclav Dolezal 1ca8fba830 libblkid: atari - fix bad variable name
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-01-24 12:18:23 +01:00
Vaclav Dolezal 50c71f25ff libblkid: Support for Atari partitioning scheme
Addresses: https://github.com/karelzak/util-linux/issues/517
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-01-23 17:02:41 +01:00
Ruediger Meier af1bc027db build-sys: remove redundant EXTRA_DIST files
The sources of AC_CONFIG_FILES (*.in) are automatically
distributed.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-22 11:16:49 +01:00
Ruediger Meier 4beacf105e build-sys: avoid using prog_DEPENDENCIES
Use EXTRA_prog_DEPENDENCIES to have the benefit
of automake's automatic prog_DEPENDENCIES.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-22 11:16:49 +01:00
Ruediger Meier 0da03d4490 build-sys: remove unneeded dependencies on bla.h.in
We have already automakes's automatic dependencies like
  bla.h.in -> bla.h -> foo.o -> bar.la

An explicit direct dependency bla.h.in -> bar.la
is redundant and useless anyways.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-22 11:16:49 +01:00
Ruediger Meier a459f2ec33 build-sys: automake is able to find headers in builddir ...
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-22 11:16:49 +01:00
Ruediger Meier 1d667d8849 build-sys: remove generated headers from dist tar ball
Headers should only be listed in either *_HEADERS or
*_SOURCES, especially when we want nodist_*_HEADERS.

Since all the generated headers are made by configure we
don't even need to use BUILT_SOURCES or other tricks.

Also see automake docs 9.4.1 Built Sources Example:
  case "Build bindir.h from configure"

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-22 11:16:49 +01:00
Karel Zak a15dca2f6d include/debug: introduce __UL_INIT_DEBUG_FROM_STRING()
Let's make it possible to use debug.h without environment variables.

Suggested-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-17 13:58:29 +01:00
Karel Zak 6d00cfb233 include/debug: don't print pointer address for SUID programs
* introduce new flag __UL_DEBUG_FL_NOADDR to suppress pointer address printing

* use __UL_DEBUG_FL_NOADDR when SUID

* move ul_debugobj() to debugobj.h, and require UL_DEBUG_CURRENT_MASK
  to provide access to the current mask from ul_debugobj(). It's better
  than modify all ul_debugobj() calls and use the global mask as
  argument.

* remove never used UL_DEBUG_DEFINE_FLAG

Reported-by: halfdog <me@halfdog.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-12 11:01:26 +01:00
Tony Asleson f82b085c31 libblkid: Add support for stratis
Initial support for stratis, ref.
https://github.com/stratis-storage

[kzak@redhat.com: - remove C++ comment]

Signed-off-by: Tony Asleson <tasleson@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-11 10:08:24 +01:00
Karel Zak 10211619dc libblkid: (bcache) cleanup magic string definition
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-18 13:03:46 +01:00
Karel Zak 42dea85c5a lib/md5: use ul_/UL_ prefix
The symbols names are too generic.

Addresses: https://github.com/karelzak/util-linux/issues/548
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-12 12:06:15 +01:00
Karel Zak b480afcaba libblkid: add debug messages when ignore useless devices
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-07 12:15:48 +01:00
Sweet Tea Dorminy 6418cba457 libblkid: Add VDO superblock information into blkid
[kzak@redhat.com: - add tests/expected/blkid/low-probe-vdo
                  - enlarge the image (must be > 1024)]

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-07 12:11:32 +01:00
Pali Rohár f0ca7e80d7 libblkid: vfat: Change parsing label in special cases
* 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>
2017-11-25 12:48:18 +01:00
Karel Zak 6e08d4d9f8 Merge branch 'master' of https://github.com/pali/util-linux
* 'master' of https://github.com/pali/util-linux:
  libblkid: udf: Fix parsing UDF revision
2017-11-21 12:42:35 +01:00
Andy Grover f024c96c34 libblkid: Mark char* params to blkid_dev_set_search as const
They are not changed by the function.

Signed-off-by: Andy Grover <agrover@redhat.com>
2017-11-21 10:43:09 +01:00
Pali Rohár 3999e62a72 libblkid: udf: Fix parsing UDF revision
UDF revision is stored as decimal number in hexadecimal format.
E.g. number 0x0150 is revision 1.50, number 0x0201 is revision 2.01.

Apparently all UDF test images have number which has same representation in
decimal and hexadecimal format, so problem was not detected.

This patch adds new test image with UDF revision 1.50. Internally number is
stored as 0x0150. In decimal format it is (incorrectly) 1.80, but in
hexadecimal correct 1.50.

$ dd if=/dev/zero of=udf-hdd-mkudffs-1.3-8.img bs=1M count=10
$ mkudffs -r 0x150 -b 512 udf-hdd-mkudffs-1.3-8.img

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
2017-11-20 18:16:59 +01:00
Pali Rohár 3ea60856ee libblkid: udf: Update copyright
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
2017-11-16 19:53:59 +01:00
Pali Rohár 06d9f4763f libblkid: udf: Use UDF revision field from LVD domain id "*OSTA UDF Compliant" as a fallback value for ID_FS_VERSION when LVIDIU is missing
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
2017-11-16 18:53:52 +01:00
Karel Zak f9dc7fd135 Merge branch 'master' of https://github.com/pali/util-linux
* 'master' of https://github.com/pali/util-linux:
  libblkid: udf: Stop scanning Volume Descriptors after we found Terminating Descriptor
  libblkid: udf: Really try to read only first LVID
2017-11-16 14:18:16 +01:00
John Groves b0a89709bf libblkid: Add support for Micron mpool formatted drives
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-16 11:44:52 +01:00
Pali Rohár 4572e4070d libblkid: udf: Stop scanning Volume Descriptors after we found Terminating Descriptor
Terminating Descriptor is the last descriptor in Volume Descriptor
Sequence. After it there can be unrecorded or empty sectors which we do not
have to scan.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
2017-11-15 18:12:50 +01:00
Pali Rohár d0ecd5e984 libblkid: udf: Really try to read only first LVID
We do not want to scan whole LVID sequence.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
2017-11-15 18:05:52 +01:00
Pali Rohár 6e810fa59d libblkid: udf: Fix parsing LVID location
And add comment about Logical Volume Integrity Sequence that we do not scan it fully.
2017-11-14 10:25:02 +01:00
Pali Rohár e44eb3e6e5 libblkid: udf: Fix reading Logical Volume Integrity Descriptor Implementation Use (LVIDIU)
LVIDIU is stored at the end of Logical Volume Integrity Descriptor (LVID),
after two variable length array of partitions. And number of partitions is
stored in LVID, not in Logical Volume Descriptor (LVD).

Length of LVIDIU is also stored in LVID, so add check that LVIDIU has
enough size.

Fixes commit db31676743.
2017-11-13 21:45:34 +01:00
Karel Zak cfcbf7526a Merge branch 'udf' of https://github.com/pali/util-linux
* 'udf' of https://github.com/pali/util-linux:
  test: Add UDF hdd image with final block size 4096 created by Linux mkudffs 1.3
  libblkid: udf: Optimize and fix probing when block size > 2048 bytes
2017-11-13 12:32:03 +01:00
Karel Zak 16068d0b9e Merge branch 'master' of https://github.com/pali/util-linux
* 'master' of https://github.com/pali/util-linux:
  libblkid: vfat: Fix reading labels which starts with byte 0x05
2017-11-13 12:23:23 +01:00
Pali Rohár f5f269ece5 libblkid: udf: Optimize and fix probing when block size > 2048 bytes
Optimize probing and detecting for UDF. Do not read and try to detect VRS
(Volume Recognition Sequence) on same blocks more times. For specific VSD
(Volume Structure Descriptor) length do it only once.

Fix probing of devices which has block size larger then 2048 bytes. It is
not truth that VSD is always 2048 bytes long. Its size is minimum of the
disk block size and 2048 bytes. See ECMA-167 sections 2/8.4 and 2/9.1.
Therefore when block size is larger then 2048 bytes, VRS needs to be
scanned again.

In commit 501aeb60a4 was removed check for
empty VSD identifier because it caused that UDF image with block size of
the 4096 bytes was not detected. Reason was that VRS was improperly scanned
as VSD was 4096 bytes long, with 2048 bytes zero padding.

Now when processing of devices with block size larger then 2048 bytes is
fixed we can correctly stop scanning VRS at first invalid VSD as specified
in ECMA-167 section 2/8.3.1.
2017-11-12 21:55:21 +01:00
Karel Zak 4545ba6276 libblkid: improve FreeBSD partitions parsing
FreeBSD since version 10 uses relative offsets for nested partitions.
Based on Richard Narron changes in kernel:block/partitions/msdos.c.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-10 12:55:11 +01:00
Pali Rohár e526f50391 libblkid: vfat: Fix reading labels which starts with byte 0x05
When FAT directory entry has leading byte 0x05 it is interpreted as byte
0xE5. This is how FAT stores file name which starts with byte 0xE5 as
leading byte in 0xE5 in FAT directory entry means that file slot is empty.

Fixes: #533
2017-11-09 19:03:34 +01:00
Milan Broz 573538bfba blkid: Add support for LUKS2 and new LABEL attributes.
This patch adds support for detection of a LUKS2 superblock.

LUKS2 is new version of Linux Unified Key Setup for encrypted
block devices.

LUKS2 contains a binary header and then JSON area for metadata.
Blkid should only parse the binary part, including newly available
optional LABEL and SUBSYSTEM fields.

LABEL is similar to filesystem label. The SUBSYSTEM field is
in principle, just a second label and can be used for specific udev rules
(for example if you have some 3rd party system that activates
volumes automatically, you can mark devices using this attribute).
Both labels are optional.

The magic string and UUID location are intentionally on the same offset
as LUKS v1, so even unpatched blkid now recognizes LUKS2.

Anyway, the code should not parse other versions of the header, so we now
explicitly check for header version and support only version 1 and 2.

Signed-off-by: Milan Broz <gmazyland@gmail.com>
2017-10-23 16:31:46 +02:00
Karel Zak ee7f1e9e08 libfdisk: (sun) make math more robust [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-11 14:50:43 +02:00
Karel Zak 9f20d80079 misc: cleanup UUID_STR_LEN definitions
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 13:25:32 +02:00
Philip Prindeville b443c1779e misc: replace magic number 37 with UUID_STR_LEN
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2017-09-05 11:49:21 +02:00
Pali Rohár c748335382 libblkid: udf: Define magic constants 2017-08-20 14:50:02 +02:00
Karel Zak feeeaca967 libblkid: fix compiler warning [-Wformat-truncation=]
The MBR partition pseudo-UUID is generated from table ID and partition
partno. The final UUID size limit is 37 bytes. The table ID has to be
restricted to keep compiler happy (for MBR the table ID is 8 bytes
as string).

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-16 11:55:57 +02:00
Karel Zak 1266fcf9cf libblkid: mark UBI as RAID
UBI is volume manager rather than filesystem. Note that libblkid has
optimized RAIDs probing (don't search for another filesystems is RAID
detected). We also don't search for RAIDs on very small devices, but
this optimization is ignored for UBI char devices (size=1byte).

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-03 15:31:54 +02:00
Rafał Miłecki a6b1ec864a libblkid: add support for UBI superblock
UBI is a volume management system that can be used on a raw flash
partition for providing multiple logical volumes. Detecting UBI
superblock may be useful for tools wanting to simplify or automate
attaching UBI.

Please note it's not directly related to the ubifs support which is just
a filesystem working on top of UBI volume.

In other words: UBI can be used on MTD partition (e.g. /dev/mtdblock0)
while ubifs can be used on UBI volume (e.g. /dev/ubi0_0).

This patch adds simple code reading UBI version and unique number and
setting it in the blkid_probe.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
2017-08-03 14:11:21 +02:00
Mark Tinguely aaf133265f libblkid: add HPE extended-XFS to known filesystems
The HPE (formerly SGI) enhanced XFS has changed its magic
version number to allow the use of EXFS and community XFS
filesystems at the same time.

This patch adds HPE EXFS support to libblkid.

[kzak@redhat.com: - removed EXFS log prober, it uses the same magic
                    string as XFS log]

Signed-off-by: Mark Tinguely <mark.tinguely@hpe.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-20 10:12:21 +02:00
Milan Broz 78f9ecb990 blkid: Add dm-integrity superblock signature
Since the kernel version 4.12 there is a new dm-integrity module
that provides an emulated per-sector metadata format for storing data integrity.

This patch adds dm-integrity magic signature to blkid to recognize such
a block device.

Signed-off-by: Milan Broz <gmazyland@gmail.com>
2017-07-18 14:43:21 +02:00
Ruediger Meier 21be08ac8c build-sys: don't use non-existing UUID_LIBS
We've added UUID_LIBS in f77a4d1087 but I don't see what it
was good for.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-07-18 11:06:53 +02:00
Karel Zak 884659b32a libblkid: don't use CDROM_GET_CAPABILITY ioctl for DM devices
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>
2017-07-12 14:35:53 +02:00
Karel Zak 10bba184bb Merge branch 'master' of https://github.com/pali/util-linux
* 'master' of https://github.com/pali/util-linux:
  tests: update UDF test, add ID_FS_VERSION
  libblkid: udf: Add support for ID_FS_VERSION
  libblkid: udf: Fix types
  libblkid: udf: De-duplicate code for dstring decoding
2017-07-11 14:31:23 +02:00
Karel Zak 4360f56cf6 libblkid: don't check for size on UBI (char dev)
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-11 12:17:40 +02:00
Pali Rohár db31676743 libblkid: udf: Add support for ID_FS_VERSION
Set ID_FS_VERSION to Minimum UDF Read Revision.
2017-07-05 13:50:52 +02:00
Pali Rohár 35b1ec3c4b libblkid: udf: Fix types 2017-07-05 13:46:12 +02:00
Pali Rohár 7afa432a07 libblkid: udf: De-duplicate code for dstring decoding 2017-07-05 12:15:00 +02:00
Karel Zak d2b0c6587d libblkid: allow to hide already detected signatures
The libblkid probing functions returns the first successful result of
the filesystem/RAID/PT. Unfortunately, some signatures is possible to
detect by more ways or device may contains more copies (e.g. GPT).

This is no problem when we wipe signatures from the device. In this
case we zeroize on-device signature and re-scan for the signature (by
blkid_probe_step_back()).

The problem is if we want to read all permutations without the device
modification (for example wipefs(8) dry run).

This patch add blkid_probe_hide_range(). The function remove (zeroize)
specified signature from in-memory cached buffers. If the buffer is
later re-used by probing functions then the signature is invisible and
we can try detect another variant of the magic string.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-28 10:28:41 +02:00
Karel Zak 08029093b0 libblkid: remove dead code and blkid_probe_new_value()
The function blkid_probe_new_value() is unnecessary.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-27 11:26:41 +02:00
Pali Rohár f0fcfdc30f libblkid: udf: Fix parsing of UDF dstring structures
First byte of dstring is OSTA Compression ID and the last byte is length of
recorded bytes (including first byte). Last byte is not a part of recorded
characters, therefore it should not be treated as data to decode.
2017-06-22 10:38:08 +02:00
Pali Rohár 501aeb60a4 libblkid: udf: Fix detection of UDF images with block size 1024 and 4096
When detecting block size of UDF filesystem, try to use also block size
512, 1024, 2048 and 4096. This would allow blkid to detect UDF filesystem
in image file created from 4K hard disk (which should have UDF block size
4096).

Before this patch only UDF images with block size of 512 and 2048 were
detected as only block size from blkid_probe_get_sectorsize() and 2048 were
used (blkid_probe_get_sectorsize() returns for disk images 512).
2017-06-14 23:15:14 +02:00
Sami Kerola f4d3783867 misc: remove stray semicolons
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-14 12:21:29 +02:00
Sami Kerola 1b5042636f misc: fix reassigned values before old ones has been used [cppcheck]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-14 12:19:20 +02:00
Ruediger Meier 11e904f02c libblkid: fix gcc-7 warning -Wint-in-bool-context
BLOCK_SIZE(sb) should be unsigned so that the left shift is defined.

This was the warning:

../libblkid/src/superblocks/exfat.c: In function 'probe_exfat':
../libblkid/src/superblocks/exfat.c:40:42: warning: '<<' in boolean context, did you mean '<' ? [-Wint-in-bool-context]
 #define CLUSTER_SIZE(sb) (BLOCK_SIZE(sb) << (sb)->bpc_bits)
                          ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
../libblkid/src/superblocks/exfat.c:122:14: note: in expansion of macro 'CLUSTER_SIZE'
  if (!sb || !CLUSTER_SIZE(sb))
              ^~~~~~~~~~~~

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-14 11:48:22 +02:00
Ruediger Meier f64ddc95f3 misc: fix gcc-7 sprintf warnings -Wformat-overflow
../login-utils/last.c: In function ‘main’:
../login-utils/last.c:624:23: warning: ‘%s’ directive writing up to 31 bytes into a region of size 27 [-Wformat-overflow=]
   sprintf(path, "/dev/%s", ut->ut_line);
                       ^~   ~~
../login-utils/last.c:624:3: note: ‘sprintf’ output between 6 and 37 bytes into a destination of size 32
   sprintf(path, "/dev/%s", ut->ut_line);

../libblkid/src/devname.c: In function 'probe_one':
../libblkid/src/devname.c:166:29: warning: '%s' directive writing up to 255 bytes into a region of size 245 [-Wformat-overflow=]
   sprintf(path, "/sys/block/%s/slaves", de->d_name);
                             ^~
../libblkid/src/devname.c:166:3: note: 'sprintf' output between 19 and 274 bytes into a destination of size 256
   sprintf(path, "/sys/block/%s/slaves", de->d_name);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-14 11:48:22 +02:00
Karel Zak bff78d701d libblkid: (vfat) add more debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-09 11:11:38 +02:00
Ruediger Meier c0d7b11a3f build-sys: fix library order when linking
We got some errors on Alpine Linux where $LTLIBINTL is non-empty:

./.libs/libcommon.a(libcommon_la-blkdev.o): In function `open_blkdev_or_file':
lib/blkdev.c:282: undefined reference to `libintl_gettext
collect2: error: ld returned 1 exit status

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-01 03:16:48 +02:00
Karel Zak ae4e2abcb1 libblkid: (docs) add missing 'since' tags
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-23 14:27:36 +02:00
Pali Rohár d8ba647d0d libblkid: udf: Change algorithm for reporting UUID
Ensure that reported UUID always contains only lowercase hexadecimal digits
and is always 16 characters length, padded with zero digits.

Volume Set Identifier is converted to UTF-8 before generating UUID from it.
As it could potentially contain any Unicode character. So correctly handle
both 8bit and 16bit OSTA Compressed Unicode encodings.

Disks which have only lowercase hexadecimal digits in Volume Set Identifier
would have same UUID as before this patch.
2017-05-17 20:36:40 +02:00
Pali Rohár 22acc2681d libblkid: udf: Correctly handle UDF strings encoded in 8bit OSTA Compressed Unicode
String encoded in 8bit OSTA Compressed Unicode contains one Unicode
codepoint per 8bits. Maximal Unicode codepoint is U+FF. Which effectively
means that it is equivalent to Latin1 encoding.

Before this patch libblkid copied raw 8bit OSTA Compressed Unicode from
disk and treated it as UTF-8. It worked fine just for UTF-8 invariants,
other characters were incorrectly encoded. This patch fixes this problem.

Note that processing UUID is not fixed in this patch.
2017-05-16 23:52:05 +02:00
Pali Rohár 98bc12ab48 libblkid: Add support for Latin1 encoding in blkid_encode_to_utf8() 2017-05-16 23:51:50 +02:00
Karel Zak ce59d8bfa5 Merge branch 'master' of https://github.com/pali/util-linux
* 'master' of https://github.com/pali/util-linux:
  tests: Add UDF CD-ROM hybrid image (ISO+Joliet+UDF) created by Nero 6
  tests: Fix test output for low-probe-udf to contain UDF data
  Revert "libblkid: Probe UDF volumes for ISO9660 info as well"
2017-05-11 10:59:14 +02:00
Pali Rohár ccfb5b0a1d Revert "libblkid: Probe UDF volumes for ISO9660 info as well"
This reverts commit 8053b51c76.

Reporting meaningless ID_FS_LABEL=UDF_Volume written in that commit was
caused by reading wrong value for UDF label and it was fixed in commit
2f2730bc77.

So after this revert blkid reports for UDF filesystems label of UDF
filesystem and not label of ISO (if present) like other systems. In most
cases UDF and ISO labels are same (sometimes just one is upper case).

Commit 8053b51c76 just fixed result, not
reason why blkid reported different UDF Label as Windows. Real reason was
fixed in 2f2730bc77.
2017-05-05 18:38:15 +02:00
Sami Kerola 635d9aa5db
libblkid: add blkid_partitions_get_name()
This new function can be use to enquiry what partition names libblkid is
aware of.  First use of this information will be in partx(8) to make bash
completion to work without a magic list.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-02 23:22:04 +01:00
Pali Rohár 49d84dbedc libblkid: udf: For better readibility use one snprintf call instead multiple in loop 2017-05-01 09:28:22 +02:00
Ruediger Meier c8df4b17d4 misc: fix some printf format strings
Fix compiler warnings seen on Linux/i586 and OSX/travis.

  #type            #format   #cast
   unsigned long    %lu       -
   uint64_t         PRIu64    -
   fdisk_sector_t   %ju       (uintmax_t)

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-04-10 15:40:58 +02:00
Karel Zak 044d6e5565 libblkid: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-24 11:46:33 +01:00
Tobias Stoeckmann 62ab1ebb12 libblkid: prevent OOB access while probing HFS+
It is possible to perform out of boundary read accesses due to
insufficient boundary checks in probe_hfsplus.

The first issue occurs if the leaf count in a B-node is too
small. The second happens while parsing a unicode description which
is longer than 255 UTF-8 characters. The length is stored in a 16 bit
integer, but the array in the struct is limited to 255 * 2, which is
in sync with Apple's Open Source HFS+ implementation (HFSUniStr255).

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2017-03-23 15:46:36 +01:00
Sami Kerola 57f1539592 libblkid: ensure uninitialized variable is not used [clang]
Following condition can be true if minix file system is corrupt, and versio
number is found to be greater than 3.  It is fair to say described scenario
is unlikely.

libblkid/src/superblocks/minix.c:107:13: warning: variable 'zone_size' is
used uninitialized whenever
      'if' condition is false [-Wsometimes-uninitialized]
        } else if (version == 3) {
                   ^~~~~~~~~~~~
libblkid/src/superblocks/minix.c:121:6: note: uninitialized use occurs here
        if (zone_size != 0 || ninodes == 0 || ninodes == UINT32_MAX)
            ^~~~~~~~~

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-03-13 14:48:12 +01:00
Sami Kerola c88f7aee8f libblkid: avoid overflow when initializing array
libblkid/src/superblocks/drbdmanage.c:38:42: warning: too long
initializer-string for array of char(no space for nul char)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-03-13 14:48:10 +01:00
Sami Kerola c308e2050f misc: stop mixing declarations and code
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-03-13 14:48:04 +01:00
Tobias Stoeckmann 55a5fbbc33 libblkid: Fix blkid.conf parsing
The SEND_UEVENT=yes|no line is not properly parsed, because the offset
jumps one byte too far behind the equal sign. Therefore, every
configuration that contains the line "SEND_UEVENT=yes" still does not
send an uevent.

The fix is simple: adjust the offset to be "12" instead of "13".
2017-03-13 12:46:47 +01:00
Karel Zak bf3e7a40ab libblkid: remove unnecessary 'static' keyword
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-20 13:08:30 +01:00
Sami Kerola c5e3ebcedc libblkid: declare across file variables in blkidP.h [smatch scan]
Else these variables will cause following warning:

libblkid/src/superblocks/superblocks.c:165:29: warning: symbol
'superblocks_drv' was not declared.  Should it be static?

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 13:00:58 +01:00
Sami Kerola 2ba641e5f3 misc: add static keyword to where needed [smatch scan]
text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be
static?

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 12:58:49 +01:00
Sami Kerola 8791804065 misc: do not use plain 0 as NULL [smatch scan]
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>
2017-02-20 12:58:49 +01:00
Karel Zak e9e88bb8e9 libblkid: (gpt) fix force flag
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-15 11:30:58 +01:00
Karel Zak 74493d48d8 libblkid: fix BLKID_PARTS_FORCE_GPT usage
Now wipefs always inform about MBR as about PMBR. That's bug.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-14 14:57:24 +01:00
Alden Tondettar a157a23f6d libblkid: Fix out of bounds reads in BEFS handling
The BEFS prober is quite trusting of whatever data is fed to it and
performs almost no bounds checks. There don't seem to be any
out-of-bounds writes as far as I can tell, but there are many ways a
corrupted image could cause libblkid to read OOB and segfault, or hang
in an infinite loop.

This fix makes a few sanity-checks of the superblock, add bounds checks
wherever they seem needed, and crudely checks for cycles in the B+ tree.

Signed-off-by: Alden Tondettar <alden.tondettar@gmail.com>
2017-01-25 11:43:06 +01:00