From 66a0fbdc4ced024757027410fa4e9d52e94b32d0 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 19 Jan 2010 01:12:06 +0100 Subject: [PATCH] libblkid: set minimal size for jfs, reiser, swap and zfs .. and don't probe for swap or ext. journal on tiny disks. Signed-off-by: Karel Zak --- shlibs/blkid/src/blkidP.h | 1 + shlibs/blkid/src/superblocks/jfs.c | 1 + shlibs/blkid/src/superblocks/reiserfs.c | 2 ++ shlibs/blkid/src/superblocks/superblocks.c | 9 +++++++-- shlibs/blkid/src/superblocks/swap.c | 2 ++ shlibs/blkid/src/superblocks/zfs.c | 1 + 6 files changed, 14 insertions(+), 2 deletions(-) diff --git a/shlibs/blkid/src/blkidP.h b/shlibs/blkid/src/blkidP.h index 4a3ae200..55850349 100644 --- a/shlibs/blkid/src/blkidP.h +++ b/shlibs/blkid/src/blkidP.h @@ -155,6 +155,7 @@ struct blkid_idinfo const char *name; /* fs, raid or partition table name */ int usage; /* BLKID_USAGE_* flag */ int flags; /* BLKID_IDINFO_* flags */ + int minsz; /* minimal device size */ /* probe function */ int (*probefunc)(blkid_probe pr, const struct blkid_idmag *mag); diff --git a/shlibs/blkid/src/superblocks/jfs.c b/shlibs/blkid/src/superblocks/jfs.c index e6e44505..9a49c674 100644 --- a/shlibs/blkid/src/superblocks/jfs.c +++ b/shlibs/blkid/src/superblocks/jfs.c @@ -61,6 +61,7 @@ const struct blkid_idinfo jfs_idinfo = .name = "jfs", .usage = BLKID_USAGE_FILESYSTEM, .probefunc = probe_jfs, + .minsz = 16 * 1024 * 1024, .magics = { { .magic = "JFS1", .len = 4, .kboff = 32 }, diff --git a/shlibs/blkid/src/superblocks/reiserfs.c b/shlibs/blkid/src/superblocks/reiserfs.c index 4222a307..921f5237 100644 --- a/shlibs/blkid/src/superblocks/reiserfs.c +++ b/shlibs/blkid/src/superblocks/reiserfs.c @@ -98,6 +98,7 @@ const struct blkid_idinfo reiser_idinfo = .name = "reiserfs", .usage = BLKID_USAGE_FILESYSTEM, .probefunc = probe_reiser, + .minsz = 4096 * 512, /* not sure, this is minimal size of journal */ .magics = { { .magic = "ReIsErFs", .len = 8, .kboff = 8, .sboff = 0x34 }, @@ -114,6 +115,7 @@ const struct blkid_idinfo reiser4_idinfo = .name = "reiser4", .usage = BLKID_USAGE_FILESYSTEM, .probefunc = probe_reiser4, + .minsz = 4096 * 512, /* not sure, this is minimal size of journal */ .magics = { { .magic = "ReIsEr4", .len = 7, .kboff = 64 }, diff --git a/shlibs/blkid/src/superblocks/superblocks.c b/shlibs/blkid/src/superblocks/superblocks.c index dbb48562..689f31bd 100644 --- a/shlibs/blkid/src/superblocks/superblocks.c +++ b/shlibs/blkid/src/superblocks/superblocks.c @@ -331,10 +331,15 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn) continue; id = idinfos[i]; + + if (id->minsz && id->minsz > pr->size) + continue; /* the device is too small */ + mag = id->magics ? &id->magics[0] : NULL; - /* don't probe for RAIDs on floppies */ - if ((id->usage & BLKID_USAGE_RAID) && blkid_probe_is_tiny(pr)) + /* don't probe for RAIDs, swap or journal on floppies */ + if ((id->usage & (BLKID_USAGE_RAID | BLKID_USAGE_OTHER)) && + blkid_probe_is_tiny(pr)) continue; DBG(DEBUG_LOWPROBE, printf("[%d] %s:\n", i, id->name)); diff --git a/shlibs/blkid/src/superblocks/swap.c b/shlibs/blkid/src/superblocks/swap.c index 4fb4ab7a..8aaa6f31 100644 --- a/shlibs/blkid/src/superblocks/swap.c +++ b/shlibs/blkid/src/superblocks/swap.c @@ -99,6 +99,7 @@ const struct blkid_idinfo swap_idinfo = .name = "swap", .usage = BLKID_USAGE_OTHER, .probefunc = probe_swap, + .minsz = 10 * 4096, /* 10 pages */ .magics = { { "SWAP-SPACE", 10, 0, 0xff6 }, @@ -121,6 +122,7 @@ const struct blkid_idinfo swsuspend_idinfo = .name = "swsuspend", .usage = BLKID_USAGE_OTHER, .probefunc = probe_swsuspend, + .minsz = 10 * 4096, /* 10 pages */ .magics = { { "S1SUSPEND", 9, 0, 0xff6 }, diff --git a/shlibs/blkid/src/superblocks/zfs.c b/shlibs/blkid/src/superblocks/zfs.c index 2d626427..0f580262 100644 --- a/shlibs/blkid/src/superblocks/zfs.c +++ b/shlibs/blkid/src/superblocks/zfs.c @@ -54,6 +54,7 @@ const struct blkid_idinfo zfs_idinfo = .name = "zfs", .usage = BLKID_USAGE_FILESYSTEM, .probefunc = probe_zfs, + .minsz = 64 * 1024 * 1024, .magics = { { .magic = "\0\0\x02\xf5\xb0\x07\xb1\x0c", .len = 8, .kboff = 8 }, -- 2.39.5