rendered paste bodyFrom 7f4a88f5e467a22cb672de7d05a84f9cd184da61 Mon Sep 17 00:00:00 2001
From: Thomas Kunze <thommycheck@gmx.de>
Date: Mon, 9 Feb 2009 22:00:03 +0100
Subject: [PATCH] fstype: add forgotten files
---
fstype/fstype.h.orig | 24 +++++++++++++
fstype/gfs2_fs.h | 56 +++++++++++++++++++++++++++++++
fstype/nilfs_fs.h | 64 +++++++++++++++++++++++++++++++++++
fstype/ocfs2_fs.h | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++
fstype/reiser4_fs.h | 31 +++++++++++++++++
fstype/squashfs_fs.h | 48 ++++++++++++++++++++++++++
6 files changed, 313 insertions(+), 0 deletions(-)
create mode 100644 fstype/fstype.h.orig
create mode 100644 fstype/gfs2_fs.h
create mode 100644 fstype/nilfs_fs.h
create mode 100644 fstype/ocfs2_fs.h
create mode 100644 fstype/reiser4_fs.h
create mode 100644 fstype/squashfs_fs.h
diff --git a/fstype/fstype.h.orig b/fstype/fstype.h.orig
new file mode 100644
index 0000000..aa1c536
--- /dev/null
+++ b/fstype/fstype.h.orig
@@ -0,0 +1,24 @@
+/*
+ * by rmk
+ *
+ * Detect filesystem type (on stdin) and output strings for two
+ * environment variables:
+ * FSTYPE - filesystem type
+ * FSSIZE - filesystem size (if known)
+ *
+ * We currently detect (in order):
+ * gzip, cramfs, romfs, xfs, minix, ext3, ext2, reiserfs, jfs
+ *
+ * MINIX, ext3 and Reiserfs bits are currently untested.
+ */
+
+#ifndef FSTYPE_H
+#define FSTYPE_H
+
+#define _XOPEN_SOURCE 500
+#include <unistd.h>
+
+int identify_fs(int fd, const char **fstype,
+ unsigned long long *bytes, off_t offset);
+
+#endif
diff --git a/fstype/gfs2_fs.h b/fstype/gfs2_fs.h
new file mode 100644
index 0000000..028e0c9
--- /dev/null
+++ b/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 */
diff --git a/fstype/nilfs_fs.h b/fstype/nilfs_fs.h
new file mode 100644
index 0000000..0845edf
--- /dev/null
+++ b/fstype/nilfs_fs.h
@@ -0,0 +1,64 @@
+#ifndef __NILFS_FS_H
+#define __NILFS_FS_H
+
+#define NILFS_SUPER_MAGIC 0x3434 /* NILFS filesystem magic number */
+
+/*
+ * struct nilfs_super_block - structure of super block on disk
+ */
+struct nilfs_super_block {
+ __le32 s_rev_level; /* Revision level */
+ __le16 s_minor_rev_level; /* minor revision level */
+ __le16 s_magic; /* Magic signature */
+
+ __le16 s_bytes; /* Bytes count of CRC calculation
+ for this structure. s_reserved
+ is excluded. */
+ __le16 s_flags; /* flags */
+ __le32 s_crc_seed; /* Seed value of CRC calculation */
+ __le32 s_sum; /* Check sum of super block */
+
+ __le32 s_log_block_size; /* Block size represented as follows
+ blocksize = 1 << (s_log_block_size + 10) */
+ __le64 s_nsegments; /* Number of segments in filesystem */
+ __le64 s_dev_size; /* block device size in bytes */
+ __le64 s_first_data_block; /* 1st seg disk block number */
+ __le32 s_blocks_per_segment; /* number of blocks per full segment */
+ __le32 s_r_segments_percentage;/* Reserved segments percentage */ /* or __le16 */
+
+ __le64 s_last_cno; /* Last checkpoint number */
+ __le64 s_last_pseg; /* disk block addr pseg written last */
+ __le64 s_last_seq; /* seq. number of seg written last */
+ __le64 s_free_blocks_count; /* Free blocks count */
+
+ __le64 s_ctime; /* Creation time (execution time of newfs) */
+ __le64 s_mtime; /* Mount time */
+ __le64 s_wtime; /* Write time */
+ __le16 s_mnt_count; /* Mount count */
+ __le16 s_max_mnt_count; /* Maximal mount count */
+ __le16 s_state; /* File system state */
+ __le16 s_errors; /* Behaviour when detecting errors */
+ __le64 s_lastcheck; /* time of last check */
+
+ __le32 s_checkinterval; /* max. time between checks */
+ __le32 s_creator_os; /* OS */
+ __le16 s_def_resuid; /* Default uid for reserved blocks */
+ __le16 s_def_resgid; /* Default gid for reserved blocks */
+ __le32 s_first_ino; /* First non-reserved inode */ /* or __le16 */
+
+ __le16 s_inode_size; /* Size of an inode */
+ __le16 s_dat_entry_size; /* Size of a dat entry */
+ __le16 s_checkpoint_size; /* Size of a checkpoint */
+ __le16 s_segment_usage_size; /* Size of a segment usage */
+
+ __u8 s_uuid[16]; /* 128-bit uuid for volume */
+ char s_volume_name[16]; /* volume name */
+ char s_last_mounted[64]; /* directory where last mounted */
+
+ __le32 s_c_interval; /* Commit interval of segment */
+ __le32 s_c_block_max; /* Threshold of data amount for
+ the segment construction */
+ __u32 s_reserved[192]; /* padding to the end of the block */
+};
+
+#endif /* __NILFS_FS_H */
diff --git a/fstype/ocfs2_fs.h b/fstype/ocfs2_fs.h
new file mode 100644
index 0000000..b71cb61
--- /dev/null
+++ b/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 */
diff --git a/fstype/reiser4_fs.h b/fstype/reiser4_fs.h
new file mode 100644
index 0000000..fb2fa12
--- /dev/null
+++ b/fstype/reiser4_fs.h
@@ -0,0 +1,31 @@
+#ifndef __REISER4_FS_H
+#define __REISER4_FS_H
+
+#define SS_MAGIC_SIZE 16
+
+/* reiser4 filesystem structure
+ *
+ * Master super block structure. It is the same for all reiser4 filesystems,
+ * so, we can declare it here. It contains common for all format fields like
+ * block size etc.
+ */
+struct reiser4_master_sb {
+ /* Master super block magic. */
+ char ms_magic[SS_MAGIC_SIZE];
+
+ /* Disk format in use. */
+ __u16 ms_format;
+
+ /* Filesyetem block size in use. */
+ __u16 ms_blksize;
+
+ /* Filesyetm uuid in use. */
+ char ms_uuid[SS_MAGIC_SIZE];
+
+ /* Filesystem label in use. */
+ char ms_label[SS_MAGIC_SIZE];
+} __attribute__ ((packed));
+
+#define REISER4_SUPER_MAGIC_STRING "ReIsEr4"
+
+#endif /* __REISER4_FS_H */
diff --git a/fstype/squashfs_fs.h b/fstype/squashfs_fs.h
new file mode 100644
index 0000000..c18365d
--- /dev/null
+++ b/fstype/squashfs_fs.h
@@ -0,0 +1,48 @@
+#ifndef __SQUASHFS_FS_H
+#define __SQUASHFS_FS_H
+
+/*
+ * Squashfs
+ */
+
+#define SQUASHFS_MAGIC 0x73717368
+#define SQUASHFS_MAGIC_SWAP 0x68737173
+
+/*
+ * Squashfs + LZMA
+ */
+
+#define SQUASHFS_MAGIC_LZMA 0x71736873
+#define SQUASHFS_MAGIC_LZMA_SWAP 0x73687371
+
+/* definitions for structures on disk */
+struct squashfs_super_block {
+ unsigned int s_magic;
+ unsigned int inodes;
+ unsigned int bytes_used_2;
+ unsigned int uid_start_2;
+ unsigned int guid_start_2;
+ unsigned int inode_table_start_2;
+ unsigned int directory_table_start_2;
+ unsigned int s_major:16;
+ unsigned int s_minor:16;
+ unsigned int block_size_1:16;
+ unsigned int block_log:16;
+ unsigned int flags:8;
+ unsigned int no_uids:8;
+ unsigned int no_guids:8;
+ unsigned int mkfs_time /* time of filesystem creation */;
+ long long root_inode;
+ unsigned int block_size;
+ unsigned int fragments;
+ unsigned int fragment_table_start_2;
+ long long bytes_used;
+ long long uid_start;
+ long long guid_start;
+ long long inode_table_start;
+ long long directory_table_start;
+ long long fragment_table_start;
+ long long lookup_table_start;
+} __attribute__ ((packed));
+
+#endif /* __SQUASHFS_FS_H */
--
1.5.6.5