From 80f26373c4ac379507c21985ae59dff09adb7b7c Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 18 Sep 2008 12:08:40 +0200 Subject: [PATCH] blkid: add jfs Signed-off-by: Karel Zak --- libs/blkid/src/probe.c | 1 + libs/blkid/src/probers/Makefile.am | 1 + libs/blkid/src/probers/jfs.c | 79 ++++++++++++++++++++++++++++++ libs/blkid/src/probers/probers.h | 1 + 4 files changed, 82 insertions(+) create mode 100644 libs/blkid/src/probers/jfs.c diff --git a/libs/blkid/src/probe.c b/libs/blkid/src/probe.c index c8b29474..b76eabae 100644 --- a/libs/blkid/src/probe.c +++ b/libs/blkid/src/probe.c @@ -53,6 +53,7 @@ static const struct blkid_idinfo *idinfos[] = &ext4_idinfo, &ext3_idinfo, &ext2_idinfo, + &jfs_idinfo, &jbd_idinfo }; diff --git a/libs/blkid/src/probers/Makefile.am b/libs/blkid/src/probers/Makefile.am index 59acd9e6..7f8e04e4 100644 --- a/libs/blkid/src/probers/Makefile.am +++ b/libs/blkid/src/probers/Makefile.am @@ -17,6 +17,7 @@ libprobers_a_SOURCES = probers.h \ silicon_raid.c \ via_raid.c \ linux_raid.c \ + jfs.c \ ext.c all-local: $(lib_LIBRARIES) diff --git a/libs/blkid/src/probers/jfs.c b/libs/blkid/src/probers/jfs.c new file mode 100644 index 00000000..d463f03c --- /dev/null +++ b/libs/blkid/src/probers/jfs.c @@ -0,0 +1,79 @@ +/* + * Copyright (C) 1999 by Andries Brouwer + * Copyright (C) 1999, 2000, 2003 by Theodore Ts'o + * Copyright (C) 2001 by Andreas Dilger + * Copyright (C) 2004 Kay Sievers + * Copyright (C) 2008 Karel Zak + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "blkidP.h" + +struct jfs_super_block { + unsigned char js_magic[4]; + uint32_t js_version; + uint64_t js_size; + uint32_t js_bsize; /* 4: aggregate block size in bytes */ + uint16_t js_l2bsize; /* 2: log2 of s_bsize */ + uint16_t js_l2bfactor; /* 2: log2(s_bsize/hardware block size) */ + uint32_t js_pbsize; /* 4: hardware/LVM block size in bytes */ + uint16_t js_l2pbsize; /* 2: log2 of s_pbsize */ + uint16_t js_pad; /* 2: padding necessary for alignment */ + uint32_t js_dummy2[26]; + unsigned char js_uuid[16]; + unsigned char js_label[16]; + unsigned char js_loguuid[16]; +}; + +static int probe_jfs(blkid_probe pr, const struct blkid_idmag *mag) +{ + struct jfs_super_block *js; + + js = (struct jfs_super_block *) blkid_probe_get_buffer(pr, 0x8000, 0x200); + + if (le32_to_cpu(js->js_bsize) != (1 << le16_to_cpu(js->js_l2bsize))) + return 1; + + if (le32_to_cpu(js->js_pbsize) != (1 << le16_to_cpu(js->js_l2pbsize))) + return 1; + + if ((le16_to_cpu(js->js_l2bsize) - le16_to_cpu(js->js_l2pbsize)) != + le16_to_cpu(js->js_l2bfactor)) + return 1; + + if (strlen((char *) js->js_label)) + blkid_probe_set_label(pr, js->js_label, sizeof(js->js_label)); + blkid_probe_set_uuid(pr, js->js_uuid); + return 0; +} + + +const struct blkid_idinfo jfs_idinfo = +{ + .name = "jfs", + .usage = BLKID_USAGE_FILESYSTEM, + .probefunc = probe_jfs, + .magics = + { + { .magic = "JFS1", .len = 4, .kboff = 32 }, + { NULL } + } +}; + diff --git a/libs/blkid/src/probers/probers.h b/libs/blkid/src/probers/probers.h index 810e2649..ff3ea3d8 100644 --- a/libs/blkid/src/probers/probers.h +++ b/libs/blkid/src/probers/probers.h @@ -33,5 +33,6 @@ extern const struct blkid_idinfo ext4_idinfo; extern const struct blkid_idinfo ext3_idinfo; extern const struct blkid_idinfo ext2_idinfo; extern const struct blkid_idinfo jbd_idinfo; +extern const struct blkid_idinfo jfs_idinfo; #endif /* _BLKID_PROBE_H */ -- 2.39.5