summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2012-12-20 02:22:36 +0000
committerpfg <pfg@FreeBSD.org>2012-12-20 02:22:36 +0000
commit16216f308ecbecf894004a7d4d7146e513c243ee (patch)
tree7e249026a8f2bd6c706a47b52d4bcd0094a9cb83
parent90acfcf07cafd583658a435ebeb7f49822941299 (diff)
downloadFreeBSD-src-16216f308ecbecf894004a7d4d7146e513c243ee.zip
FreeBSD-src-16216f308ecbecf894004a7d4d7146e513c243ee.tar.gz
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 MFC after: 5 days
-rwxr-xr-xsys/fs/ext2fs/ext2_dinode.h22
-rw-r--r--sys/fs/ext2fs/ext2_inode_cnv.c5
-rw-r--r--sys/fs/ext2fs/ext2_vfsops.c2
-rwxr-xr-xsys/fs/ext2fs/ext2fs.h20
4 files changed, 25 insertions, 24 deletions
diff --git a/sys/fs/ext2fs/ext2_dinode.h b/sys/fs/ext2fs/ext2_dinode.h
index 16c2cb7..9a87fc4 100755
--- a/sys/fs/ext2fs/ext2_dinode.h
+++ b/sys/fs/ext2fs/ext2_dinode.h
@@ -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
diff --git a/sys/fs/ext2fs/ext2_inode_cnv.c b/sys/fs/ext2fs/ext2_inode_cnv.c
index aff44d9..0fa3075 100644
--- a/sys/fs/ext2fs/ext2_inode_cnv.c
+++ b/sys/fs/ext2fs/ext2_inode_cnv.c
@@ -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 )
diff --git a/sys/fs/ext2fs/ext2_vfsops.c b/sys/fs/ext2fs/ext2_vfsops.c
index 7447558..3f181fd 100644
--- a/sys/fs/ext2fs/ext2_vfsops.c
+++ b/sys/fs/ext2fs/ext2_vfsops.c
@@ -349,7 +349,7 @@ compute_sb_data(struct vnode *devvp, struct ext2fs *es,
}
}
/* 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);
diff --git a/sys/fs/ext2fs/ext2fs.h b/sys/fs/ext2fs/ext2fs.h
index add9c05..5cafc7b 100755
--- a/sys/fs/ext2fs/ext2fs.h
+++ b/sys/fs/ext2fs/ext2fs.h
@@ -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
OpenPOWER on IntegriCloud