mirror of https://github.com/vitalif/e2fsprogs
libblkid: Strengthen the JFS probe routine
Check to make sure a JFS filesystem is really correct by checking the relationship between the following fields in the JFS superblock: s_bsize, s_l2bsize, s_pbsize, s_l2pbsize, and s_l2bfactor. Thanks to Lesh Bogdanow for this suggestion. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>bitmap-optimize
parent
78d89cda68
commit
b41fb00225
|
@ -780,6 +780,16 @@ static int probe_jfs(struct blkid_probe *probe,
|
|||
|
||||
js = (struct jfs_super_block *)buf;
|
||||
|
||||
if (blkid_le32(js->js_bsize) != (1 << blkid_le16(js->js_l2bsize)))
|
||||
return 1;
|
||||
|
||||
if (blkid_le32(js->js_pbsize) != (1 << blkid_le16(js->js_l2pbsize)))
|
||||
return 1;
|
||||
|
||||
if ((blkid_le16(js->js_l2bsize) - blkid_le16(js->js_l2pbsize)) !=
|
||||
blkid_le16(js->js_l2bfactor))
|
||||
return 1;
|
||||
|
||||
if (strlen((char *) js->js_label))
|
||||
label = (char *) js->js_label;
|
||||
blkid_set_tag(probe->dev, "LABEL", label, sizeof(js->js_label));
|
||||
|
|
|
@ -181,10 +181,13 @@ struct jfs_super_block {
|
|||
unsigned char js_magic[4];
|
||||
__u32 js_version;
|
||||
__u64 js_size;
|
||||
__u32 js_bsize;
|
||||
__u32 js_dummy1;
|
||||
__u32 js_pbsize;
|
||||
__u32 js_dummy2[27];
|
||||
__u32 js_bsize; /* 4: aggregate block size in bytes */
|
||||
__u16 js_l2bsize; /* 2: log2 of s_bsize */
|
||||
__u16 js_l2bfactor; /* 2: log2(s_bsize/hardware block size) */
|
||||
__u32 js_pbsize; /* 4: hardware/LVM block size in bytes */
|
||||
__u16 js_l2pbsize; /* 2: log2 of s_pbsize */
|
||||
__u16 js_pad; /* 2: padding necessary for alignment */
|
||||
__u32 js_dummy2[26];
|
||||
unsigned char js_uuid[16];
|
||||
unsigned char js_label[16];
|
||||
unsigned char js_loguuid[16];
|
||||
|
|
Loading…
Reference in New Issue