This patch add support for a new tag. The tag is based on udev block
device ID (see /dev/disk/by-id). The usual use-case is to use
WWN for this purpose, for example
# mount ID=wwn-0x50026b724b09a1ff /mnt
Note that ID is not strictly defined and udevd generates various IDs
also for HW where WWN is undefined. This is reason why introduce ID=
seems better and more generic than more restrictive WWN=.
Addresses: https://github.com/karelzak/util-linux/issues/1008
Signed-off-by: Karel Zak <kzak@redhat.com>
There is quite some value (in terms of readability and user
expectations) if consistent names are used for the sections
within manual pages. This patch is one of a series to bring
about this consistency.
In the Linux man-pages project, I long ago did away with the
AUTHOR(S) section, but I realize some projects like to keep this.
But, let's make sure that the section is consistently titled
across pages. Currently we have AUTHOR (47) or AUTHORS (41).
Let's standardize on the latter (which is also what is
suggested in man-pages(7)).
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Using double quotes in .SH lines containing multiple words is unneeded,
and in any case is not consistently done in the util-linux manual pages,
where double quotes are used in only around half of the cases.
(This usage was long ago elminated in the man-pages project, with
no ill effects reported to date.)
Remove these quotes, so that .SH lines are more uniform, in preparation
for some (more easily) scripted doiscovery of consistency problems in
(and possibly global fixes to) the manual pages.
Other than stripping the double quotes, this patch makes no changes to
the content of the manual pages.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
The dax (direct access) blockdev capability is exposed via sysfs, add it
to the list of topology values to be obtained while probing.
Expose blkid_topology_get_dax() symbol that programs can link against
for querying the capability.
Reorder the idinfos array to give precedence to the sysfs over ioctl so
that the dax probe has a chance to be executed, as there is no ioctl
interface for it.
Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
This PR fixes an off by one in `strncmp(dev->bid_name, "/dev/mapper/", 11)` check. The `"/dev/mapper/"` string literal has a length of 12 and without this fix paths like `"/dev/mapperSOMETHING"` would also be accepted.
The zonefs filesystem was added to upstream linux kernel 5.6. This
patch add support for probing zonefs formatted zoned block devices so
that other file system formatting tool can detect its presence on a
device.
[kzak@redhat.com: - use standard integer types]
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/superblocks/exfat.c: In function ‘probe_exfat’:
./include/c.h:133:17: warning: comparison of distinct pointer types lacks a cast
libblkid/src/superblocks/exfat.c:129:5: note: in expansion of macro ‘min’
./include/c.h:134:8: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
Let's consolidate the code, we need to use it in libfdisk too. It
seems better to keep it generic and libblkid independent.
This patch also removes blkid_encode_alloc(), this function is overkill.
Signed-off-by: Karel Zak <kzak@redhat.com>
The logger and rtwake time function changes continue the same fixes as
previous commit - use thread safe functions. The libsmartcols condition
removal is possible because width must be greater than tb->termwidth that is
size_t and cannot be smaller than zero. And remove couple FIXME's that are
old and unlikely ever to get fixed.
Reference: 3160589d86
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Function blkid_encode_to_utf8() says that is supports BLKID_ENC_UTF16LE and
BLKID_ENC_UTF16BE encodings, but it is not truth and supports only UCS-2
(and not full UTF-16).
As all places where BLKID_ENC_UTF16LE and BLKID_ENC_UTF16BE is used expects
UTF-16 and not UCS-2, this patch changes implementation of encodings
BLKID_ENC_UTF16LE and BLKID_ENC_UTF16BE to supports full UTF-16, including
surrogate pairs and not only UCS-2.
The commit 39f5af2598 introduces
O_NONBLOCK to avoid the tray close on open(). The side effect is that
open() is successful when there is no medium.
This is usually no problem for standard tools because the next read()
will fail. Unfortunately, libblkid ignores I/O errors for (and only
for) CDROMs to support some crazy hybrid data+audio disks. The final
result is many I/O errors in system log when O_NONBLOCK is enabled.
This patch add CDROM_DRIVE_STATUS to stop probing when there is no
disk or when the tray is open.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1787973
Signed-off-by: Karel Zak <kzak@redhat.com>
* 'master' of https://github.com/dsd/util-linux:
libblkid: improve identification of ISO9660 partition
isosize: move ISO size functions into a shared header
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>
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>
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.
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>