Currently, the binary blkid_probe_get_{topology,partitions}() API
returns empty structs when information has not been gathered. This is
confusing for applications. It's seems better to return NULL.
Reported-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
The original e2fsprogs has BLKID_{VERSION,DATE} macros in blkid.h.
Although the macros are not updated for many years in e2fsprogs. So I
guess nobody uses it.
Signed-off-by: Karel Zak <kzak@redhat.com>
Crypto devices may sometimes have multiple additional prober matches,
however just like RAID, there's no danger of activating the wrong one
since special help is needed to activate the block device before it
can be used.
Thus modify blkid_do_safeprobe() to break out of the loop when a
crypto device is detected, as it does already for RAID.
Signed-off-by: Scott James Remnant <scott@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
* mount(8) uses private device-mapper names in mtab
* libblkid returns private device-mapper names when evaluate udev
/dev/disk-by symlinks.
* on systems where DM is fully integrated with udev the /dev/mapper/<name>
files are symlinks to /dev/dm-N. It means we need a special care to hide
private device-mapper names.
Signed-off-by: Karel Zak <kzak@redhat.com>
The libblkid keeps information about partitions in 512-byte counts.
This patch:
* convert GPT partition LBA to 512-byte sectors
* fix n+1 bug in GPT partition size, because:
"The partition is defined as all the logical blocks **inclusive**
of the StartingLBA and EndingLBA." (UEFI 2.3)
Signed-off-by: Karel Zak <kzak@redhat.com>
The current implementation uses fixed sector size (512 bytes), that's
wrong. UEFI standard requires real logical sector size -- it means
BLKSSZGET for Linux.
The size of GPT header is not static, but whole sector is allocated
for the header. In theory the HeaderSize field could be greater than
sizeof(struct gpt_header). It means we have to read whole sector with
the header, because the header crc32 checksum is counted according to
HeaderSize.
Signed-off-by: Karel Zak <kzak@redhat.com>
gcc 4.4 produces tons of
"dereferencing type-punned pointer will break strict-aliasing rules"
warnings for fdisk code where is
char buffer[BUFSIZ];
((struct disklabel *) MBRBuffer)->foo
There are two ways how fix the problem:
1/ union {
char buffer[BUFSIZ], struct disklabel label
} MBRBuffer;
2/ use allocated buffer, this way seems less invasive.
This patch implements 2/.
Old version:
$ make -C fdisk | grep -c warning
236
New version:
$ make -C fdisk | grep -c warning
0
About aliasing:
- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40665
- http://cellperformance.beyond3d.com/articles/2006/06/understanding-strict-aliasing.html
- C99
Signed-off-by: Karel Zak <kzak@redhat.com>
This patch add __attribute__((packed)) to almost all superblock and
disk label definitions. Well, in many cases this is not necessary, but
it's a cheap way how to keep the code robust...
Signed-off-by: Karel Zak <kzak@redhat.com>