ext2_inode_cnv.c (252890) | ext2_inode_cnv.c (254260) |
---|---|
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 252890 2013-07-06 18:28:06Z pfg $ | 22 * $FreeBSD: head/sys/fs/ext2fs/ext2_inode_cnv.c 254260 2013-08-12 21:34:48Z 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/endian.h> 31#include <sys/lock.h> 32#include <sys/stat.h> 33#include <sys/vnode.h> 34 | 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/endian.h> 31#include <sys/lock.h> 32#include <sys/stat.h> 33#include <sys/vnode.h> 34 |
35#include <fs/ext2fs/fs.h> |
|
35#include <fs/ext2fs/inode.h> 36#include <fs/ext2fs/ext2fs.h> 37#include <fs/ext2fs/ext2_dinode.h> 38#include <fs/ext2fs/ext2_extern.h> 39 40#define XTIME_TO_NSEC(x) ((x & EXT3_NSEC_MASK) >> 2) 41#define NSEC_TO_XTIME(t) (le32toh(t << 2) & EXT3_NSEC_MASK) 42 43void 44ext2_print_inode(struct inode *in) 45{ 46 int i; | 36#include <fs/ext2fs/inode.h> 37#include <fs/ext2fs/ext2fs.h> 38#include <fs/ext2fs/ext2_dinode.h> 39#include <fs/ext2fs/ext2_extern.h> 40 41#define XTIME_TO_NSEC(x) ((x & EXT3_NSEC_MASK) >> 2) 42#define NSEC_TO_XTIME(t) (le32toh(t << 2) & EXT3_NSEC_MASK) 43 44void 45ext2_print_inode(struct inode *in) 46{ 47 int i; |
48 struct ext4_extent_header *ehp; 49 struct ext4_extent *ep; |
|
47 48 printf( "Inode: %5ju", (uintmax_t)in->i_number); 49 printf( /* "Inode: %5d" */ 50 " Type: %10s Mode: 0x%o Flags: 0x%x Version: %d\n", 51 "n/a", in->i_mode, in->i_flags, in->i_gen); | 50 51 printf( "Inode: %5ju", (uintmax_t)in->i_number); 52 printf( /* "Inode: %5d" */ 53 " Type: %10s Mode: 0x%o Flags: 0x%x Version: %d\n", 54 "n/a", in->i_mode, in->i_flags, in->i_gen); |
52 printf( "User: %5lu Group: %5lu Size: %lu\n", 53 (unsigned long)in->i_uid, (unsigned long)in->i_gid, 54 (unsigned long)in->i_size); 55 printf( "Links: %3d Blockcount: %d\n", 56 in->i_nlink, in->i_blocks); | 55 printf("User: %5u Group: %5u Size: %ju\n", 56 in->i_uid, in->i_gid, (uintmax_t)in->i_size); 57 printf("Links: %3d Blockcount: %ju\n", 58 in->i_nlink, (uintmax_t)in->i_blocks); |
57 printf( "ctime: 0x%x", in->i_ctime); 58 printf( "atime: 0x%x", in->i_atime); 59 printf( "mtime: 0x%x", in->i_mtime); | 59 printf( "ctime: 0x%x", in->i_ctime); 60 printf( "atime: 0x%x", in->i_atime); 61 printf( "mtime: 0x%x", in->i_mtime); |
60 printf( "BLOCKS: "); 61 for(i=0; i < (in->i_blocks <= 24 ? ((in->i_blocks+1)/2): 12); i++) 62 printf("%d ", in->i_db[i]); | 62 if (E2DI_HAS_XTIME(in)) 63 printf("crtime %#x ", in->i_birthtime); 64 printf("BLOCKS:"); 65 for (i = 0; i < (in->i_blocks <= 24 ? (in->i_blocks + 1) / 2 : 12); i++) 66 printf(" %d", in->i_db[i]); |
63 printf("\n"); | 67 printf("\n"); |
68 printf("Extents:\n"); 69 ehp = (struct ext4_extent_header *)in->i_db; 70 printf("Header (magic 0x%x entries %d max %d depth %d gen %d)\n", 71 ehp->eh_magic, ehp->eh_ecount, ehp->eh_max, ehp->eh_depth, 72 ehp->eh_gen); 73 ep = (struct ext4_extent *)(char *)(ehp + 1); 74 printf("Index (blk %d len %d start_lo %d start_hi %d)\n", ep->e_blk, 75 ep->e_len, ep->e_start_lo, ep->e_start_hi); 76 printf("\n"); |
|
64} 65 66/* 67 * raw ext2 inode to inode 68 */ 69void 70ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip) 71{ --- 19 unchanged lines hidden (view full) --- 91 ip->i_birthtime = ei->e2di_crtime; 92 ip->i_birthnsec = XTIME_TO_NSEC(ei->e2di_crtime_extra); 93 } 94 ip->i_flags = ei->e2di_flags; 95 ip->i_flags |= (ei->e2di_flags & EXT2_APPEND) ? SF_APPEND : 0; 96 ip->i_flags |= (ei->e2di_flags & EXT2_IMMUTABLE) ? SF_IMMUTABLE : 0; 97 ip->i_flags |= (ei->e2di_flags & EXT2_NODUMP) ? UF_NODUMP : 0; 98 ip->i_blocks = ei->e2di_nblock; | 77} 78 79/* 80 * raw ext2 inode to inode 81 */ 82void 83ext2_ei2i(struct ext2fs_dinode *ei, struct inode *ip) 84{ --- 19 unchanged lines hidden (view full) --- 104 ip->i_birthtime = ei->e2di_crtime; 105 ip->i_birthnsec = XTIME_TO_NSEC(ei->e2di_crtime_extra); 106 } 107 ip->i_flags = ei->e2di_flags; 108 ip->i_flags |= (ei->e2di_flags & EXT2_APPEND) ? SF_APPEND : 0; 109 ip->i_flags |= (ei->e2di_flags & EXT2_IMMUTABLE) ? SF_IMMUTABLE : 0; 110 ip->i_flags |= (ei->e2di_flags & EXT2_NODUMP) ? UF_NODUMP : 0; 111 ip->i_blocks = ei->e2di_nblock; |
112 if (E2DI_HAS_HUGE_FILE(ip)) { 113 ip->i_blocks |= (uint64_t)ei->e2di_nblock_high << 32; 114 if (ei->e2di_flags & EXT4_HUGE_FILE) 115 ip->i_blocks = fsbtodb(ip->i_e2fs, ip->i_blocks); 116 } |
|
99 ip->i_gen = ei->e2di_gen; 100 ip->i_uid = ei->e2di_uid; 101 ip->i_gid = ei->e2di_gid; 102 /* XXX use memcpy */ 103 for(i = 0; i < NDADDR; i++) 104 ip->i_db[i] = ei->e2di_blocks[i]; 105 for(i = 0; i < NIADDR; i++) 106 ip->i_ib[i] = ei->e2di_blocks[EXT2_NDIR_BLOCKS + i]; --- 26 unchanged lines hidden (view full) --- 133 ei->e2di_atime_extra = NSEC_TO_XTIME(ip->i_atimensec); 134 ei->e2di_crtime = ip->i_birthtime; 135 ei->e2di_crtime_extra = NSEC_TO_XTIME(ip->i_birthnsec); 136 } 137 ei->e2di_flags = ip->i_flags; 138 ei->e2di_flags |= (ip->i_flags & SF_APPEND) ? EXT2_APPEND: 0; 139 ei->e2di_flags |= (ip->i_flags & SF_IMMUTABLE) ? EXT2_IMMUTABLE: 0; 140 ei->e2di_flags |= (ip->i_flags & UF_NODUMP) ? EXT2_NODUMP: 0; | 117 ip->i_gen = ei->e2di_gen; 118 ip->i_uid = ei->e2di_uid; 119 ip->i_gid = ei->e2di_gid; 120 /* XXX use memcpy */ 121 for(i = 0; i < NDADDR; i++) 122 ip->i_db[i] = ei->e2di_blocks[i]; 123 for(i = 0; i < NIADDR; i++) 124 ip->i_ib[i] = ei->e2di_blocks[EXT2_NDIR_BLOCKS + i]; --- 26 unchanged lines hidden (view full) --- 151 ei->e2di_atime_extra = NSEC_TO_XTIME(ip->i_atimensec); 152 ei->e2di_crtime = ip->i_birthtime; 153 ei->e2di_crtime_extra = NSEC_TO_XTIME(ip->i_birthnsec); 154 } 155 ei->e2di_flags = ip->i_flags; 156 ei->e2di_flags |= (ip->i_flags & SF_APPEND) ? EXT2_APPEND: 0; 157 ei->e2di_flags |= (ip->i_flags & SF_IMMUTABLE) ? EXT2_IMMUTABLE: 0; 158 ei->e2di_flags |= (ip->i_flags & UF_NODUMP) ? EXT2_NODUMP: 0; |
141 ei->e2di_nblock = ip->i_blocks; | 159 ei->e2di_nblock = ip->i_blocks & 0xffffffff; 160 ei->e2di_nblock_high = ip->i_blocks >> 32 & 0xffff; |
142 ei->e2di_gen = ip->i_gen; 143 ei->e2di_uid = ip->i_uid; 144 ei->e2di_gid = ip->i_gid; 145 /* XXX use memcpy */ 146 for(i = 0; i < NDADDR; i++) 147 ei->e2di_blocks[i] = ip->i_db[i]; 148 for(i = 0; i < NIADDR; i++) 149 ei->e2di_blocks[EXT2_NDIR_BLOCKS + i] = ip->i_ib[i]; 150} | 161 ei->e2di_gen = ip->i_gen; 162 ei->e2di_uid = ip->i_uid; 163 ei->e2di_gid = ip->i_gid; 164 /* XXX use memcpy */ 165 for(i = 0; i < NDADDR; i++) 166 ei->e2di_blocks[i] = ip->i_db[i]; 167 for(i = 0; i < NIADDR; i++) 168 ei->e2di_blocks[EXT2_NDIR_BLOCKS + i] = ip->i_ib[i]; 169} |