summaryrefslogtreecommitdiff
path: root/sys/ufs/ext2fs/ext2fs.h
diff options
context:
space:
mode:
authorjasoni <jasoni@cvs.openbsd.org>2000-04-26 23:24:43 +0000
committerjasoni <jasoni@cvs.openbsd.org>2000-04-26 23:24:43 +0000
commitb8e2981f69abb136dfacb9e792372f456732e939 (patch)
tree6cf55356a1d0549dd7bd890f16470ed65af9fd6f /sys/ufs/ext2fs/ext2fs.h
parentf101b0a4deb6828e7d91b49b0c42e87659eb834d (diff)
Support for ext2fs rev. 1 (from NetBSD)
Diffstat (limited to 'sys/ufs/ext2fs/ext2fs.h')
-rw-r--r--sys/ufs/ext2fs/ext2fs.h145
1 files changed, 105 insertions, 40 deletions
diff --git a/sys/ufs/ext2fs/ext2fs.h b/sys/ufs/ext2fs/ext2fs.h
index e1d7b8c4842..a5d683b137d 100644
--- a/sys/ufs/ext2fs/ext2fs.h
+++ b/sys/ufs/ext2fs/ext2fs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ext2fs.h,v 1.3 1997/06/12 21:09:30 downsj Exp $ */
+/* $OpenBSD: ext2fs.h,v 1.4 2000/04/26 23:24:39 jasoni Exp $ */
/* $NetBSD: ext2fs.h,v 1.1 1997/06/11 09:33:37 bouyer Exp $ */
/*
@@ -100,32 +100,46 @@
* Super block for an ext2fs file system.
*/
struct ext2fs {
- u_int32_t e2fs_icount; /* Inode count */
- u_int32_t e2fs_bcount; /* blocks count */
- u_int32_t e2fs_rbcount; /* reserved blocks count */
- u_int32_t e2fs_fbcount; /* free blocks count */
- u_int32_t e2fs_ficount; /* free inodes count */
+ u_int32_t e2fs_icount; /* Inode count */
+ u_int32_t e2fs_bcount; /* blocks count */
+ u_int32_t e2fs_rbcount; /* reserved blocks count */
+ u_int32_t e2fs_fbcount; /* free blocks count */
+ u_int32_t e2fs_ficount; /* free inodes count */
u_int32_t e2fs_first_dblock; /* first data block */
- u_int32_t e2fs_log_bsize; /* block size = 1024*(2^e2fs_log_bsize) */
- u_int32_t e2fs_fsize; /* fragment size */
- u_int32_t e2fs_bpg; /* blocks per group */
- u_int32_t e2fs_fpg; /* frags per group */
- u_int32_t e2fs_ipg; /* inodes per group */
- u_int32_t e2fs_mtime; /* mount time */
- u_int32_t e2fs_wtime; /* write time */
- u_int16_t e2fs_mnt_count; /* mount count */
+ u_int32_t e2fs_log_bsize; /* block size = 1024*(2^e2fs_log_bsize) */
+ u_int32_t e2fs_fsize; /* fragment size */
+ u_int32_t e2fs_bpg; /* blocks per group */
+ u_int32_t e2fs_fpg; /* frags per group */
+ u_int32_t e2fs_ipg; /* inodes per group */
+ u_int32_t e2fs_mtime; /* mount time */
+ u_int32_t e2fs_wtime; /* write time */
+ u_int16_t e2fs_mnt_count; /* mount count */
u_int16_t e2fs_max_mnt_count; /* max mount count */
- u_int16_t e2fs_magic; /* magic number */
- u_int16_t e2fs_state; /* file system state */
- u_int16_t e2fs_beh; /* behavior on errors */
- u_int16_t reserved;
- u_int32_t e2fs_lastfsck; /* time of last fsck */
- u_int32_t e2fs_fsckintv; /* max time between fscks */
- u_int32_t e2fs_creator; /* creator OS */
- u_int32_t e2fs_rev; /* revision level */
- u_int16_t e2fs_ruid; /* default uid for reserved blocks */
- u_int16_t e2fs_rgid; /* default gid for reserved blocks */
- u_int32_t reserved2[235];
+ u_int16_t e2fs_magic; /* magic number */
+ u_int16_t e2fs_state; /* file system state */
+ u_int16_t e2fs_beh; /* behavior on errors */
+ u_int16_t e2fs_minrev; /* minor revision level */
+ u_int32_t e2fs_lastfsck; /* time of last fsck */
+ u_int32_t e2fs_fsckintv; /* max time between fscks */
+ u_int32_t e2fs_creator; /* creator OS */
+ u_int32_t e2fs_rev; /* revision level */
+ u_int16_t e2fs_ruid; /* default uid for reserved blocks */
+ u_int16_t e2fs_rgid; /* default gid for reserved blocks */
+ /* EXT2_DYNAMIC_REV superblocks */
+ u_int32_t e2fs_first_ino; /* first non-reserved inode */
+ u_int16_t e2fs_inode_size; /* size of inode structure */
+ u_int16_t e2fs_block_group_nr; /* block grp number of this sblk*/
+ u_int32_t e2fs_features_compat; /* compatible feature set */
+ u_int32_t e2fs_features_incompat; /* incompatible feature set */
+ u_int32_t e2fs_features_rocompat; /* RO-compatible feature set */
+ u_int8_t e2fs_uuid[16]; /* 128-bit uuid for volume */
+ char e2fs_vname[16]; /* volume name */
+ char e2fs_fsmnt[64]; /* name mounted on */
+ u_int32_t e2fs_algo; /* For compression */
+ u_int8_t e2fs_prealloc; /* # of blocks to preallocate */
+ u_int8_t e2fs_dir_prealloc; /* # of blocks to preallocate for dir */
+ u_int16_t pad1;
+ u_int32_t reserved2[204];
};
@@ -133,18 +147,18 @@ struct ext2fs {
struct m_ext2fs {
struct ext2fs e2fs;
u_char e2fs_fsmnt[MAXMNTLEN]; /* name mounted on */
- int8_t e2fs_ronly; /* mounted read-only flag */
- int8_t e2fs_fmod; /* super block modified flag */
- int32_t e2fs_bsize; /* block size */
- int32_t e2fs_bshift; /* ``lblkno'' calc of logical blkno */
- int32_t e2fs_bmask; /* ``blkoff'' calc of blk offsets */
- int64_t e2fs_qbmask; /* ~fs_bmask - for use with quad size */
- int32_t e2fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */
- int32_t e2fs_ncg; /* number of cylinder groups */
- int32_t e2fs_ngdb; /* number of group descriptor block */
- int32_t e2fs_ipb; /* number of inodes per block */
- int32_t e2fs_itpg; /* number of inode table per group */
- struct ext2_gd *e2fs_gd; /* group descripors */
+ int8_t e2fs_ronly; /* mounted read-only flag */
+ int8_t e2fs_fmod; /* super block modified flag */
+ int32_t e2fs_bsize; /* block size */
+ int32_t e2fs_bshift; /* ``lblkno'' calc of logical blkno */
+ int32_t e2fs_bmask; /* ``blkoff'' calc of blk offsets */
+ int64_t e2fs_qbmask; /* ~fs_bmask - for use with quad size */
+ int32_t e2fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */
+ int32_t e2fs_ncg; /* number of cylinder groups */
+ int32_t e2fs_ngdb; /* number of group descriptor block */
+ int32_t e2fs_ipb; /* number of inodes per block */
+ int32_t e2fs_itpg; /* number of inode table per group */
+ struct ext2_gd *e2fs_gd; /* group descripors */
};
@@ -153,7 +167,23 @@ struct m_ext2fs {
* Filesystem identification
*/
#define E2FS_MAGIC 0xef53 /* the ext2fs magic number */
-#define E2FS_REV 0 /* revision level */
+#define E2FS_REV0 0 /* revision level */
+#define E2FS_REV1 1 /* revision level */
+
+/* compatible/imcompatible features */
+#define EXT2F_COMPAT_PREALLOC 0x0001
+
+#define EXT2F_ROCOMPAT_SPARSESUPER 0x0001
+#define EXT2F_ROCOMPAT_LARGEFILE 0x0002
+#define EXT2F_ROCOMPAT_BTREE_DIR 0x0004
+
+#define EXT2F_INCOMPAT_COMP 0x0001
+#define EXT2F_INCOMPAT_FTYPE 0x0002
+
+/* features supported in this implementation */
+#define EXT2F_COMPAT_SUPP 0x0000
+#define EXT2F_ROCOMPAT_SUPP EXT2F_ROCOMPAT_SPARSESUPER
+#define EXT2F_INCOMPAT_SUPP EXT2F_INCOMPAT_FTYPE
/*
* OS identification
@@ -166,7 +196,7 @@ struct m_ext2fs {
* Filesystem clean flags
*/
#define E2FS_ISCLEAN 0x01
-#define E2FS_ERRORS 0x02
+#define E2FS_ERRORS 0x02
/* ext2 file system block group descriptor */
@@ -179,10 +209,45 @@ struct ext2_gd {
u_int16_t ext2bgd_ndirs; /* number of directories */
u_int16_t reserved;
u_int32_t reserved2[3];
-
};
/*
+ * If the EXT2F_ROCOMPAT_SPARSESUPER flag is set, the cylinder group has a
+ * copy of the super and cylinder group descriptors blocks only if it's
+ * a power of 3, 5 or 7
+ */
+
+static __inline__ int cg_has_sb __P((int)) __attribute__((__unused__));
+static __inline int
+cg_has_sb(i)
+ int i;
+{
+ int a3 ,a5 , a7;
+
+ if (i == 0 || i == 1)
+ return 1;
+ for (a3 = 3, a5 = 5, a7 = 7;
+ a3 <= i || a5 <= i || a7 <= i;
+ a3 *= 3, a5 *= 5, a7 *= 7)
+ if (i == a3 || i == a5 || i == a7)
+ return 1;
+ return 0;
+}
+
+/*
+ * EXT2FS metadatas are stored in little-endian byte order. These macros
+ * should aide in support for big-endian machines.
+ */
+#define h2fs16(x) (x)
+#define h2fs32(x) (x)
+#define fs2h16(x) (x)
+#define fs2h32(x) (x)
+#define e2fs_sbload(old, new) bcopy((old), (new), SBSIZE);
+#define e2fs_cgload(old, new, size) bcopy((old), (new), (size));
+#define e2fs_sbsave(old, new) bcopy((old), (new), SBSIZE);
+#define e2fs_cgsave(old, new, size) bcopy((old), (new), (size));
+
+/*
* Turn file system block numbers into disk block addresses.
* This maps file system blocks to device size blocks.
*/