diff options
author | Fedor Uporov <fsu@FreeBSD.org> | 2017-10-17 20:45:44 +0000 |
---|---|---|
committer | Fedor Uporov <fsu@FreeBSD.org> | 2017-10-17 20:45:44 +0000 |
commit | b394cd1e28f1a094742434474ebe4f5004bf0ce3 (patch) | |
tree | 4a903d2c90a5b6b6660009ceba227c563b50628b /sys/fs/ext2fs/ext2_inode_cnv.c | |
parent | b541ba195ccc4806d94348fa328d620e3261c05a (diff) | |
download | src-b394cd1e28f1a094742434474ebe4f5004bf0ce3.tar.gz src-b394cd1e28f1a094742434474ebe4f5004bf0ce3.zip |
Add inital extents read-write support.
Approved by: pfg (mentor)
MFC after: 6 months
RelNotes: Yes
Differential Revision: https://reviews.freebsd.org/D12087
Notes
Notes:
svn path=/head/; revision=324706
Diffstat (limited to 'sys/fs/ext2fs/ext2_inode_cnv.c')
-rw-r--r-- | sys/fs/ext2fs/ext2_inode_cnv.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/sys/fs/ext2fs/ext2_inode_cnv.c b/sys/fs/ext2fs/ext2_inode_cnv.c index ec3faa93b1fa..ef2fe60ef3f9 100644 --- a/sys/fs/ext2fs/ext2_inode_cnv.c +++ b/sys/fs/ext2fs/ext2_inode_cnv.c @@ -51,7 +51,7 @@ ext2_print_inode(struct inode *in) printf("Inode: %5ju", (uintmax_t)in->i_number); printf( /* "Inode: %5d" */ - " Type: %10s Mode: 0x%o Flags: 0x%x Version: %d acl: 0x%llx\n", + " Type: %10s Mode: 0x%o Flags: 0x%x Version: %d acl: 0x%lx\n", "n/a", in->i_mode, in->i_flags, in->i_gen, in->i_facl); printf("User: %5u Group: %5u Size: %ju\n", in->i_uid, in->i_gid, (uintmax_t)in->i_size); @@ -62,19 +62,22 @@ ext2_print_inode(struct inode *in) printf("mtime: 0x%x", in->i_mtime); 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"); + if (in->i_flag & IN_E4EXTENTS) { + 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"); + } else { + 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"); + } } #endif /* EXT2FS_DEBUG */ @@ -84,8 +87,6 @@ ext2_print_inode(struct inode *in) void ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip) { - int i; - ip->i_nlink = ei->e2di_nlink; /* * Godmar thinks - if the link count is zero, then the inode is @@ -127,10 +128,7 @@ ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip) ip->i_uid |= (uint32_t)ei->e2di_uid_high << 16; ip->i_gid |= (uint32_t)ei->e2di_gid_high << 16; - for (i = 0; i < EXT2_NDADDR; i++) - ip->i_db[i] = ei->e2di_blocks[i]; - for (i = 0; i < EXT2_NIADDR; i++) - ip->i_ib[i] = ei->e2di_blocks[EXT2_NDIR_BLOCKS + i]; + memcpy(ip->i_data, ei->e2di_blocks, sizeof(ei->e2di_blocks)); } /* @@ -140,7 +138,6 @@ int ext2_i2ei(struct inode *ip, struct ext2fs_dinode *ei) { struct m_ext2fs *fs; - int i; fs = ip->i_e2fs; ei->e2di_mode = ip->i_mode; @@ -190,10 +187,7 @@ ext2_i2ei(struct inode *ip, struct ext2fs_dinode *ei) ei->e2di_gid = ip->i_gid & 0xffff; ei->e2di_gid_high = ip->i_gid >> 16 & 0xffff; - for (i = 0; i < EXT2_NDADDR; i++) - ei->e2di_blocks[i] = ip->i_db[i]; - for (i = 0; i < EXT2_NIADDR; i++) - ei->e2di_blocks[EXT2_NDIR_BLOCKS + i] = ip->i_ib[i]; + memcpy(ei->e2di_blocks, ip->i_data, sizeof(ei->e2di_blocks)); return (0); } |