diff options
author | Ian Dowse <iedowse@FreeBSD.org> | 2002-05-16 19:08:03 +0000 |
---|---|---|
committer | Ian Dowse <iedowse@FreeBSD.org> | 2002-05-16 19:08:03 +0000 |
commit | 9504abaad76b5fa631ac0eb7a59d107332189fbd (patch) | |
tree | 90aeb827be217019fb5a2b0c03ee96df99127d25 /sys/gnu/ext2fs/ext2_inode_cnv.c | |
parent | d99142426b33e21bc9344fa772e582fad9380164 (diff) | |
download | src-9504abaad76b5fa631ac0eb7a59d107332189fbd.tar.gz src-9504abaad76b5fa631ac0eb7a59d107332189fbd.zip |
Complete the separation of ext2fs from ufs by copying the remaining
shared code and converting all ufs references. Originally it may
have made sense to share common features between the two filesystems,
but recently it has only caused problems, the UFS2 work being the
final straw.
All UFS_* indirect calls are now direct calls to ext2_* functions,
and ext2fs-specific mount and inode structures have been introduced.
Notes
Notes:
svn path=/head/; revision=96749
Diffstat (limited to 'sys/gnu/ext2fs/ext2_inode_cnv.c')
-rw-r--r-- | sys/gnu/ext2fs/ext2_inode_cnv.c | 151 |
1 files changed, 61 insertions, 90 deletions
diff --git a/sys/gnu/ext2fs/ext2_inode_cnv.c b/sys/gnu/ext2fs/ext2_inode_cnv.c index 3e8e0ff73445..d64e5498776b 100644 --- a/sys/gnu/ext2fs/ext2_inode_cnv.c +++ b/sys/gnu/ext2fs/ext2_inode_cnv.c @@ -23,7 +23,7 @@ */ /* - * routines to convert on disk ext2 inodes in dinodes and back + * routines to convert on disk ext2 inodes into inodes and back */ #include <sys/param.h> #include <sys/systm.h> @@ -31,130 +31,101 @@ #include <sys/stat.h> #include <sys/vnode.h> -#include <ufs/ufs/quota.h> -#include <ufs/ufs/inode.h> - -/* - * Undo the definitions in <ufs/ufs/inode.h> that would destroy the include - * of <gnu/ext2fs/ext2_fs.h>. - */ -#undef i_atime -#undef i_blocks -#undef i_ctime -#undef i_db -#undef i_flags -#undef i_gen -#undef i_gid -#undef i_ib -#undef i_mode -#undef i_mtime -#undef i_nlink -#undef i_rdev -#undef i_shortlink -#undef i_size -#undef i_uid - +#include <gnu/ext2fs/inode.h> #include <gnu/ext2fs/ext2_fs.h> #include <gnu/ext2fs/ext2_extern.h> void -ext2_print_dinode( di ) - struct dinode *di; +ext2_print_inode( in ) + struct inode *in; { int i; + + printf( "Inode: %5d", in->i_number); printf( /* "Inode: %5d" */ " Type: %10s Mode: 0x%o Flags: 0x%x Version: %d\n", - "n/a", di->di_mode, di->di_flags, di->di_gen); + "n/a", in->i_mode, in->i_flags, in->i_gen); printf( "User: %5lu Group: %5lu Size: %lu\n", - (unsigned long)di->di_uid, (unsigned long)di->di_gid, - (unsigned long)di->di_size); + (unsigned long)in->i_uid, (unsigned long)in->i_gid, + (unsigned long)in->i_size); printf( "Links: %3d Blockcount: %d\n", - di->di_nlink, di->di_blocks); - printf( "ctime: 0x%x", di->di_ctime); - printf( "atime: 0x%x", di->di_atime); - printf( "mtime: 0x%x", di->di_mtime); + in->i_nlink, 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 < (di->di_blocks <= 24 ? ((di->di_blocks+1)/2): 12); i++) - printf("%d ", di->di_db[i]); + for(i=0; i < (in->i_blocks <= 24 ? ((in->i_blocks+1)/2): 12); i++) + printf("%d ", in->i_db[i]); printf("\n"); } -void -ext2_print_inode( in ) - struct inode *in; -{ - printf( "Inode: %5d", in->i_number); - ext2_print_dinode(&in->i_din); -} - /* - * raw ext2 inode to dinode + * raw ext2 inode to inode */ void -ext2_ei2di(ei, di) - struct ext2_inode *ei; - struct dinode *di; +ext2_ei2i(ei, ip) + struct ext2_inode *ei; + struct inode *ip; { - int i; + int i; - di->di_nlink = ei->i_links_count; + ip->i_nlink = ei->i_links_count; /* Godmar thinks - if the link count is zero, then the inode is unused - according to ext2 standards. Ufs marks this fact by setting i_mode to zero - why ? I can see that this might lead to problems in an undelete. */ - di->di_mode = ei->i_links_count ? ei->i_mode : 0; - di->di_size = ei->i_size; - di->di_atime = ei->i_atime; - di->di_mtime = ei->i_mtime; - di->di_ctime = ei->i_ctime; - di->di_flags = 0; - di->di_flags |= (ei->i_flags & EXT2_APPEND_FL) ? APPEND : 0; - di->di_flags |= (ei->i_flags & EXT2_IMMUTABLE_FL) ? IMMUTABLE : 0; - di->di_blocks = ei->i_blocks; - di->di_gen = ei->i_generation; - di->di_uid = ei->i_uid; - di->di_gid = ei->i_gid; + ip->i_mode = ei->i_links_count ? ei->i_mode : 0; + ip->i_size = ei->i_size; + ip->i_atime = ei->i_atime; + ip->i_mtime = ei->i_mtime; + ip->i_ctime = ei->i_ctime; + ip->i_flags = 0; + ip->i_flags |= (ei->i_flags & EXT2_APPEND_FL) ? APPEND : 0; + ip->i_flags |= (ei->i_flags & EXT2_IMMUTABLE_FL) ? IMMUTABLE : 0; + ip->i_blocks = ei->i_blocks; + ip->i_gen = ei->i_generation; + ip->i_uid = ei->i_uid; + ip->i_gid = ei->i_gid; /* XXX use memcpy */ - for(i = 0; i < NDADDR; i++) - di->di_db[i] = ei->i_block[i]; - for(i = 0; i < NIADDR; i++) - di->di_ib[i] = ei->i_block[EXT2_NDIR_BLOCKS + i]; + for(i = 0; i < NDADDR; i++) + ip->i_db[i] = ei->i_block[i]; + for(i = 0; i < NIADDR; i++) + ip->i_ib[i] = ei->i_block[EXT2_NDIR_BLOCKS + i]; } /* - * dinode to raw ext2 inode + * inode to raw ext2 inode */ void -ext2_di2ei(di, ei) - struct dinode *di; - struct ext2_inode *ei; +ext2_i2ei(ip, ei) + struct inode *ip; + struct ext2_inode *ei; { - int i; + int i; - ei->i_mode = di->di_mode; - ei->i_links_count = di->di_nlink; + ei->i_mode = ip->i_mode; + ei->i_links_count = ip->i_nlink; /* Godmar thinks: if dtime is nonzero, ext2 says this inode has been deleted, this would correspond to a zero link count */ - ei->i_dtime = ei->i_links_count ? 0 : di->di_mtime; - ei->i_size = di->di_size; - ei->i_atime = di->di_atime; - ei->i_mtime = di->di_mtime; - ei->i_ctime = di->di_ctime; - ei->i_flags = di->di_flags; - ei->i_flags = 0; - ei->i_flags |= (di->di_flags & APPEND) ? EXT2_APPEND_FL: 0; - ei->i_flags |= (di->di_flags & IMMUTABLE) - ? EXT2_IMMUTABLE_FL: 0; - ei->i_blocks = di->di_blocks; - ei->i_generation = di->di_gen; - ei->i_uid = di->di_uid; - ei->i_gid = di->di_gid; + ei->i_dtime = ei->i_links_count ? 0 : ip->i_mtime; + ei->i_size = ip->i_size; + ei->i_atime = ip->i_atime; + ei->i_mtime = ip->i_mtime; + ei->i_ctime = ip->i_ctime; + ei->i_flags = ip->i_flags; + ei->i_flags = 0; + ei->i_flags |= (ip->i_flags & APPEND) ? EXT2_APPEND_FL: 0; + ei->i_flags |= (ip->i_flags & IMMUTABLE) ? EXT2_IMMUTABLE_FL: 0; + ei->i_blocks = ip->i_blocks; + ei->i_generation = ip->i_gen; + ei->i_uid = ip->i_uid; + ei->i_gid = ip->i_gid; /* XXX use memcpy */ - for(i = 0; i < NDADDR; i++) - ei->i_block[i] = di->di_db[i]; - for(i = 0; i < NIADDR; i++) - ei->i_block[EXT2_NDIR_BLOCKS + i] = di->di_ib[i]; + for(i = 0; i < NDADDR; i++) + ei->i_block[i] = ip->i_db[i]; + for(i = 0; i < NIADDR; i++) + ei->i_block[EXT2_NDIR_BLOCKS + i] = ip->i_ib[i]; } |