aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaximilian attems <max@stro.at>2007-08-15 13:28:32 +0200
committermaximilian attems <max@stro.at>2007-08-15 21:03:19 +0200
commit2c6da00c13b5a79d78fdc3546c0312a5d99920bb (patch)
tree3c3431db9638f0934d71285354991b360fdcf6ae
parent926182c619163d1bf406bb03e70116dafbefc516 (diff)
downloadklibc-2c6da00c13b5a79d78fdc3546c0312a5d99920bb.tar.gz
fstype: add gfs2 supportklibc-1.5.3
./gfs2_mkfs -t mycluster:mygfs -p lock_dlm -j 2 /dev/mapper/nancy_vg1-gfs2 ./usr/kinit/fstype/static/fstype /dev/mapper/nancy_vg1-gfs2 FSTYPE=gfs2 FSSIZE=0 set the fssize to zero for now. Signed-off-by: maximilian attems <max@stro.at>
-rw-r--r--usr/kinit/fstype/fstype.c16
-rw-r--r--usr/kinit/fstype/gfs2_fs.h56
2 files changed, 72 insertions, 0 deletions
diff --git a/usr/kinit/fstype/fstype.c b/usr/kinit/fstype/fstype.c
index 3465676891d2f..197a2595de065 100644
--- a/usr/kinit/fstype/fstype.c
+++ b/usr/kinit/fstype/fstype.c
@@ -31,6 +31,7 @@
#include "lvm2_sb.h"
#include "iso9660_sb.h"
#include "squashfs_fs.h"
+#include "gfs2_fs.h"
/*
* Slightly cleaned up version of jfs_superblock to
@@ -297,6 +298,20 @@ static int squashfs_image(const void *buf, unsigned long long *blocks)
return 0;
}
+static int gfs2_image(const void *buf, unsigned long long *bytes)
+{
+ const struct gfs2_sb *sb =
+ (const struct gfs2_sb *)buf;
+
+ if (__be32_to_cpu(sb->sb_header.mh_magic) == GFS2_MAGIC
+ && (__be32_to_cpu(sb->sb_fs_format) == GFS2_FORMAT_FS
+ || __be32_to_cpu(sb->sb_fs_format) == GFS2_FORMAT_MULTI)) {
+ *bytes = 0; /* cpu_to_be32(sb->sb_bsize) * ?; */
+ return 1;
+ }
+ return 0;
+}
+
struct imagetype {
off_t block;
const char name[12];
@@ -328,6 +343,7 @@ static struct imagetype images[] = {
{8, "reiserfs", reiserfs_image},
{64, "reiserfs", reiserfs_image},
{64, "reiser4", reiser4_image},
+ {64, "gfs2", gfs2_image},
{32, "jfs", jfs_image},
{32, "iso9660", iso_image},
{0, "luks", luks_image},
diff --git a/usr/kinit/fstype/gfs2_fs.h b/usr/kinit/fstype/gfs2_fs.h
new file mode 100644
index 0000000000000..028e0c91ad02d
--- /dev/null
+++ b/usr/kinit/fstype/gfs2_fs.h
@@ -0,0 +1,56 @@
+#ifndef __GFS2_FS_H
+#define __GFS2_FS_H
+
+#define GFS2_MAGIC 0x01161970
+#define GFS2_FORMAT_FS 1801
+#define GFS2_FORMAT_MULTI 1900
+
+
+/*
+ * An on-disk inode number
+ */
+struct gfs2_inum {
+ __be64 no_formal_ino;
+ __be64 no_addr;
+};
+
+/*
+ * Generic metadata head structure
+ * Every inplace buffer logged in the journal must start with this.
+ */
+struct gfs2_meta_header {
+ uint32_t mh_magic;
+ uint32_t mh_type;
+ uint64_t __pad0; /* Was generation number in gfs1 */
+ uint32_t mh_format;
+ uint32_t __pad1; /* Was incarnation number in gfs1 */
+};
+
+/* Requirement: GFS2_LOCKNAME_LEN % 8 == 0
+ * Includes: the fencing zero at the end */
+#define GFS2_LOCKNAME_LEN 64
+
+/*
+ * super-block structure
+ */
+struct gfs2_sb {
+ struct gfs2_meta_header sb_header;
+
+ uint32_t sb_fs_format;
+ uint32_t sb_multihost_format;
+ uint32_t __pad0; /* Was superblock flags in gfs1 */
+
+ uint32_t sb_bsize;
+ uint32_t sb_bsize_shift;
+ uint32_t __pad1; /* Was journal segment size in gfs1 */
+
+ struct gfs2_inum sb_master_dir; /* Was jindex dinode in gfs1 */
+ struct gfs2_inum __pad2; /* Was rindex dinode in gfs1 */
+ struct gfs2_inum sb_root_dir;
+
+ char sb_lockproto[GFS2_LOCKNAME_LEN];
+ char sb_locktable[GFS2_LOCKNAME_LEN];
+ /* In gfs1, quota and license dinodes followed */
+} __attribute__ ((__packed__));
+
+#endif /* __GFS2_FS_H */