We need to evaluate "include::" directive relatively to project
top-level source directory rather than to the current document
location.
Signed-off-by: Karel Zak <kzak@redhat.com>
The symlinks are generated by asciidoctor and current dist_man_MANS
depends on order (nan page before man link). This solutions is useless
when execute "make -j". The real solution is to keep man pages in
separate variable and use only this variable evaluate what we need to
generate.
Signed-off-by: Karel Zak <kzak@redhat.com>
The whole thing is complicated by the fact that we have two layers
of libraries: e.g. libmount also needs libblkid. If we just tell meson
to make libmount static, this is not enough, because we also need it
to link to a static libblkid. Hence in the case of libs that link to
other libs internally, we need to create a different object with a
a different set of link_with items.
To avoid building the libraries twice, libfdisk and libmount are first
built into an internal "convenience" library, which is then linked into
the static and shared versions as appropriate.
To build: meson build && ninja -C build
To run tests: ninja -C build check
To install for packaging: DESTDIR=/var/tmp/inst ninja -C build install
To install for realz: sudo ninja -C build install
v2:
- Optional items are now based on the 'feature' feature in meson.
Built libraries which are disabled turn into disabler() objects
and also poison any executables which link to them.
What is there:
- building of the binaries and libs and the python module
- installation of binaries, libs, python module, localization files,
man pages, pkgconfig files
- running of tests
- most options to configure build equivalently to the
./configure settings
Partially implemented:
- disabling of stuff when things missing. In the C code, the defines
are all used, so that should be fine. In the build system, some
files should be skipped, but that is probably not always done properly.
Getting this right might require some testing of various build option
combinations to get the details right.
Not implemented:
- static builds of fdisk and other binaries
- things marked with XXX or FIXME
- ???
Differences:
- .la files are not created. They are useless and everybody hates them.
- Requires.private in pkgconfig files are not present in the
autogenerated .pc file. Not sure if they should be there or not. If
necessary, they can be added by hand.
- man pages and systemd units are installed by the install target. Not
sure why 'make install' doesn't do that.
- the split between / and /usr is probably wrong. But it's all pointless
anyway, so maybe we could simplify things but not implementing it at
all under meson?
The current GFS2 prober hard codes superblock constants, but these
constants are affected by GFS2 development.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1913844
Signed-off-by: Karel Zak <kzak@redhat.com>
udf superblock code already sets VOLUME_SET_ID to Volume Set Identifier
from UDF Primary Volume Descriptor.
In iso9660 similar meaning has Volume Set Identifier in ISO9660
Primary (or Supplementary Joliet) Volume Descriptor. Therefore exports it
as VOLUME_SET_ID label.
In ISO9660 Primary (and Supplementary Joliet) Volume Descriptor exists
another member Data Preparer Identifier which is currently not parsed by
iso9660 superblock code.
To have iso9660 superblock code feature complete export also Data Preparer
Identifier as DATA_PREPARER_ID label. UDF does not have equivalent of Data
Preparer Identifier.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Joliet may contain UNICODE variant of these identifiers. So prefer UNICODE
variant from Joliet over ASCII variant if Joliet one is available.
Also use same technique as for Label for reconstructing original UNICODE
variants of these identifiers.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Label in Joliet is UNICODE (UTF16BE) but can contain only 16 characters.
Label in PVD is subset of ASCII but can contain up to the 32 characters.
Non-representable characters are stored as replacement character '_'.
Label in Joliet is in most cases trimmed but UNICODE version of label in
PVD. Based on these facts try to reconstruct original label if label in
Joliet is prefix of the label in PVD (ignoring non-representable
characters).
It is possible that label in Joliet and PVD are totally different. In this
case label from Joliet as prior this change.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
ECMA 119 (ISO 9660) does not mandate that Primary Volume Descriptor needs
to be the first in Volume Descriptor Set sequence.
Move assignment of labels outside of the for-loop and correctly detects
Primary Volume Descriptor via its type (0x01) at any position in sequence.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
ECMA 119 (ISO 9660) says that if the first byte is set to (5F), the
remaining bytes of this field shall specify an identifier for a file
containing the data. As libblkid does not support reading files from the
filesystem itself it cannot parse fields which starts with 0x5F '_' char.
So for now ignore iso->publisher_id and iso->application_id values which
starts with '_' character.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
ECMA 119 (ISO 9660) does not say anything if all bytes are of these fields
are FILLER then fields are not set. It says it for iso->publisher_id and
iso->application_id.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Enhanced Read-Only File System (EROFS) has been included in Linux
kernel, many Linux distributions, buildroot and Android AOSP for
a while. Plus, nowadays, it's known that EROFS has been commercially
used by several Android vendors for their system partitions.
util-linux in busybox can also detect it recently.
This patch adds support for detecting EROFS filesystem to libblkid.
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
iso9660 superblock code already sets PUBLISHER_ID to Publisher Identifier
from ISO9660 Supplementary Volume Descriptor.
In udf field LVInfo1 from Implementation Use Volume Descriptor could
contain information such as Owner Name. More UDF generating tools
(e.g. Solaris's labelit or Linux udftools 2.3+) set this field to person
who creating the filesystem therefore its meaning is similar to ISO9660
Publisher Identifier. So for compatibility with iso9660 superblock code
export this field via PUBLISHER_ID label.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
iso9660 superblock code already sets APPLICATION_ID to Application
Identifier from ISO9660 Supplementary Volume Descriptor.
In udf similar meaning has Application Identifier from UDF Primary Volume
Descriptor. Therefore exports it as APPLICATION_ID label.
More tools for generating hybrid ISO+UDF images (e.g. genisoimage, mkisofs
or nero) set Application Identifier in UDF Primary Volume Descriptor to
just empty string. But they set Implementation Identifier in UDF Primary
Volume Descriptor to their tool name.
So if Application Identifier is empty then exports Implementation
Identifier as APPLICATION_ID label.
Please note that Application Identifier and Implementation Identifier are
stored in UDF only in ASCII, not UNICODE.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
dstring structures are in UL_ENCODE_LATIN1/UL_ENCODE_UTF16BE encodings only
when corresponding desc_charset structures are set to the OSTA Compressed
Unicode. So add missing checks.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
* pali/multisesssion:
libblkid: udf: add support for unclosed sequential Write-Once media
libblkid: udf: add support for multisession via session_offset hint
libblkid: iso9660: add support for multisession via session_offset hint
libblkid: fix blkid_probe_get_sb() to use hint offset calculation
libblkid: allow to specify offset defined by hint for blkid_probe_get_idmag()
libblkid: detect session_offset hint for optical discs
libblkid: do size correction of optical discs also by last written sector
libblkid: detect CD/DVD discs in packet writing mode
libblkid: overwrite existing hint
libblkid: export blkid_probe_reset_hints()
blkid: add --hint <name>=value
libblkid: add blkid_probe_{set,get}_hint()
Function blkid_probe_strncpy_uuid() is better suitable for setting UUID
than function blkid_probe_set_id_label().
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
To read multisession UDF disc it is required to probe VSD and AVDP from the
selected session (specified by session_offset) and then read other volume
descriptors from absolute location specified in AVDP, which is in most
cases in previous session.
So it is required for udf detector to be able to read data from any
location of disc and therefore blkid's --offset argument cannot be used to
access multisession optical disc.
Only blkid's --hint session_offset argument can be used to instruct blkid
to read multisession optical disc or disc images correctly.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
The only required change is to read disc from offset specified by
session_offset instead of beginning of disc (offset 0).
So either blkid's --offset or --hint session_offset argument would work for
correct detection of multisession ISO9660 optical disc or disc image.
Although the ISO9660 specification allows also non-2kB sector sizes,
current blkid implementation has hardcoded ISO9660 sector size to 2kB.
Therefore there is check that session_offset is multiple of 2048.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Extends struct blkid_idmag with a new member hoff which specify name of the
hint used for blkid_probe_get_hint() function to retrieve offset to kboff.
blkid_probe_get_idmag() will use supplied hint offset in bytes as a start
position from which the final offsets for magic strings are calculated.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
When offset and session_offset hint are not specified then sets
session_offset hint from CDROMMULTISESSION ioctl which returns start
position of the last session of multisession optical disc.
It is expected that session_offset hint contains position offset in bytes
where starts session of multisession optical disc which should be read.
Filesystems designed for optical discs are expected to use this value when
dealing with multisession optical disc to know where they should start
reading optical disc or image of optical disc.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Packet writing mode for CD and DVD discs is provided by kernel module
pktcdvd.ko which exports block devices /dev/pktcdvd/pktcdvd*.
These block devices do not accept CDROM_DRIVE_STATUS ioctl, therefore
current blkid code does not detect them as BLKID_FL_CDROM_DEV and also
does not do necessary size correction.
Extend detection of CD/DVD discs by additional CDROM_LAST_WRITTEN ioctl
which is accepted also by pktcdvd.ko.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
The linux kernel does not support more than 256 partitions
(DISK_MAX_PARTS). The atari and mac block devices have no such limits.
Use dos logical partition limit for atari as well (100).
Use the kernel limit for mac (256).
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
The time_t data type is a signed integer. A signed integer overflow is
not defined in C programming language.
A signed overflow occurs on 32 bit systems with 32 time_t for loop back
devices, e.g. when calling "blkid /dev/loop0". This happens because
bid_time is set to INT_MIN and the diff calculation cannot store the
result in time_t (positive int - INT_MIN > INT_MAX).
This fix changes the code to use an unsigned integer calculation. It
pretty much means that the code works as before, but well defined in C.
Checking diff to be positive protects the code against system setups
with dates before 1970 as well.
The time_t data type on modern Linux systems is 64 bit even for 32 bit
systems. Since long is 32 bit on these systems, long long is a better
data type for 64 bit output.
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
* make hints persistent and do not call blkid_probe_reset_hints() in
blkid_probe_set_device()
* export blkid_probe_reset_hints() by API to keep it completely in
user's hands
Reported-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
If the map count is set to INT_MAX then the for loop does not stop
because its check is never false.
I have not found a correct upper limit. The other partition logics have
a maximum amount (exception is atari.c).
The loop itself wouldn't be endless. If the iteration reaches block 0
then the signature will be wrong. This means that map count = INT_MAX
case would fail even if such a setup would be correct on disk.
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
Multiple occurrences of CACHE_FILE lead to memory leaks.
Also if last occurrence of CACHE_FILE is empty then cache file is not
set to NULL again.
An example /etc/blkid.conf could be:
CACHE_FILE=/tmp/cache1
CACHE_FILE=/tmp/cache2
CACHE_FILE=
I would expect that CACHE_FILE is empty but actually it is still
/tmp/cache2.
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
Add new API for additional probing hints (offsets). The idea is that
probing function can optionally use the hint to detect superblock or
partition table if on unusual place where the library does not expects (etc.)
The hints use strings as identifiers (e.g. "last-medium-session") to
make it extendable and prober specific (if necessary). The function
blkid_probe_set_hint() always add a new hint, so you can specify more
offsets with the same (hint) name.
The function blkid_probe_get_hint() is not public. For now it returns
the first hint only.
Addresses: https://github.com/karelzak/util-linux/issues/1161
Signed-off-by: Karel Zak <kzak@redhat.com>
According to coverirty a printf format string contains an unrecognized
format specifier (CWE-628). Lets avoid glibc extension "%m" that is same
as "%s", strerror(errno).
CID: 360699
CID: 360718
Signed-off-by: Sami Kerola <kerolasa@iki.fi>