ext2_inode_cnv.c (202283) | ext2_inode_cnv.c (232703) |
---|---|
1/*- 2 * Copyright (c) 1995 The University of Utah and 3 * the Computer Systems Laboratory at the University of Utah (CSL). 4 * All rights reserved. 5 * 6 * Permission to use, copy, modify and distribute this software is hereby 7 * granted provided that (1) source code retains these copyright, permission, 8 * and disclaimer notices, and (2) redistributions including binaries --- 5 unchanged lines hidden (view full) --- 14 * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS 15 * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF 16 * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 17 * 18 * CSL requests users of this software to return to csl-dist@cs.utah.edu any 19 * improvements that they make and grant CSL redistribution rights. 20 * 21 * Utah $Hdr$ | 1/*- 2 * Copyright (c) 1995 The University of Utah and 3 * the Computer Systems Laboratory at the University of Utah (CSL). 4 * All rights reserved. 5 * 6 * Permission to use, copy, modify and distribute this software is hereby 7 * granted provided that (1) source code retains these copyright, permission, 8 * and disclaimer notices, and (2) redistributions including binaries --- 5 unchanged lines hidden (view full) --- 14 * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS 15 * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF 16 * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 17 * 18 * CSL requests users of this software to return to csl-dist@cs.utah.edu any 19 * improvements that they make and grant CSL redistribution rights. 20 * 21 * Utah $Hdr$ |
22 * $FreeBSD: head/sys/fs/ext2fs/ext2_inode_cnv.c 202283 2010-01-14 14:30:54Z lulf $ | 22 * $FreeBSD: head/sys/fs/ext2fs/ext2_inode_cnv.c 232703 2012-03-08 21:06:05Z pfg $ |
23 */ 24 25/* 26 * routines to convert on disk ext2 inodes into inodes and back 27 */ 28#include <sys/param.h> 29#include <sys/systm.h> 30#include <sys/lock.h> 31#include <sys/stat.h> 32#include <sys/vnode.h> 33 34#include <fs/ext2fs/inode.h> 35#include <fs/ext2fs/ext2fs.h> 36#include <fs/ext2fs/ext2_extern.h> 37#include <fs/ext2fs/ext2_dinode.h> 38 | 23 */ 24 25/* 26 * routines to convert on disk ext2 inodes into inodes and back 27 */ 28#include <sys/param.h> 29#include <sys/systm.h> 30#include <sys/lock.h> 31#include <sys/stat.h> 32#include <sys/vnode.h> 33 34#include <fs/ext2fs/inode.h> 35#include <fs/ext2fs/ext2fs.h> 36#include <fs/ext2fs/ext2_extern.h> 37#include <fs/ext2fs/ext2_dinode.h> 38 |
39#define XTIME_TO_NSEC(x) ((x & EXT3_NSEC_MASK) >> 2) 40#define NSEC_TO_XTIME(t) ((t << 2) & EXT3_NSEC_MASK) 41 |
|
39void 40ext2_print_inode( in ) 41 struct inode *in; 42{ 43 int i; 44 45 printf( "Inode: %5d", in->i_number); 46 printf( /* "Inode: %5d" */ --- 31 unchanged lines hidden (view full) --- 78 */ 79 ip->i_mode = ei->e2di_nlink ? ei->e2di_mode : 0; 80 ip->i_size = ei->e2di_size; 81 if (S_ISREG(ip->i_mode)) 82 ip->i_size |= ((u_int64_t)ei->e2di_size_high) << 32; 83 ip->i_atime = ei->e2di_atime; 84 ip->i_mtime = ei->e2di_mtime; 85 ip->i_ctime = ei->e2di_ctime; | 42void 43ext2_print_inode( in ) 44 struct inode *in; 45{ 46 int i; 47 48 printf( "Inode: %5d", in->i_number); 49 printf( /* "Inode: %5d" */ --- 31 unchanged lines hidden (view full) --- 81 */ 82 ip->i_mode = ei->e2di_nlink ? ei->e2di_mode : 0; 83 ip->i_size = ei->e2di_size; 84 if (S_ISREG(ip->i_mode)) 85 ip->i_size |= ((u_int64_t)ei->e2di_size_high) << 32; 86 ip->i_atime = ei->e2di_atime; 87 ip->i_mtime = ei->e2di_mtime; 88 ip->i_ctime = ei->e2di_ctime; |
89 if (E2DI_HAS_XTIME(ip)) { 90 ip->i_atimensec = XTIME_TO_NSEC(ei->e2di_atime_extra); 91 ip->i_mtimensec = XTIME_TO_NSEC(ei->e2di_mtime_extra); 92 ip->i_ctimensec = XTIME_TO_NSEC(ei->e2di_ctime_extra); 93 ip->i_birthtime = ei->e2di_crtime; 94 ip->i_birthnsec = XTIME_TO_NSEC(ei->e2di_crtime_extra); 95 } |
|
86 ip->i_flags = 0; 87 ip->i_flags |= (ei->e2di_flags & EXT2_APPEND) ? SF_APPEND : 0; 88 ip->i_flags |= (ei->e2di_flags & EXT2_IMMUTABLE) ? SF_IMMUTABLE : 0; 89 ip->i_flags |= (ei->e2di_flags & EXT2_NODUMP) ? UF_NODUMP : 0; 90 ip->i_blocks = ei->e2di_nblock; 91 ip->i_gen = ei->e2di_gen; 92 ip->i_uid = ei->e2di_uid; 93 ip->i_gid = ei->e2di_gid; --- 22 unchanged lines hidden (view full) --- 116 */ 117 ei->e2di_dtime = ei->e2di_nlink ? 0 : ip->i_mtime; 118 ei->e2di_size = ip->i_size; 119 if (S_ISREG(ip->i_mode)) 120 ei->e2di_size_high = ip->i_size >> 32; 121 ei->e2di_atime = ip->i_atime; 122 ei->e2di_mtime = ip->i_mtime; 123 ei->e2di_ctime = ip->i_ctime; | 96 ip->i_flags = 0; 97 ip->i_flags |= (ei->e2di_flags & EXT2_APPEND) ? SF_APPEND : 0; 98 ip->i_flags |= (ei->e2di_flags & EXT2_IMMUTABLE) ? SF_IMMUTABLE : 0; 99 ip->i_flags |= (ei->e2di_flags & EXT2_NODUMP) ? UF_NODUMP : 0; 100 ip->i_blocks = ei->e2di_nblock; 101 ip->i_gen = ei->e2di_gen; 102 ip->i_uid = ei->e2di_uid; 103 ip->i_gid = ei->e2di_gid; --- 22 unchanged lines hidden (view full) --- 126 */ 127 ei->e2di_dtime = ei->e2di_nlink ? 0 : ip->i_mtime; 128 ei->e2di_size = ip->i_size; 129 if (S_ISREG(ip->i_mode)) 130 ei->e2di_size_high = ip->i_size >> 32; 131 ei->e2di_atime = ip->i_atime; 132 ei->e2di_mtime = ip->i_mtime; 133 ei->e2di_ctime = ip->i_ctime; |
134 if (E2DI_HAS_XTIME(ip)) { 135 ei->e2di_ctime_extra = NSEC_TO_XTIME(ip->i_ctimensec); 136 ei->e2di_mtime_extra = NSEC_TO_XTIME(ip->i_mtimensec); 137 ei->e2di_atime_extra = NSEC_TO_XTIME(ip->i_atimensec); 138 ei->e2di_crtime = ip->i_birthtime; 139 ei->e2di_crtime_extra = NSEC_TO_XTIME(ip->i_birthnsec); 140 } |
|
124 ei->e2di_flags = ip->i_flags; 125 ei->e2di_flags = 0; 126 ei->e2di_flags |= (ip->i_flags & SF_APPEND) ? EXT2_APPEND: 0; 127 ei->e2di_flags |= (ip->i_flags & SF_IMMUTABLE) ? EXT2_IMMUTABLE: 0; 128 ei->e2di_flags |= (ip->i_flags & UF_NODUMP) ? EXT2_NODUMP: 0; 129 ei->e2di_nblock = ip->i_blocks; 130 ei->e2di_gen = ip->i_gen; 131 ei->e2di_uid = ip->i_uid; 132 ei->e2di_gid = ip->i_gid; 133 /* XXX use memcpy */ 134 for(i = 0; i < NDADDR; i++) 135 ei->e2di_blocks[i] = ip->i_db[i]; 136 for(i = 0; i < NIADDR; i++) 137 ei->e2di_blocks[EXT2_NDIR_BLOCKS + i] = ip->i_ib[i]; 138} | 141 ei->e2di_flags = ip->i_flags; 142 ei->e2di_flags = 0; 143 ei->e2di_flags |= (ip->i_flags & SF_APPEND) ? EXT2_APPEND: 0; 144 ei->e2di_flags |= (ip->i_flags & SF_IMMUTABLE) ? EXT2_IMMUTABLE: 0; 145 ei->e2di_flags |= (ip->i_flags & UF_NODUMP) ? EXT2_NODUMP: 0; 146 ei->e2di_nblock = ip->i_blocks; 147 ei->e2di_gen = ip->i_gen; 148 ei->e2di_uid = ip->i_uid; 149 ei->e2di_gid = ip->i_gid; 150 /* XXX use memcpy */ 151 for(i = 0; i < NDADDR; i++) 152 ei->e2di_blocks[i] = ip->i_db[i]; 153 for(i = 0; i < NIADDR; i++) 154 ei->e2di_blocks[EXT2_NDIR_BLOCKS + i] = ip->i_ib[i]; 155} |