fstype: add gfs2 support

  ./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>
diff --git a/usr/kinit/fstype/fstype.c b/usr/kinit/fstype/fstype.c
index 3465676..197a259 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 @@
 	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 @@
 	{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 0000000..028e0c9
--- /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 */