kern/143345: extfs minor header cleanups to better match NetBSD/UFS

Pedro F. Giffuni giffunip at tutopia.com
Fri Jan 29 15:00:20 UTC 2010


>Number:         143345
>Category:       kern
>Synopsis:       extfs minor header cleanups to better match NetBSD/UFS
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 29 15:00:19 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Pedro F. Giffuni
>Release:        8.0-Release + BSD ext2fs
>Organization:
>Environment:
FreeBSD mogwai.giffuni.net 8.0-RELEASE FreeBSD 8.0-RELEASE #13: Sat Jan  9 20:39:47 UTC 2010     pedro at mogwai.giffuni.net:/usr/src/sys/i386/compile/GENERIC  i386

>Description:
Some changes in the headers for better compatibility with NetBSD:

- Move special inode numbers from ext2fs.h to ext2_dinode.h
- Re-sort ext2_dinode.h to make more consistent with the NetBSD
 (UFS derived) file.
- Minor re-sort to ext2fs.h to better match the NetBSD equivalent.
- Add the prealloc fields to the superblock struct as in NetBSD.
- Add one more compat definition as in NetBSD rev. 1.29
- Cleanup #endif comments

These changes have no effect on the fs code but are important for
porting the userland utilities (fsck and newfs) from NetBSD.
>How-To-Repeat:

>Fix:
diff -ru ext2fs.bsd/ext2_dinode.h ext2fs/ext2_dinode.h
--- ext2fs.bsd/ext2_dinode.h	2010-01-17 19:01:35.000000000 +0000
+++ ext2fs/ext2_dinode.h	2010-01-29 09:46:44.000000000 +0000
@@ -29,21 +29,19 @@
 #ifndef _FS_EXT2FS_EXT2_DINODE_H_
 #define _FS_EXT2FS_EXT2_DINODE_H_
 
-#define e2di_size_high	e2di_dacl
-
 /*
- * Inode flags
- * The current implementation uses only EXT2_IMMUTABLE and EXT2_APPEND flags
+ * Special inode numbers
+ * The root inode is the root of the file system.  Inode 0 can't be used for
+ * normal purposes and bad blocks are normally linked to inode 1, thus
+ * the root inode is 2.
+ * Inode 3 to 10 are reserved in ext2fs.
  */
-#define EXT2_SECRM		0x00000001	/* Secure deletion */
-#define EXT2_UNRM		0x00000002	/* Undelete */
-#define EXT2_COMPR		0x00000004	/* Compress file */
-#define EXT2_SYNC		0x00000008	/* Synchronous updates */
-#define EXT2_IMMUTABLE		0x00000010	/* Immutable file */
-#define EXT2_APPEND		0x00000020	/* writes to file may only append */
-#define EXT2_NODUMP		0x00000040	/* do not dump file */
-#define EXT2_NOATIME		0x00000080	/* do not update atime */
+#define EXT2_BAD_INO		 1	/* Bad blocks inode */
+#define EXT2_ROOT_INO		 2	/* Root inode */
+#define EXT2_BOOT_LOADER_INO	 5	/* Boot loader inode */
+#define EXT2_UNDEL_DIR_INO	 6	/* Undelete directory inode */
 
+#define e2di_size_high	e2di_dacl
 
 /*
  * Structure of an inode on the disk
@@ -74,5 +72,18 @@
 	u_int32_t	e2di_linux_reserved3; /* 124 */
 };
 
-#endif /* _FS_EXT2FS_EXT2_DINODE_H_ */
+/*
+ * Inode flags
+ * The current implementation uses only EXT2_IMMUTABLE and EXT2_APPEND flags
+ */
+#define EXT2_SECRM		0x00000001	/* Secure deletion */
+#define EXT2_UNRM		0x00000002	/* Undelete */
+#define EXT2_COMPR		0x00000004	/* Compress file */
+#define EXT2_SYNC		0x00000008	/* Synchronous updates */
+#define EXT2_IMMUTABLE		0x00000010	/* Immutable file */
+#define EXT2_APPEND		0x00000020	/* writes to file may only append */
+#define EXT2_NODUMP		0x00000040	/* do not dump file */
+#define EXT2_NOATIME		0x00000080	/* do not update atime */
+
+#endif /* !_FS_EXT2FS_EXT2_DINODE_H_ */
 
diff -ru ext2fs.bsd/ext2fs.h ext2fs/ext2fs.h
--- ext2fs.bsd/ext2fs.h	2010-01-17 19:03:08.000000000 +0000
+++ ext2fs/ext2fs.h	2010-01-29 09:34:32.000000000 +0000
@@ -39,22 +39,6 @@
 
 #include <sys/types.h>
 
-/*
- * Special inode numbers
- */
-#define	EXT2_BAD_INO		 1	/* Bad blocks inode */
-#define EXT2_ROOT_INO		 2	/* Root inode */
-#define EXT2_BOOT_LOADER_INO	 5	/* Boot loader inode */
-#define EXT2_UNDEL_DIR_INO	 6	/* Undelete directory inode */
-
-/* First non-reserved inode for old ext2 filesystems */
-#define E2FS_REV0_FIRST_INO	11
-
-/*
- * The second extended file system magic number
- */
-#define E2FS_MAGIC		0xEF53
-
 #if defined(_KERNEL)
 /*
  * FreeBSD passes the pointer to the in-core struct with relevant
@@ -129,7 +113,9 @@
 	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 comcate for dir */
+	u_int32_t  e2fs_algo;		/* for compression */
+	uint8_t	   e2fs_prealloc;	/* # of blocks to preallocate */
+	uint8_t	   e2fs_dir_prealloc;	/* # of blocks to preallocate for dir */
 	u_int16_t  e2fs_reserved_ngdb; /* # of reserved gd blocks for resize */
 	u_int32_t  reserved2[204];
 };
@@ -153,8 +139,8 @@
 	uint32_t e2fs_bshift;     /* calc of logical block no */
 	int32_t e2fs_bmask;       /* calc of block offset */
 	int32_t e2fs_bpg;         /* Number of blocks per group */
-	int64_t e2fs_qbmask;       /* = s_blocksize -1 */
-	uint32_t e2fs_fsbtodb;     /* Shift to get disk block */
+	int64_t e2fs_qbmask;      /* = s_blocksize -1 */
+	uint32_t e2fs_fsbtodb;    /* Shift to get disk block */
 	uint32_t e2fs_ipg;        /* Number of inodes per group */
 	uint32_t e2fs_ipb;        /* Number of inodes per block */
 	uint32_t e2fs_itpg;       /* Number of inode table per group */
@@ -169,8 +155,8 @@
 	int32_t  e2fs_isize;      /* Size of inode */
 	uint32_t e2fs_mount_opt;
 	uint32_t e2fs_blocksize_bits;
+	uint8_t	*e2fs_contigdirs; /* (u) # of contig. allocated dirs */
 	uint32_t e2fs_total_dir;  /* Total number of directories */
-	uint8_t	*e2fs_contigdirs;
 	char e2fs_wasvalid;       /* valid at mount time */
 	off_t e2fs_maxfilesize;
 	struct ext2_gd *e2fs_gd; /* Group Descriptors */
@@ -182,6 +168,14 @@
 #define E2FS_DATE		"95/08/09"
 #define E2FS_VERSION		"0.5b"
 
+/* First non-reserved inode for old ext2 filesystems */
+#define E2FS_REV0_FIRST_INO	11
+
+/*
+ * The second extended file system magic number
+ */
+#define E2FS_MAGIC		0xEF53
+
 /*
  * Revision levels
  */
@@ -197,6 +191,7 @@
  * compatible/incompatible features
  */
 #define EXT2F_COMPAT_PREALLOC		0x0001
+#define EXT2F_COMPAT_HASJOURNAL		0x0004
 #define EXT2F_COMPAT_RESIZE		0x0010
 
 #define EXT2F_ROCOMPAT_SPARSESUPER	0x0001
@@ -326,4 +321,4 @@
 
 #endif
 
-#endif	/* _LINUX_EXT2_FS_H */
+#endif	/* !_FS_EXT2FS_EXT2FS_H */


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list