svn commit: r244687 - stable/9/sys/fs/ext2fs

Pedro F. Giffuni pfg at FreeBSD.org
Tue Dec 25 17:39:38 UTC 2012


Author: pfg
Date: Tue Dec 25 17:39:37 2012
New Revision: 244687
URL: http://svnweb.freebsd.org/changeset/base/244687

Log:
  MFC	r244475:
  More constant renaming in preparation for newer features.
  
  We also try to make better use of the fs flags instead of
  trying adapt the code according to the fs structures. In
  the case of subsecond timestamps and birthtime we now
  check that the feature is explicitly enabled: previously
  we only checked that the reserved space was available and
  silently wrote them.
  
  This approach is much safer, especially if the filesystem
  happens to use embedded inodes or support EAs.
  
  Discussed with:    Zheng Liu, bde

Modified:
  stable/9/sys/fs/ext2fs/ext2_dinode.h
  stable/9/sys/fs/ext2fs/ext2_inode_cnv.c
  stable/9/sys/fs/ext2fs/ext2_vfsops.c
  stable/9/sys/fs/ext2fs/ext2fs.h

Modified: stable/9/sys/fs/ext2fs/ext2_dinode.h
==============================================================================
--- stable/9/sys/fs/ext2fs/ext2_dinode.h	Tue Dec 25 17:06:05 2012	(r244686)
+++ stable/9/sys/fs/ext2fs/ext2_dinode.h	Tue Dec 25 17:39:37 2012	(r244687)
@@ -60,15 +60,16 @@
 #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_INDEX		0x00001000 	/* hash-indexed directory */
-#define EXT2_IMAGIC		0x00002000 	/* AFS directory */
-#define EXT2_JOURNAL_DATA		0x00004000 /* file data should be journaled */
-#define EXT2_NOTAIL		0x00008000 /* file tail should not be merged */
-#define EXT2_DIRSYNC		0x00010000	/* dirsync behaviour */
-#define EXT2_TOPDIR		0x00020000 /* Top of directory hierarchies*/
-#define EXT2_HUGE_FILE		0x00040000	/* Set to each huge file */
-#define EXT2_EXTENTS		0x00080000	/* Inode uses extents */
-#define EXT2_EOFBLOCKS		0x00400000 /* Blocks allocated beyond EOF */
+
+#define EXT4_INDEX		0x00001000 	/* hash-indexed directory */
+#define EXT4_IMAGIC		0x00002000 	/* AFS directory */
+#define EXT4_JOURNAL_DATA	0x00004000 /* file data should be journaled */
+#define EXT4_NOTAIL		0x00008000 /* file tail should not be merged */
+#define EXT4_DIRSYNC		0x00010000	/* dirsync behaviour */
+#define EXT4_TOPDIR		0x00020000 /* Top of directory hierarchies*/
+#define EXT4_HUGE_FILE		0x00040000	/* Set to each huge file */
+#define EXT4_EXTENTS		0x00080000	/* Inode uses extents */
+#define EXT4_EOFBLOCKS		0x00400000 /* Blocks allocated beyond EOF */
 
 /*
  * Definitions for nanosecond timestamps.
@@ -78,8 +79,7 @@
 #define EXT3_EPOCH_MASK	((1 << EXT3_EPOCH_BITS) - 1)
 #define EXT3_NSEC_MASK	(~0UL << EXT3_EPOCH_BITS)
 
-#define E2DI_HAS_XTIME(ip)	(EXT2_INODE_SIZE((ip)->i_e2fs) > \
-				    E2FS_REV0_INODE_SIZE)
+#define E2DI_HAS_XTIME(ip)	(EXT2_HAS_RO_COMPAT_FEATURE(ip->i_e2fs, EXT2F_ROCOMPAT_EXTRA_ISIZE))
 
 /*
  * Structure of an inode on the disk

Modified: stable/9/sys/fs/ext2fs/ext2_inode_cnv.c
==============================================================================
--- stable/9/sys/fs/ext2fs/ext2_inode_cnv.c	Tue Dec 25 17:06:05 2012	(r244686)
+++ stable/9/sys/fs/ext2fs/ext2_inode_cnv.c	Tue Dec 25 17:39:37 2012	(r244687)
@@ -27,17 +27,18 @@
  */
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/endian.h>
 #include <sys/lock.h>
 #include <sys/stat.h>
 #include <sys/vnode.h>
 
 #include <fs/ext2fs/inode.h>
 #include <fs/ext2fs/ext2fs.h>
-#include <fs/ext2fs/ext2_extern.h>
 #include <fs/ext2fs/ext2_dinode.h>
+#include <fs/ext2fs/ext2_extern.h>
 
 #define XTIME_TO_NSEC(x)	((x & EXT3_NSEC_MASK) >> 2)
-#define NSEC_TO_XTIME(t)	((t << 2) & EXT3_NSEC_MASK)
+#define NSEC_TO_XTIME(t)	(le32toh(t << 2) & EXT3_NSEC_MASK)
 
 void
 ext2_print_inode( in )

Modified: stable/9/sys/fs/ext2fs/ext2_vfsops.c
==============================================================================
--- stable/9/sys/fs/ext2fs/ext2_vfsops.c	Tue Dec 25 17:06:05 2012	(r244686)
+++ stable/9/sys/fs/ext2fs/ext2_vfsops.c	Tue Dec 25 17:39:37 2012	(r244687)
@@ -349,7 +349,7 @@ compute_sb_data(struct vnode *devvp, str
 		}
 	}
 	/* Check for extra isize in big inodes. */
-	if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT4F_ROCOMPAT_EXTRA_ISIZE) &&
+	if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_EXTRA_ISIZE) &&
 	    EXT2_INODE_SIZE(fs) < sizeof(struct ext2fs_dinode)) {
 		printf("ext2fs: no space for extra inode timestamps\n");
 		return (EINVAL);

Modified: stable/9/sys/fs/ext2fs/ext2fs.h
==============================================================================
--- stable/9/sys/fs/ext2fs/ext2fs.h	Tue Dec 25 17:06:05 2012	(r244686)
+++ stable/9/sys/fs/ext2fs/ext2fs.h	Tue Dec 25 17:39:37 2012	(r244687)
@@ -215,18 +215,18 @@ struct m_ext2fs {
 #define EXT2F_ROCOMPAT_SPARSESUPER	0x0001
 #define EXT2F_ROCOMPAT_LARGEFILE	0x0002
 #define EXT2F_ROCOMPAT_BTREE_DIR	0x0004
-#define EXT4F_ROCOMPAT_HUGE_FILE	0x0008
-#define EXT4F_ROCOMPAT_GDT_CSUM		0x0010
-#define EXT4F_ROCOMPAT_DIR_NLINK	0x0020
-#define EXT4F_ROCOMPAT_EXTRA_ISIZE	0x0040
+#define EXT2F_ROCOMPAT_HUGE_FILE	0x0008
+#define EXT2F_ROCOMPAT_GDT_CSUM		0x0010
+#define EXT2F_ROCOMPAT_DIR_NLINK	0x0020
+#define EXT2F_ROCOMPAT_EXTRA_ISIZE	0x0040
 
 #define EXT2F_INCOMPAT_COMP		0x0001
 #define EXT2F_INCOMPAT_FTYPE		0x0002
-#define EXT4F_INCOMPAT_META_BG		0x0010
-#define EXT4F_INCOMPAT_EXTENTS		0x0040
-#define EXT4F_INCOMPAT_64BIT		0x0080
-#define EXT4F_INCOMPAT_MMP		0x0100
-#define EXT4F_INCOMPAT_FLEX_BG		0x0200
+#define EXT2F_INCOMPAT_META_BG		0x0010
+#define EXT2F_INCOMPAT_EXTENTS		0x0040
+#define EXT2F_INCOMPAT_64BIT		0x0080
+#define EXT2F_INCOMPAT_MMP		0x0100
+#define EXT2F_INCOMPAT_FLEX_BG		0x0200
 
 /*
  * Features supported in this implementation
@@ -239,7 +239,7 @@ struct m_ext2fs {
 #define EXT2F_COMPAT_SUPP		0x0000
 #define EXT2F_ROCOMPAT_SUPP		(EXT2F_ROCOMPAT_SPARSESUPER | \
 					 EXT2F_ROCOMPAT_LARGEFILE | \
-					 EXT4F_ROCOMPAT_EXTRA_ISIZE)
+					 EXT2F_ROCOMPAT_EXTRA_ISIZE)
 #define EXT2F_INCOMPAT_SUPP		EXT2F_INCOMPAT_FTYPE
 
 /* Assume that user mode programs are passing in an ext2fs superblock, not


More information about the svn-src-all mailing list