summaryrefslogtreecommitdiffstats
path: root/sys/fs/ext2fs/ext2_inode_cnv.c
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2013-08-12 21:34:48 +0000
committerpfg <pfg@FreeBSD.org>2013-08-12 21:34:48 +0000
commit0b111bdfcbe8e9c5f1d30ef4226b1250231c8716 (patch)
treee860424fb0197712306853c548b2f4f68cda88d8 /sys/fs/ext2fs/ext2_inode_cnv.c
parent3eef1145fb2dc3eb7434ad247e8dd4f79a183cd0 (diff)
downloadFreeBSD-src-0b111bdfcbe8e9c5f1d30ef4226b1250231c8716.zip
FreeBSD-src-0b111bdfcbe8e9c5f1d30ef4226b1250231c8716.tar.gz
Add read-only support for extents in ext2fs.
Basic support for extents was implemented by Zheng Liu as part of his Google Summer of Code in 2010. This support is read-only at this time. In addition to extents we also support the huge_file extension for read-only purposes. This works nicely with the additional support for birthtime/nanosec timestamps and dir_index that have been added lately. The implementation may not work for all ext4 filesystems as it doesn't support some features that are being enabled by default on recent linux like flex_bg. Nevertheless, the feature should be very useful for migration or simple access in filesystems that have been converted from ext2/3 or don't use incompatible features. Special thanks to Zheng Liu for his dedication and continued work to support ext2 in FreeBSD. Submitted by: Zheng Liu (lz@) Reviewed by: Mike Ma, Christoph Mallon (previous version) Sponsored by: Google Inc. MFC after: 3 weeks
Diffstat (limited to 'sys/fs/ext2fs/ext2_inode_cnv.c')
-rw-r--r--sys/fs/ext2fs/ext2_inode_cnv.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/sys/fs/ext2fs/ext2_inode_cnv.c b/sys/fs/ext2fs/ext2_inode_cnv.c
index cade4a6..c26784b 100644
--- a/sys/fs/ext2fs/ext2_inode_cnv.c
+++ b/sys/fs/ext2fs/ext2_inode_cnv.c
@@ -32,6 +32,7 @@
#include <sys/stat.h>
#include <sys/vnode.h>
+#include <fs/ext2fs/fs.h>
#include <fs/ext2fs/inode.h>
#include <fs/ext2fs/ext2fs.h>
#include <fs/ext2fs/ext2_dinode.h>
@@ -44,22 +45,34 @@ void
ext2_print_inode(struct inode *in)
{
int i;
+ struct ext4_extent_header *ehp;
+ struct ext4_extent *ep;
printf( "Inode: %5ju", (uintmax_t)in->i_number);
printf( /* "Inode: %5d" */
" Type: %10s Mode: 0x%o Flags: 0x%x Version: %d\n",
"n/a", in->i_mode, in->i_flags, in->i_gen);
- printf( "User: %5lu Group: %5lu Size: %lu\n",
- (unsigned long)in->i_uid, (unsigned long)in->i_gid,
- (unsigned long)in->i_size);
- printf( "Links: %3d Blockcount: %d\n",
- in->i_nlink, in->i_blocks);
+ printf("User: %5u Group: %5u Size: %ju\n",
+ in->i_uid, in->i_gid, (uintmax_t)in->i_size);
+ printf("Links: %3d Blockcount: %ju\n",
+ in->i_nlink, (uintmax_t)in->i_blocks);
printf( "ctime: 0x%x", in->i_ctime);
printf( "atime: 0x%x", in->i_atime);
printf( "mtime: 0x%x", in->i_mtime);
- printf( "BLOCKS: ");
- for(i=0; i < (in->i_blocks <= 24 ? ((in->i_blocks+1)/2): 12); i++)
- printf("%d ", in->i_db[i]);
+ if (E2DI_HAS_XTIME(in))
+ printf("crtime %#x ", in->i_birthtime);
+ printf("BLOCKS:");
+ for (i = 0; i < (in->i_blocks <= 24 ? (in->i_blocks + 1) / 2 : 12); i++)
+ printf(" %d", in->i_db[i]);
+ printf("\n");
+ printf("Extents:\n");
+ ehp = (struct ext4_extent_header *)in->i_db;
+ printf("Header (magic 0x%x entries %d max %d depth %d gen %d)\n",
+ ehp->eh_magic, ehp->eh_ecount, ehp->eh_max, ehp->eh_depth,
+ ehp->eh_gen);
+ ep = (struct ext4_extent *)(char *)(ehp + 1);
+ printf("Index (blk %d len %d start_lo %d start_hi %d)\n", ep->e_blk,
+ ep->e_len, ep->e_start_lo, ep->e_start_hi);
printf("\n");
}
@@ -96,6 +109,11 @@ ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip)
ip->i_flags |= (ei->e2di_flags & EXT2_IMMUTABLE) ? SF_IMMUTABLE : 0;
ip->i_flags |= (ei->e2di_flags & EXT2_NODUMP) ? UF_NODUMP : 0;
ip->i_blocks = ei->e2di_nblock;
+ if (E2DI_HAS_HUGE_FILE(ip)) {
+ ip->i_blocks |= (uint64_t)ei->e2di_nblock_high << 32;
+ if (ei->e2di_flags & EXT4_HUGE_FILE)
+ ip->i_blocks = fsbtodb(ip->i_e2fs, ip->i_blocks);
+ }
ip->i_gen = ei->e2di_gen;
ip->i_uid = ei->e2di_uid;
ip->i_gid = ei->e2di_gid;
@@ -138,7 +156,8 @@ ext2_i2ei(struct inode *ip, struct ext2fs_dinode *ei)
ei->e2di_flags |= (ip->i_flags & SF_APPEND) ? EXT2_APPEND: 0;
ei->e2di_flags |= (ip->i_flags & SF_IMMUTABLE) ? EXT2_IMMUTABLE: 0;
ei->e2di_flags |= (ip->i_flags & UF_NODUMP) ? EXT2_NODUMP: 0;
- ei->e2di_nblock = ip->i_blocks;
+ ei->e2di_nblock = ip->i_blocks & 0xffffffff;
+ ei->e2di_nblock_high = ip->i_blocks >> 32 & 0xffff;
ei->e2di_gen = ip->i_gen;
ei->e2di_uid = ip->i_uid;
ei->e2di_gid = ip->i_gid;
OpenPOWER on IntegriCloud