diff options
author | Karel Zak | 2015-06-09 10:37:11 +0200 |
---|---|---|
committer | Karel Zak | 2015-06-09 10:37:11 +0200 |
commit | 00817742ce360119e079a33e12cf84118ff7c63e (patch) | |
tree | fbf68f6baf07d0a2fe6e9742df9b72dfaf78766b | |
parent | libfdisk: improve +0 partition size (diff) | |
download | kernel-qcow2-util-linux-00817742ce360119e079a33e12cf84118ff7c63e.tar.gz kernel-qcow2-util-linux-00817742ce360119e079a33e12cf84118ff7c63e.tar.xz kernel-qcow2-util-linux-00817742ce360119e079a33e12cf84118ff7c63e.zip |
libblkid: (nilfs2) check devise size
Unfortunately, nilfs2 have the same problem like many RAIDs. It uses
the end of the device to store (backup) superblock. The end of the
last partition is the same location as the end of the whole-disk. It
means that the superblock seems valid for the last partitions as well
as for whole-device.
Fortunately, nilfs2 superblock contains size of the device, so we can
distinguish between whole-disk and partition device.
Reported-by: Heinz Diehl <htd+ml@fritha.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r-- | libblkid/src/superblocks/nilfs.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libblkid/src/superblocks/nilfs.c b/libblkid/src/superblocks/nilfs.c index eccd8ae1d..14a4b74c6 100644 --- a/libblkid/src/superblocks/nilfs.c +++ b/libblkid/src/superblocks/nilfs.c @@ -77,6 +77,9 @@ static int nilfs_valid_sb(blkid_probe pr, struct nilfs_super_block *sb) if (!sb || le16_to_cpu(sb->s_magic) != NILFS_SB_MAGIC) return 0; + if (sb->s_dev_size != pr->size) + return 0; + bytes = le16_to_cpu(sb->s_bytes); crc = crc32(le32_to_cpu(sb->s_crc_seed), (unsigned char *)sb, sumoff); crc = crc32(crc, sum, 4); |