aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaximilian attems <max@stro.at>2007-08-21 11:41:00 +0200
committermaximilian attems <max@stro.at>2007-08-21 11:41:29 +0200
commit6789167791ff5364c2b85bb440b731b599774de8 (patch)
tree1b815810ec9f3536ef6ee95deed474b91fc4e6a1
parent9c5a7acda064daa7482148b5a45ee3b7ed39356c (diff)
downloadklibc-6789167791ff5364c2b85bb440b731b599774de8.tar.gz
fstype: add ocfs2 supportklibc-1.5.4
mkfs.ocfs2 /dev/mapper/nancy_vg1-ocfs2 > /dev/null mkfs.ocfs2 1.2.1 ./usr/kinit/fstype/static/fstype /dev/mapper/nancy_vg1-ocfs2 FSTYPE=ocfs2 FSSIZE=0 Signed-off-by: maximilian attems <max@stro.at>
-rw-r--r--usr/kinit/fstype/fstype.c15
-rw-r--r--usr/kinit/fstype/ocfs2_fs.h90
2 files changed, 105 insertions, 0 deletions
diff --git a/usr/kinit/fstype/fstype.c b/usr/kinit/fstype/fstype.c
index 197a2595de065..2f219e63b9afb 100644
--- a/usr/kinit/fstype/fstype.c
+++ b/usr/kinit/fstype/fstype.c
@@ -32,6 +32,7 @@
#include "iso9660_sb.h"
#include "squashfs_fs.h"
#include "gfs2_fs.h"
+#include "ocfs2_fs.h"
/*
* Slightly cleaned up version of jfs_superblock to
@@ -312,6 +313,19 @@ static int gfs2_image(const void *buf, unsigned long long *bytes)
return 0;
}
+static int ocfs2_image(const void *buf, unsigned long long *bytes)
+{
+ const struct ocfs2_dinode *sb =
+ (const struct ocfs2_dinode *)buf;
+
+ if (!memcmp(sb->i_signature, OCFS2_SUPER_BLOCK_SIGNATURE,
+ sizeof(OCFS2_SUPER_BLOCK_SIGNATURE) - 1)) {
+ *bytes = 0;
+ return 1;
+ }
+ return 0;
+}
+
struct imagetype {
off_t block;
const char name[12];
@@ -340,6 +354,7 @@ static struct imagetype images[] = {
{1, "ext3", ext3_image},
{1, "ext2", ext2_image},
{1, "minix", minix_image},
+ {2, "ocfs2", ocfs2_image},
{8, "reiserfs", reiserfs_image},
{64, "reiserfs", reiserfs_image},
{64, "reiser4", reiser4_image},
diff --git a/usr/kinit/fstype/ocfs2_fs.h b/usr/kinit/fstype/ocfs2_fs.h
new file mode 100644
index 0000000000000..b71cb617a079a
--- /dev/null
+++ b/usr/kinit/fstype/ocfs2_fs.h
@@ -0,0 +1,90 @@
+#ifndef _OCFS2_FS_H
+#define _OCFS2_FS_H
+
+/* Object signatures */
+#define OCFS2_SUPER_BLOCK_SIGNATURE "OCFSV2"
+
+#define OCFS2_VOL_UUID_LEN 16
+#define OCFS2_MAX_VOL_LABEL_LEN 64
+
+/*
+ * On disk superblock for OCFS2
+ * Note that it is contained inside an ocfs2_dinode, so all offsets
+ * are relative to the start of ocfs2_dinode.id2.
+ */
+struct ocfs2_super_block {
+/*00*/ uint16_t s_major_rev_level;
+ uint16_t s_minor_rev_level;
+ uint16_t s_mnt_count;
+ int16_t s_max_mnt_count;
+ uint16_t s_state; /* File system state */
+ uint16_t s_errors; /* Behaviour when detecting errors */
+ uint32_t s_checkinterval; /* Max time between checks */
+/*10*/ uint64_t s_lastcheck; /* Time of last check */
+ uint32_t s_creator_os; /* OS */
+ uint32_t s_feature_compat; /* Compatible feature set */
+/*20*/ uint32_t s_feature_incompat; /* Incompatible feature set */
+ uint32_t s_feature_ro_compat; /* Readonly-compatible feature set */
+ uint64_t s_root_blkno; /* Offset, in blocks, of root directory
+ dinode */
+/*30*/ uint64_t s_system_dir_blkno; /* Offset, in blocks, of system
+ directory dinode */
+ uint32_t s_blocksize_bits; /* Blocksize for this fs */
+ uint32_t s_clustersize_bits; /* Clustersize for this fs */
+/*40*/ uint16_t s_max_slots; /* Max number of simultaneous mounts
+ before tunefs required */
+ uint16_t s_reserved1;
+ uint32_t s_reserved2;
+ uint64_t s_first_cluster_group; /* Block offset of 1st cluster
+ * group header */
+/*50*/ uint8_t s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */
+/*90*/ uint8_t s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid */
+/*A0*/
+} __attribute__ ((packed));
+
+/*
+ * On disk inode for OCFS2
+ */
+struct ocfs2_dinode {
+/*00*/ uint8_t i_signature[8]; /* Signature for validation */
+ uint32_t i_generation; /* Generation number */
+ uint16_t i_suballoc_slot; /* Slot suballocator this inode
+ belongs to */
+ int16_t i_suballoc_bit; /* Bit offset in suballocator
+ block group */
+/*10*/ uint32_t i_reserved0;
+ uint32_t i_clusters; /* Cluster count */
+ uint32_t i_uid; /* Owner UID */
+ uint32_t i_gid; /* Owning GID */
+/*20*/ uint64_t i_size; /* Size in bytes */
+ uint16_t i_mode; /* File mode */
+ uint16_t i_links_count; /* Links count */
+ uint32_t i_flags; /* File flags */
+/*30*/ uint64_t i_atime; /* Access time */
+ uint64_t i_ctime; /* Creation time */
+/*40*/ uint64_t i_mtime; /* Modification time */
+ uint64_t i_dtime; /* Deletion time */
+/*50*/ uint64_t i_blkno; /* Offset on disk, in blocks */
+ uint64_t i_last_eb_blk; /* Pointer to last extent
+ block */
+/*60*/ uint32_t i_fs_generation; /* Generation per fs-instance */
+ uint32_t i_atime_nsec;
+ uint32_t i_ctime_nsec;
+ uint32_t i_mtime_nsec;
+ uint32_t i_attr;
+ uint16_t i_orphaned_slot; /* Only valid when OCFS2_ORPHANED_FL
+ was set in i_flags */
+ uint16_t i_reserved1;
+/*70*/ uint64_t i_reserved2[8];
+/*B8*/ uint64_t i_pad1;
+ uint64_t i_rdev; /* Device number */
+ uint32_t i_used; /* Bits (ie, clusters) used */
+ uint32_t i_total; /* Total bits (clusters)
+ available */
+ uint32_t ij_flags; /* Mounted, version, etc. */
+ uint32_t ij_pad;
+/*C0*/ struct ocfs2_super_block i_super;
+/* Actual on-disk size is one block */
+} __attribute__ ((packed));
+
+#endif /* _OCFS2_FS_H */