]> err.no Git - util-linux/commitdiff
blkid: add jfs
authorKarel Zak <kzak@redhat.com>
Thu, 18 Sep 2008 10:08:40 +0000 (12:08 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 11 Feb 2009 22:21:45 +0000 (23:21 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libs/blkid/src/probe.c
libs/blkid/src/probers/Makefile.am
libs/blkid/src/probers/jfs.c [new file with mode: 0644]
libs/blkid/src/probers/probers.h

index c8b2947474a1b0692132bce2b28d372a8bde74cb..b76eabae05e5ae1866400926c267cc518428a22a 100644 (file)
@@ -53,6 +53,7 @@ static const struct blkid_idinfo *idinfos[] =
        &ext4_idinfo,
        &ext3_idinfo,
        &ext2_idinfo,
+       &jfs_idinfo,
        &jbd_idinfo
 };
 
index 59acd9e6e70a468938727c4f12d2ec0757611670..7f8e04e4bb1d24cb3354e795966c29daec020af2 100644 (file)
@@ -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 (file)
index 0000000..d463f03
--- /dev/null
@@ -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 <kay.sievers@vrfy.org>
+ * Copyright (C) 2008 Karel Zak <kzak@redhat.com>
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <ctype.h>
+#include <stdint.h>
+
+#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 }
+       }
+};
+
index 810e2649571ee85127584c805ae395d9125d809c..ff3ea3d845ea469beba7479510f395a3982c8b15 100644 (file)
@@ -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 */