| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | *  linux/include/linux/ufs_fs.h | 
|  | 3 | * | 
|  | 4 | * Copyright (C) 1996 | 
|  | 5 | * Adrian Rodriguez (adrian@franklins-tower.rutgers.edu) | 
|  | 6 | * Laboratory for Computer Science Research Computing Facility | 
|  | 7 | * Rutgers, The State University of New Jersey | 
|  | 8 | * | 
|  | 9 | * Clean swab support by Fare <fare@tunes.org> | 
|  | 10 | * just hope no one is using NNUUXXI on __?64 structure elements | 
|  | 11 | * 64-bit clean thanks to Maciej W. Rozycki <macro@ds2.pg.gda.pl> | 
|  | 12 | * | 
|  | 13 | * 4.4BSD (FreeBSD) support added on February 1st 1998 by | 
|  | 14 | * Niels Kristian Bech Jensen <nkbj@image.dk> partially based | 
|  | 15 | * on code by Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de>. | 
|  | 16 | * | 
|  | 17 | * NeXTstep support added on February 5th 1998 by | 
|  | 18 | * Niels Kristian Bech Jensen <nkbj@image.dk>. | 
|  | 19 | * | 
|  | 20 | * Write support by Daniel Pirkl <daniel.pirkl@email.cz> | 
|  | 21 | * | 
|  | 22 | * HP/UX hfs filesystem support added by | 
|  | 23 | * Martin K. Petersen <mkp@mkp.net>, August 1999 | 
|  | 24 | * | 
|  | 25 | * UFS2 (of FreeBSD 5.x) support added by | 
|  | 26 | * Niraj Kumar <niraj17@iitbombay.org>  , Jan 2004 | 
|  | 27 | * | 
|  | 28 | */ | 
|  | 29 |  | 
|  | 30 | #ifndef __LINUX_UFS_FS_H | 
|  | 31 | #define __LINUX_UFS_FS_H | 
|  | 32 |  | 
|  | 33 | #include <linux/types.h> | 
|  | 34 | #include <linux/kernel.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #include <linux/stat.h> | 
|  | 36 | #include <linux/fs.h> | 
|  | 37 |  | 
|  | 38 | #ifndef __KERNEL__ | 
|  | 39 | typedef __u64 __fs64; | 
|  | 40 | typedef __u32 __fs32; | 
|  | 41 | typedef __u16 __fs16; | 
|  | 42 | #else | 
| Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 43 | #include <asm/div64.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | typedef __u64 __bitwise __fs64; | 
|  | 45 | typedef __u32 __bitwise __fs32; | 
|  | 46 | typedef __u16 __bitwise __fs16; | 
|  | 47 | #endif | 
|  | 48 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #define UFS_BBLOCK 0 | 
|  | 50 | #define UFS_BBSIZE 8192 | 
|  | 51 | #define UFS_SBLOCK 8192 | 
|  | 52 | #define UFS_SBSIZE 8192 | 
|  | 53 |  | 
|  | 54 | #define UFS_SECTOR_SIZE 512 | 
|  | 55 | #define UFS_SECTOR_BITS 9 | 
|  | 56 | #define UFS_MAGIC  0x00011954 | 
|  | 57 | #define UFS2_MAGIC 0x19540119 | 
|  | 58 | #define UFS_CIGAM  0x54190100 /* byteswapped MAGIC */ | 
|  | 59 |  | 
|  | 60 | /* Copied from FreeBSD */ | 
|  | 61 | /* | 
|  | 62 | * Each disk drive contains some number of filesystems. | 
|  | 63 | * A filesystem consists of a number of cylinder groups. | 
|  | 64 | * Each cylinder group has inodes and data. | 
|  | 65 | * | 
|  | 66 | * A filesystem is described by its super-block, which in turn | 
|  | 67 | * describes the cylinder groups.  The super-block is critical | 
|  | 68 | * data and is replicated in each cylinder group to protect against | 
|  | 69 | * catastrophic loss.  This is done at `newfs' time and the critical | 
|  | 70 | * super-block data does not change, so the copies need not be | 
|  | 71 | * referenced further unless disaster strikes. | 
|  | 72 | * | 
|  | 73 | * For filesystem fs, the offsets of the various blocks of interest | 
|  | 74 | * are given in the super block as: | 
|  | 75 | *      [fs->fs_sblkno]         Super-block | 
|  | 76 | *      [fs->fs_cblkno]         Cylinder group block | 
|  | 77 | *      [fs->fs_iblkno]         Inode blocks | 
|  | 78 | *      [fs->fs_dblkno]         Data blocks | 
|  | 79 | * The beginning of cylinder group cg in fs, is given by | 
|  | 80 | * the ``cgbase(fs, cg)'' macro. | 
|  | 81 | * | 
|  | 82 | * Depending on the architecture and the media, the superblock may | 
|  | 83 | * reside in any one of four places. For tiny media where every block | 
|  | 84 | * counts, it is placed at the very front of the partition. Historically, | 
|  | 85 | * UFS1 placed it 8K from the front to leave room for the disk label and | 
|  | 86 | * a small bootstrap. For UFS2 it got moved to 64K from the front to leave | 
|  | 87 | * room for the disk label and a bigger bootstrap, and for really piggy | 
|  | 88 | * systems we check at 256K from the front if the first three fail. In | 
|  | 89 | * all cases the size of the superblock will be SBLOCKSIZE. All values are | 
|  | 90 | * given in byte-offset form, so they do not imply a sector size. The | 
|  | 91 | * SBLOCKSEARCH specifies the order in which the locations should be searched. | 
|  | 92 | */ | 
|  | 93 | #define SBLOCK_FLOPPY        0 | 
|  | 94 | #define SBLOCK_UFS1       8192 | 
|  | 95 | #define SBLOCK_UFS2      65536 | 
|  | 96 | #define SBLOCK_PIGGY    262144 | 
|  | 97 | #define SBLOCKSIZE        8192 | 
|  | 98 | #define SBLOCKSEARCH \ | 
|  | 99 | { SBLOCK_UFS2, SBLOCK_UFS1, SBLOCK_FLOPPY, SBLOCK_PIGGY, -1 } | 
|  | 100 |  | 
|  | 101 |  | 
|  | 102 | /* HP specific MAGIC values */ | 
|  | 103 |  | 
|  | 104 | #define UFS_MAGIC_LFN   0x00095014 /* fs supports filenames > 14 chars */ | 
|  | 105 | #define UFS_CIGAM_LFN   0x14500900 /* srahc 41 < semanelif stroppus sf */ | 
|  | 106 |  | 
|  | 107 | #define UFS_MAGIC_SEC   0x00612195 /* B1 security fs */ | 
|  | 108 | #define UFS_CIGAM_SEC   0x95216100 | 
|  | 109 |  | 
|  | 110 | #define UFS_MAGIC_FEA   0x00195612 /* fs_featurebits supported */ | 
|  | 111 | #define UFS_CIGAM_FEA   0x12561900 | 
|  | 112 |  | 
|  | 113 | #define UFS_MAGIC_4GB   0x05231994 /* fs > 4 GB && fs_featurebits */ | 
|  | 114 | #define UFS_CIGAM_4GB   0x94192305 | 
|  | 115 |  | 
|  | 116 | /* Seems somebody at HP goofed here. B1 and lfs are both 0x2 !?! */ | 
|  | 117 | #define UFS_FSF_LFN     0x00000001 /* long file names */ | 
|  | 118 | #define UFS_FSF_B1      0x00000002 /* B1 security */ | 
|  | 119 | #define UFS_FSF_LFS     0x00000002 /* large files */ | 
|  | 120 | #define UFS_FSF_LUID    0x00000004 /* large UIDs */ | 
|  | 121 |  | 
|  | 122 | /* End of HP stuff */ | 
|  | 123 |  | 
|  | 124 |  | 
|  | 125 | #define UFS_BSIZE	8192 | 
|  | 126 | #define UFS_MINBSIZE	4096 | 
|  | 127 | #define UFS_FSIZE	1024 | 
|  | 128 | #define UFS_MAXFRAG	(UFS_BSIZE / UFS_FSIZE) | 
|  | 129 |  | 
|  | 130 | #define UFS_NDADDR 12 | 
|  | 131 | #define UFS_NINDIR 3 | 
|  | 132 |  | 
|  | 133 | #define UFS_IND_BLOCK	(UFS_NDADDR + 0) | 
|  | 134 | #define UFS_DIND_BLOCK	(UFS_NDADDR + 1) | 
|  | 135 | #define UFS_TIND_BLOCK	(UFS_NDADDR + 2) | 
|  | 136 |  | 
|  | 137 | #define UFS_NDIR_FRAGMENT (UFS_NDADDR << uspi->s_fpbshift) | 
|  | 138 | #define UFS_IND_FRAGMENT (UFS_IND_BLOCK << uspi->s_fpbshift) | 
|  | 139 | #define UFS_DIND_FRAGMENT (UFS_DIND_BLOCK << uspi->s_fpbshift) | 
|  | 140 | #define UFS_TIND_FRAGMENT (UFS_TIND_BLOCK << uspi->s_fpbshift) | 
|  | 141 |  | 
|  | 142 | #define UFS_ROOTINO 2 | 
|  | 143 | #define UFS_FIRST_INO (UFS_ROOTINO + 1) | 
|  | 144 |  | 
|  | 145 | #define UFS_USEEFT  ((__u16)65535) | 
|  | 146 |  | 
|  | 147 | #define UFS_FSOK      0x7c269d38 | 
| Andreas Schwab | 9d923a0 | 2006-02-03 03:04:12 -0800 | [diff] [blame] | 148 | #define UFS_FSACTIVE  ((__s8)0x00) | 
|  | 149 | #define UFS_FSCLEAN   ((__s8)0x01) | 
|  | 150 | #define UFS_FSSTABLE  ((__s8)0x02) | 
|  | 151 | #define UFS_FSOSF1    ((__s8)0x03)	/* is this correct for DEC OSF/1? */ | 
|  | 152 | #define UFS_FSBAD     ((__s8)0xff) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 |  | 
|  | 154 | /* From here to next blank line, s_flags for ufs_sb_info */ | 
|  | 155 | /* directory entry encoding */ | 
|  | 156 | #define UFS_DE_MASK		0x00000010	/* mask for the following */ | 
|  | 157 | #define UFS_DE_OLD		0x00000000 | 
|  | 158 | #define UFS_DE_44BSD		0x00000010 | 
|  | 159 | /* uid encoding */ | 
|  | 160 | #define UFS_UID_MASK		0x00000060	/* mask for the following */ | 
|  | 161 | #define UFS_UID_OLD		0x00000000 | 
|  | 162 | #define UFS_UID_44BSD		0x00000020 | 
|  | 163 | #define UFS_UID_EFT		0x00000040 | 
|  | 164 | /* superblock state encoding */ | 
|  | 165 | #define UFS_ST_MASK		0x00000700	/* mask for the following */ | 
|  | 166 | #define UFS_ST_OLD		0x00000000 | 
|  | 167 | #define UFS_ST_44BSD		0x00000100 | 
| Mark Fortescue | 252e211 | 2007-10-16 23:26:31 -0700 | [diff] [blame] | 168 | #define UFS_ST_SUN		0x00000200 /* Solaris */ | 
|  | 169 | #define UFS_ST_SUNOS		0x00000300 | 
|  | 170 | #define UFS_ST_SUNx86		0x00000400 /* Solaris x86 */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | /*cylinder group encoding */ | 
|  | 172 | #define UFS_CG_MASK		0x00003000	/* mask for the following */ | 
|  | 173 | #define UFS_CG_OLD		0x00000000 | 
|  | 174 | #define UFS_CG_44BSD		0x00002000 | 
|  | 175 | #define UFS_CG_SUN		0x00001000 | 
|  | 176 | /* filesystem type encoding */ | 
|  | 177 | #define UFS_TYPE_MASK		0x00010000	/* mask for the following */ | 
|  | 178 | #define UFS_TYPE_UFS1		0x00000000 | 
|  | 179 | #define UFS_TYPE_UFS2		0x00010000 | 
|  | 180 |  | 
|  | 181 |  | 
|  | 182 | /* fs_inodefmt options */ | 
|  | 183 | #define UFS_42INODEFMT	-1 | 
|  | 184 | #define UFS_44INODEFMT	2 | 
|  | 185 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | /* | 
|  | 187 | * MINFREE gives the minimum acceptable percentage of file system | 
|  | 188 | * blocks which may be free. If the freelist drops below this level | 
|  | 189 | * only the superuser may continue to allocate blocks. This may | 
|  | 190 | * be set to 0 if no reserve of free blocks is deemed necessary, | 
|  | 191 | * however throughput drops by fifty percent if the file system | 
|  | 192 | * is run at between 95% and 100% full; thus the minimum default | 
|  | 193 | * value of fs_minfree is 5%. However, to get good clustering | 
|  | 194 | * performance, 10% is a better choice. hence we use 10% as our | 
|  | 195 | * default value. With 10% free space, fragmentation is not a | 
|  | 196 | * problem, so we choose to optimize for time. | 
|  | 197 | */ | 
|  | 198 | #define UFS_MINFREE         5 | 
|  | 199 | #define UFS_DEFAULTOPT      UFS_OPTTIME | 
|  | 200 |  | 
|  | 201 | /* | 
|  | 202 | * Turn file system block numbers into disk block addresses. | 
|  | 203 | * This maps file system blocks to device size blocks. | 
|  | 204 | */ | 
|  | 205 | #define ufs_fsbtodb(uspi, b)	((b) << (uspi)->s_fsbtodb) | 
|  | 206 | #define	ufs_dbtofsb(uspi, b)	((b) >> (uspi)->s_fsbtodb) | 
|  | 207 |  | 
|  | 208 | /* | 
|  | 209 | * Cylinder group macros to locate things in cylinder groups. | 
|  | 210 | * They calc file system addresses of cylinder group data structures. | 
|  | 211 | */ | 
|  | 212 | #define	ufs_cgbase(c)	(uspi->s_fpg * (c)) | 
|  | 213 | #define ufs_cgstart(c)	((uspi)->fs_magic == UFS2_MAGIC ?  ufs_cgbase(c) : \ | 
|  | 214 | (ufs_cgbase(c)  + uspi->s_cgoffset * ((c) & ~uspi->s_cgmask))) | 
|  | 215 | #define	ufs_cgsblock(c)	(ufs_cgstart(c) + uspi->s_sblkno)	/* super blk */ | 
|  | 216 | #define	ufs_cgcmin(c)	(ufs_cgstart(c) + uspi->s_cblkno)	/* cg block */ | 
|  | 217 | #define	ufs_cgimin(c)	(ufs_cgstart(c) + uspi->s_iblkno)	/* inode blk */ | 
|  | 218 | #define	ufs_cgdmin(c)	(ufs_cgstart(c) + uspi->s_dblkno)	/* 1st data */ | 
|  | 219 |  | 
|  | 220 | /* | 
|  | 221 | * Macros for handling inode numbers: | 
|  | 222 | *     inode number to file system block offset. | 
|  | 223 | *     inode number to cylinder group number. | 
|  | 224 | *     inode number to file system block address. | 
|  | 225 | */ | 
|  | 226 | #define	ufs_inotocg(x)		((x) / uspi->s_ipg) | 
|  | 227 | #define	ufs_inotocgoff(x)	((x) % uspi->s_ipg) | 
| Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 228 | #define	ufs_inotofsba(x)	(((u64)ufs_cgimin(ufs_inotocg(x))) + ufs_inotocgoff(x) / uspi->s_inopf) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | #define	ufs_inotofsbo(x)	((x) % uspi->s_inopf) | 
|  | 230 |  | 
|  | 231 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | * Compute the cylinder and rotational position of a cyl block addr. | 
|  | 233 | */ | 
|  | 234 | #define ufs_cbtocylno(bno) \ | 
|  | 235 | ((bno) * uspi->s_nspf / uspi->s_spc) | 
|  | 236 | #define ufs_cbtorpos(bno) \ | 
|  | 237 | ((((bno) * uspi->s_nspf % uspi->s_spc / uspi->s_nsect \ | 
|  | 238 | * uspi->s_trackskew + (bno) * uspi->s_nspf % uspi->s_spc \ | 
|  | 239 | % uspi->s_nsect * uspi->s_interleave) % uspi->s_nsect \ | 
|  | 240 | * uspi->s_nrpos) / uspi->s_npsect) | 
|  | 241 |  | 
|  | 242 | /* | 
|  | 243 | * The following macros optimize certain frequently calculated | 
|  | 244 | * quantities by using shifts and masks in place of divisions | 
|  | 245 | * modulos and multiplications. | 
|  | 246 | */ | 
|  | 247 | #define ufs_blkoff(loc)		((loc) & uspi->s_qbmask) | 
|  | 248 | #define ufs_fragoff(loc)	((loc) & uspi->s_qfmask) | 
|  | 249 | #define ufs_lblktosize(blk)	((blk) << uspi->s_bshift) | 
|  | 250 | #define ufs_lblkno(loc)		((loc) >> uspi->s_bshift) | 
|  | 251 | #define ufs_numfrags(loc)	((loc) >> uspi->s_fshift) | 
|  | 252 | #define ufs_blkroundup(size)	(((size) + uspi->s_qbmask) & uspi->s_bmask) | 
|  | 253 | #define ufs_fragroundup(size)	(((size) + uspi->s_qfmask) & uspi->s_fmask) | 
|  | 254 | #define ufs_fragstoblks(frags)	((frags) >> uspi->s_fpbshift) | 
|  | 255 | #define ufs_blkstofrags(blks)	((blks) << uspi->s_fpbshift) | 
|  | 256 | #define ufs_fragnum(fsb)	((fsb) & uspi->s_fpbmask) | 
|  | 257 | #define ufs_blknum(fsb)		((fsb) & ~uspi->s_fpbmask) | 
|  | 258 |  | 
|  | 259 | #define	UFS_MAXNAMLEN 255 | 
|  | 260 | #define UFS_MAXMNTLEN 512 | 
|  | 261 | #define UFS2_MAXMNTLEN 468 | 
|  | 262 | #define UFS2_MAXVOLLEN 32 | 
| Mike Frysinger | eb58570 | 2007-02-12 00:52:27 -0800 | [diff] [blame] | 263 | #define UFS_MAXCSBUFS 31 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | #define UFS_LINK_MAX 32000 | 
|  | 265 | /* | 
|  | 266 | #define	UFS2_NOCSPTRS	((128 / sizeof(void *)) - 4) | 
|  | 267 | */ | 
|  | 268 | #define	UFS2_NOCSPTRS	28 | 
|  | 269 |  | 
|  | 270 | /* | 
|  | 271 | * UFS_DIR_PAD defines the directory entries boundaries | 
|  | 272 | * (must be a multiple of 4) | 
|  | 273 | */ | 
|  | 274 | #define UFS_DIR_PAD			4 | 
|  | 275 | #define UFS_DIR_ROUND			(UFS_DIR_PAD - 1) | 
|  | 276 | #define UFS_DIR_REC_LEN(name_len)	(((name_len) + 1 + 8 + UFS_DIR_ROUND) & ~UFS_DIR_ROUND) | 
|  | 277 |  | 
|  | 278 | struct ufs_timeval { | 
|  | 279 | __fs32	tv_sec; | 
|  | 280 | __fs32	tv_usec; | 
|  | 281 | }; | 
|  | 282 |  | 
|  | 283 | struct ufs_dir_entry { | 
|  | 284 | __fs32  d_ino;			/* inode number of this entry */ | 
|  | 285 | __fs16  d_reclen;		/* length of this entry */ | 
|  | 286 | union { | 
|  | 287 | __fs16	d_namlen;		/* actual length of d_name */ | 
|  | 288 | struct { | 
|  | 289 | __u8	d_type;		/* file type */ | 
|  | 290 | __u8	d_namlen;	/* length of string in d_name */ | 
|  | 291 | } d_44; | 
|  | 292 | } d_u; | 
|  | 293 | __u8	d_name[UFS_MAXNAMLEN + 1];	/* file name */ | 
|  | 294 | }; | 
|  | 295 |  | 
|  | 296 | struct ufs_csum { | 
|  | 297 | __fs32	cs_ndir;	/* number of directories */ | 
|  | 298 | __fs32	cs_nbfree;	/* number of free blocks */ | 
|  | 299 | __fs32	cs_nifree;	/* number of free inodes */ | 
|  | 300 | __fs32	cs_nffree;	/* number of free frags */ | 
|  | 301 | }; | 
|  | 302 | struct ufs2_csum_total { | 
|  | 303 | __fs64	cs_ndir;	/* number of directories */ | 
|  | 304 | __fs64	cs_nbfree;	/* number of free blocks */ | 
|  | 305 | __fs64	cs_nifree;	/* number of free inodes */ | 
|  | 306 | __fs64	cs_nffree;	/* number of free frags */ | 
|  | 307 | __fs64   cs_numclusters;	/* number of free clusters */ | 
|  | 308 | __fs64   cs_spare[3];	/* future expansion */ | 
|  | 309 | }; | 
|  | 310 |  | 
| Al Viro | 44aa535 | 2006-08-13 01:54:30 -0400 | [diff] [blame] | 311 | struct ufs_csum_core { | 
|  | 312 | __u64	cs_ndir;	/* number of directories */ | 
|  | 313 | __u64	cs_nbfree;	/* number of free blocks */ | 
|  | 314 | __u64	cs_nifree;	/* number of free inodes */ | 
|  | 315 | __u64	cs_nffree;	/* number of free frags */ | 
|  | 316 | __u64   cs_numclusters;	/* number of free clusters */ | 
|  | 317 | }; | 
|  | 318 |  | 
| Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 319 | /* | 
|  | 320 | * File system flags | 
|  | 321 | */ | 
|  | 322 | #define UFS_UNCLEAN      0x01    /* file system not clean at mount (unused) */ | 
|  | 323 | #define UFS_DOSOFTDEP    0x02    /* file system using soft dependencies */ | 
|  | 324 | #define UFS_NEEDSFSCK    0x04    /* needs sync fsck (FreeBSD compat, unused) */ | 
|  | 325 | #define UFS_INDEXDIRS    0x08    /* kernel supports indexed directories */ | 
|  | 326 | #define UFS_ACLS         0x10    /* file system has ACLs enabled */ | 
|  | 327 | #define UFS_MULTILABEL   0x20    /* file system is MAC multi-label */ | 
|  | 328 | #define UFS_FLAGS_UPDATED 0x80   /* flags have been moved to new location */ | 
|  | 329 |  | 
| Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 330 | #if 0 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | /* | 
|  | 332 | * This is the actual superblock, as it is laid out on the disk. | 
| Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 333 | * Do NOT use this structure, because of sizeof(ufs_super_block) > 512 and | 
|  | 334 | * it may occupy several blocks, use | 
|  | 335 | * struct ufs_super_block_(first,second,third) instead. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | */ | 
|  | 337 | struct ufs_super_block { | 
| Mark Fortescue | 252e211 | 2007-10-16 23:26:31 -0700 | [diff] [blame] | 338 | union { | 
|  | 339 | struct { | 
|  | 340 | __fs32	fs_link;	/* UNUSED */ | 
|  | 341 | } fs_42; | 
|  | 342 | struct { | 
|  | 343 | __fs32	fs_state;	/* file system state flag */ | 
|  | 344 | } fs_sun; | 
|  | 345 | } fs_u0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | __fs32	fs_rlink;	/* UNUSED */ | 
|  | 347 | __fs32	fs_sblkno;	/* addr of super-block in filesys */ | 
|  | 348 | __fs32	fs_cblkno;	/* offset of cyl-block in filesys */ | 
|  | 349 | __fs32	fs_iblkno;	/* offset of inode-blocks in filesys */ | 
|  | 350 | __fs32	fs_dblkno;	/* offset of first data after cg */ | 
|  | 351 | __fs32	fs_cgoffset;	/* cylinder group offset in cylinder */ | 
|  | 352 | __fs32	fs_cgmask;	/* used to calc mod fs_ntrak */ | 
|  | 353 | __fs32	fs_time;	/* last time written -- time_t */ | 
|  | 354 | __fs32	fs_size;	/* number of blocks in fs */ | 
|  | 355 | __fs32	fs_dsize;	/* number of data blocks in fs */ | 
|  | 356 | __fs32	fs_ncg;		/* number of cylinder groups */ | 
|  | 357 | __fs32	fs_bsize;	/* size of basic blocks in fs */ | 
|  | 358 | __fs32	fs_fsize;	/* size of frag blocks in fs */ | 
|  | 359 | __fs32	fs_frag;	/* number of frags in a block in fs */ | 
|  | 360 | /* these are configuration parameters */ | 
|  | 361 | __fs32	fs_minfree;	/* minimum percentage of free blocks */ | 
|  | 362 | __fs32	fs_rotdelay;	/* num of ms for optimal next block */ | 
|  | 363 | __fs32	fs_rps;		/* disk revolutions per second */ | 
|  | 364 | /* these fields can be computed from the others */ | 
|  | 365 | __fs32	fs_bmask;	/* ``blkoff'' calc of blk offsets */ | 
|  | 366 | __fs32	fs_fmask;	/* ``fragoff'' calc of frag offsets */ | 
|  | 367 | __fs32	fs_bshift;	/* ``lblkno'' calc of logical blkno */ | 
|  | 368 | __fs32	fs_fshift;	/* ``numfrags'' calc number of frags */ | 
|  | 369 | /* these are configuration parameters */ | 
|  | 370 | __fs32	fs_maxcontig;	/* max number of contiguous blks */ | 
|  | 371 | __fs32	fs_maxbpg;	/* max number of blks per cyl group */ | 
|  | 372 | /* these fields can be computed from the others */ | 
|  | 373 | __fs32	fs_fragshift;	/* block to frag shift */ | 
|  | 374 | __fs32	fs_fsbtodb;	/* fsbtodb and dbtofsb shift constant */ | 
|  | 375 | __fs32	fs_sbsize;	/* actual size of super block */ | 
|  | 376 | __fs32	fs_csmask;	/* csum block offset */ | 
|  | 377 | __fs32	fs_csshift;	/* csum block number */ | 
|  | 378 | __fs32	fs_nindir;	/* value of NINDIR */ | 
|  | 379 | __fs32	fs_inopb;	/* value of INOPB */ | 
|  | 380 | __fs32	fs_nspf;	/* value of NSPF */ | 
|  | 381 | /* yet another configuration parameter */ | 
|  | 382 | __fs32	fs_optim;	/* optimization preference, see below */ | 
|  | 383 | /* these fields are derived from the hardware */ | 
|  | 384 | union { | 
|  | 385 | struct { | 
|  | 386 | __fs32	fs_npsect;	/* # sectors/track including spares */ | 
|  | 387 | } fs_sun; | 
|  | 388 | struct { | 
|  | 389 | __fs32	fs_state;	/* file system state time stamp */ | 
|  | 390 | } fs_sunx86; | 
|  | 391 | } fs_u1; | 
|  | 392 | __fs32	fs_interleave;	/* hardware sector interleave */ | 
|  | 393 | __fs32	fs_trackskew;	/* sector 0 skew, per track */ | 
|  | 394 | /* a unique id for this filesystem (currently unused and unmaintained) */ | 
|  | 395 | /* In 4.3 Tahoe this space is used by fs_headswitch and fs_trkseek */ | 
|  | 396 | /* Neither of those fields is used in the Tahoe code right now but */ | 
|  | 397 | /* there could be problems if they are.                            */ | 
|  | 398 | __fs32	fs_id[2];	/* file system id */ | 
|  | 399 | /* sizes determined by number of cylinder groups and their sizes */ | 
|  | 400 | __fs32	fs_csaddr;	/* blk addr of cyl grp summary area */ | 
|  | 401 | __fs32	fs_cssize;	/* size of cyl grp summary area */ | 
|  | 402 | __fs32	fs_cgsize;	/* cylinder group size */ | 
|  | 403 | /* these fields are derived from the hardware */ | 
|  | 404 | __fs32	fs_ntrak;	/* tracks per cylinder */ | 
|  | 405 | __fs32	fs_nsect;	/* sectors per track */ | 
|  | 406 | __fs32	fs_spc;		/* sectors per cylinder */ | 
|  | 407 | /* this comes from the disk driver partitioning */ | 
|  | 408 | __fs32	fs_ncyl;	/* cylinders in file system */ | 
|  | 409 | /* these fields can be computed from the others */ | 
|  | 410 | __fs32	fs_cpg;		/* cylinders per group */ | 
|  | 411 | __fs32	fs_ipg;		/* inodes per cylinder group */ | 
|  | 412 | __fs32	fs_fpg;		/* blocks per group * fs_frag */ | 
|  | 413 | /* this data must be re-computed after crashes */ | 
|  | 414 | struct ufs_csum fs_cstotal;	/* cylinder summary information */ | 
|  | 415 | /* these fields are cleared at mount time */ | 
|  | 416 | __s8	fs_fmod;	/* super block modified flag */ | 
|  | 417 | __s8	fs_clean;	/* file system is clean flag */ | 
|  | 418 | __s8	fs_ronly;	/* mounted read-only flag */ | 
| Evgeniy Dushistov | ee3ffd6 | 2006-06-25 05:47:30 -0700 | [diff] [blame] | 419 | __s8	fs_flags; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | union { | 
|  | 421 | struct { | 
|  | 422 | __s8	fs_fsmnt[UFS_MAXMNTLEN];/* name mounted on */ | 
|  | 423 | __fs32	fs_cgrotor;	/* last cg searched */ | 
|  | 424 | __fs32	fs_csp[UFS_MAXCSBUFS];/*list of fs_cs info buffers */ | 
|  | 425 | __fs32	fs_maxcluster; | 
|  | 426 | __fs32	fs_cpc;		/* cyl per cycle in postbl */ | 
|  | 427 | __fs16	fs_opostbl[16][8]; /* old rotation block list head */ | 
|  | 428 | } fs_u1; | 
|  | 429 | struct { | 
|  | 430 | __s8  fs_fsmnt[UFS2_MAXMNTLEN];	/* name mounted on */ | 
|  | 431 | __u8   fs_volname[UFS2_MAXVOLLEN]; /* volume name */ | 
|  | 432 | __fs64  fs_swuid;		/* system-wide uid */ | 
|  | 433 | __fs32  fs_pad;	/* due to alignment of fs_swuid */ | 
|  | 434 | __fs32   fs_cgrotor;     /* last cg searched */ | 
|  | 435 | __fs32   fs_ocsp[UFS2_NOCSPTRS]; /*list of fs_cs info buffers */ | 
|  | 436 | __fs32   fs_contigdirs;/*# of contiguously allocated dirs */ | 
|  | 437 | __fs32   fs_csp;	/* cg summary info buffer for fs_cs */ | 
|  | 438 | __fs32   fs_maxcluster; | 
|  | 439 | __fs32   fs_active;/* used by snapshots to track fs */ | 
|  | 440 | __fs32   fs_old_cpc;	/* cyl per cycle in postbl */ | 
|  | 441 | __fs32   fs_maxbsize;/*maximum blocking factor permitted */ | 
|  | 442 | __fs64   fs_sparecon64[17];/*old rotation block list head */ | 
|  | 443 | __fs64   fs_sblockloc; /* byte offset of standard superblock */ | 
|  | 444 | struct  ufs2_csum_total fs_cstotal;/*cylinder summary information*/ | 
|  | 445 | struct  ufs_timeval    fs_time;		/* last time written */ | 
|  | 446 | __fs64    fs_size;		/* number of blocks in fs */ | 
|  | 447 | __fs64    fs_dsize;	/* number of data blocks in fs */ | 
|  | 448 | __fs64   fs_csaddr;	/* blk addr of cyl grp summary area */ | 
|  | 449 | __fs64    fs_pendingblocks;/* blocks in process of being freed */ | 
|  | 450 | __fs32    fs_pendinginodes;/*inodes in process of being freed */ | 
|  | 451 | } fs_u2; | 
|  | 452 | }  fs_u11; | 
|  | 453 | union { | 
|  | 454 | struct { | 
|  | 455 | __fs32	fs_sparecon[53];/* reserved for future constants */ | 
|  | 456 | __fs32	fs_reclaim; | 
|  | 457 | __fs32	fs_sparecon2[1]; | 
|  | 458 | __fs32	fs_state;	/* file system state time stamp */ | 
|  | 459 | __fs32	fs_qbmask[2];	/* ~usb_bmask */ | 
|  | 460 | __fs32	fs_qfmask[2];	/* ~usb_fmask */ | 
|  | 461 | } fs_sun; | 
|  | 462 | struct { | 
|  | 463 | __fs32	fs_sparecon[53];/* reserved for future constants */ | 
|  | 464 | __fs32	fs_reclaim; | 
|  | 465 | __fs32	fs_sparecon2[1]; | 
|  | 466 | __fs32	fs_npsect;	/* # sectors/track including spares */ | 
|  | 467 | __fs32	fs_qbmask[2];	/* ~usb_bmask */ | 
|  | 468 | __fs32	fs_qfmask[2];	/* ~usb_fmask */ | 
|  | 469 | } fs_sunx86; | 
|  | 470 | struct { | 
|  | 471 | __fs32	fs_sparecon[50];/* reserved for future constants */ | 
|  | 472 | __fs32	fs_contigsumsize;/* size of cluster summary array */ | 
|  | 473 | __fs32	fs_maxsymlinklen;/* max length of an internal symlink */ | 
|  | 474 | __fs32	fs_inodefmt;	/* format of on-disk inodes */ | 
|  | 475 | __fs32	fs_maxfilesize[2];	/* max representable file size */ | 
|  | 476 | __fs32	fs_qbmask[2];	/* ~usb_bmask */ | 
|  | 477 | __fs32	fs_qfmask[2];	/* ~usb_fmask */ | 
|  | 478 | __fs32	fs_state;	/* file system state time stamp */ | 
|  | 479 | } fs_44; | 
|  | 480 | } fs_u2; | 
|  | 481 | __fs32	fs_postblformat;	/* format of positional layout tables */ | 
|  | 482 | __fs32	fs_nrpos;		/* number of rotational positions */ | 
|  | 483 | __fs32	fs_postbloff;		/* (__s16) rotation block list head */ | 
|  | 484 | __fs32	fs_rotbloff;		/* (__u8) blocks for each rotation */ | 
|  | 485 | __fs32	fs_magic;		/* magic number */ | 
|  | 486 | __u8	fs_space[1];		/* list of blocks for each rotation */ | 
|  | 487 | }; | 
| Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 488 | #endif/*struct ufs_super_block*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 |  | 
|  | 490 | /* | 
|  | 491 | * Preference for optimization. | 
|  | 492 | */ | 
|  | 493 | #define UFS_OPTTIME	0	/* minimize allocation time */ | 
|  | 494 | #define UFS_OPTSPACE	1	/* minimize disk fragmentation */ | 
|  | 495 |  | 
|  | 496 | /* | 
|  | 497 | * Rotational layout table format types | 
|  | 498 | */ | 
|  | 499 | #define UFS_42POSTBLFMT		-1	/* 4.2BSD rotational table format */ | 
|  | 500 | #define UFS_DYNAMICPOSTBLFMT	1	/* dynamic rotational table format */ | 
|  | 501 |  | 
|  | 502 | /* | 
|  | 503 | * Convert cylinder group to base address of its global summary info. | 
|  | 504 | */ | 
| Evgeniy Dushistov | e295cfc | 2006-02-03 03:04:04 -0800 | [diff] [blame] | 505 | #define fs_cs(indx) s_csp[(indx)] | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 |  | 
|  | 507 | /* | 
|  | 508 | * Cylinder group block for a file system. | 
|  | 509 | * | 
|  | 510 | * Writable fields in the cylinder group are protected by the associated | 
|  | 511 | * super block lock fs->fs_lock. | 
|  | 512 | */ | 
|  | 513 | #define	CG_MAGIC	0x090255 | 
|  | 514 | #define ufs_cg_chkmagic(sb, ucg) \ | 
|  | 515 | (fs32_to_cpu((sb), (ucg)->cg_magic) == CG_MAGIC) | 
| Mark Fortescue | 252e211 | 2007-10-16 23:26:31 -0700 | [diff] [blame] | 516 | /* | 
|  | 517 | * Macros for access to old cylinder group array structures | 
|  | 518 | */ | 
|  | 519 | #define ufs_ocg_blktot(sb, ucg)      fs32_to_cpu((sb), ((struct ufs_old_cylinder_group *)(ucg))->cg_btot) | 
|  | 520 | #define ufs_ocg_blks(sb, ucg, cylno) fs32_to_cpu((sb), ((struct ufs_old_cylinder_group *)(ucg))->cg_b[cylno]) | 
|  | 521 | #define ufs_ocg_inosused(sb, ucg)    fs32_to_cpu((sb), ((struct ufs_old_cylinder_group *)(ucg))->cg_iused) | 
|  | 522 | #define ufs_ocg_blksfree(sb, ucg)    fs32_to_cpu((sb), ((struct ufs_old_cylinder_group *)(ucg))->cg_free) | 
|  | 523 | #define ufs_ocg_chkmagic(sb, ucg) \ | 
|  | 524 | (fs32_to_cpu((sb), ((struct ufs_old_cylinder_group *)(ucg))->cg_magic) == CG_MAGIC) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 |  | 
|  | 526 | /* | 
|  | 527 | * size of this structure is 172 B | 
|  | 528 | */ | 
|  | 529 | struct	ufs_cylinder_group { | 
|  | 530 | __fs32	cg_link;		/* linked list of cyl groups */ | 
|  | 531 | __fs32	cg_magic;		/* magic number */ | 
|  | 532 | __fs32	cg_time;		/* time last written */ | 
|  | 533 | __fs32	cg_cgx;			/* we are the cgx'th cylinder group */ | 
|  | 534 | __fs16	cg_ncyl;		/* number of cyl's this cg */ | 
|  | 535 | __fs16	cg_niblk;		/* number of inode blocks this cg */ | 
|  | 536 | __fs32	cg_ndblk;		/* number of data blocks this cg */ | 
|  | 537 | struct	ufs_csum cg_cs;		/* cylinder summary information */ | 
|  | 538 | __fs32	cg_rotor;		/* position of last used block */ | 
|  | 539 | __fs32	cg_frotor;		/* position of last used frag */ | 
|  | 540 | __fs32	cg_irotor;		/* position of last used inode */ | 
|  | 541 | __fs32	cg_frsum[UFS_MAXFRAG];	/* counts of available frags */ | 
|  | 542 | __fs32	cg_btotoff;		/* (__u32) block totals per cylinder */ | 
|  | 543 | __fs32	cg_boff;		/* (short) free block positions */ | 
|  | 544 | __fs32	cg_iusedoff;		/* (char) used inode map */ | 
|  | 545 | __fs32	cg_freeoff;		/* (u_char) free block map */ | 
|  | 546 | __fs32	cg_nextfreeoff;		/* (u_char) next available space */ | 
|  | 547 | union { | 
|  | 548 | struct { | 
|  | 549 | __fs32	cg_clustersumoff;	/* (u_int32) counts of avail clusters */ | 
|  | 550 | __fs32	cg_clusteroff;		/* (u_int8) free cluster map */ | 
|  | 551 | __fs32	cg_nclusterblks;	/* number of clusters this cg */ | 
|  | 552 | __fs32	cg_sparecon[13];	/* reserved for future use */ | 
|  | 553 | } cg_44; | 
|  | 554 | struct { | 
|  | 555 | __fs32	cg_clustersumoff;/* (u_int32) counts of avail clusters */ | 
|  | 556 | __fs32	cg_clusteroff;	/* (u_int8) free cluster map */ | 
|  | 557 | __fs32	cg_nclusterblks;/* number of clusters this cg */ | 
|  | 558 | __fs32   cg_niblk; /* number of inode blocks this cg */ | 
|  | 559 | __fs32   cg_initediblk;	/* last initialized inode */ | 
|  | 560 | __fs32   cg_sparecon32[3];/* reserved for future use */ | 
|  | 561 | __fs64   cg_time;	/* time last written */ | 
|  | 562 | __fs64	cg_sparecon[3];	/* reserved for future use */ | 
|  | 563 | } cg_u2; | 
|  | 564 | __fs32	cg_sparecon[16];	/* reserved for future use */ | 
|  | 565 | } cg_u; | 
|  | 566 | __u8	cg_space[1];		/* space for cylinder group maps */ | 
|  | 567 | /* actually longer */ | 
|  | 568 | }; | 
|  | 569 |  | 
| Mark Fortescue | 252e211 | 2007-10-16 23:26:31 -0700 | [diff] [blame] | 570 | /* Historic Cylinder group info */ | 
|  | 571 | struct ufs_old_cylinder_group { | 
|  | 572 | __fs32	cg_link;		/* linked list of cyl groups */ | 
|  | 573 | __fs32	cg_rlink;		/* for incore cyl groups     */ | 
|  | 574 | __fs32	cg_time;		/* time last written */ | 
|  | 575 | __fs32	cg_cgx;			/* we are the cgx'th cylinder group */ | 
|  | 576 | __fs16	cg_ncyl;		/* number of cyl's this cg */ | 
|  | 577 | __fs16	cg_niblk;		/* number of inode blocks this cg */ | 
|  | 578 | __fs32	cg_ndblk;		/* number of data blocks this cg */ | 
|  | 579 | struct	ufs_csum cg_cs;		/* cylinder summary information */ | 
|  | 580 | __fs32	cg_rotor;		/* position of last used block */ | 
|  | 581 | __fs32	cg_frotor;		/* position of last used frag */ | 
|  | 582 | __fs32	cg_irotor;		/* position of last used inode */ | 
|  | 583 | __fs32	cg_frsum[8];		/* counts of available frags */ | 
|  | 584 | __fs32	cg_btot[32];		/* block totals per cylinder */ | 
|  | 585 | __fs16	cg_b[32][8];		/* positions of free blocks */ | 
|  | 586 | __u8	cg_iused[256];		/* used inode map */ | 
|  | 587 | __fs32	cg_magic;		/* magic number */ | 
|  | 588 | __u8	cg_free[1];		/* free block map */ | 
|  | 589 | /* actually longer */ | 
|  | 590 | }; | 
|  | 591 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | /* | 
|  | 593 | * structure of an on-disk inode | 
|  | 594 | */ | 
|  | 595 | struct ufs_inode { | 
|  | 596 | __fs16	ui_mode;		/*  0x0 */ | 
|  | 597 | __fs16	ui_nlink;		/*  0x2 */ | 
|  | 598 | union { | 
|  | 599 | struct { | 
|  | 600 | __fs16	ui_suid;	/*  0x4 */ | 
|  | 601 | __fs16	ui_sgid;	/*  0x6 */ | 
|  | 602 | } oldids; | 
|  | 603 | __fs32	ui_inumber;		/*  0x4 lsf: inode number */ | 
|  | 604 | __fs32	ui_author;		/*  0x4 GNU HURD: author */ | 
|  | 605 | } ui_u1; | 
|  | 606 | __fs64	ui_size;		/*  0x8 */ | 
|  | 607 | struct ufs_timeval ui_atime;	/* 0x10 access */ | 
|  | 608 | struct ufs_timeval ui_mtime;	/* 0x18 modification */ | 
|  | 609 | struct ufs_timeval ui_ctime;	/* 0x20 creation */ | 
|  | 610 | union { | 
|  | 611 | struct { | 
|  | 612 | __fs32	ui_db[UFS_NDADDR];/* 0x28 data blocks */ | 
|  | 613 | __fs32	ui_ib[UFS_NINDIR];/* 0x58 indirect blocks */ | 
|  | 614 | } ui_addr; | 
|  | 615 | __u8	ui_symlink[4*(UFS_NDADDR+UFS_NINDIR)];/* 0x28 fast symlink */ | 
|  | 616 | } ui_u2; | 
|  | 617 | __fs32	ui_flags;		/* 0x64 immutable, append-only... */ | 
|  | 618 | __fs32	ui_blocks;		/* 0x68 blocks in use */ | 
|  | 619 | __fs32	ui_gen;			/* 0x6c like ext2 i_version, for NFS support */ | 
|  | 620 | union { | 
|  | 621 | struct { | 
|  | 622 | __fs32	ui_shadow;	/* 0x70 shadow inode with security data */ | 
|  | 623 | __fs32	ui_uid;		/* 0x74 long EFT version of uid */ | 
|  | 624 | __fs32	ui_gid;		/* 0x78 long EFT version of gid */ | 
|  | 625 | __fs32	ui_oeftflag;	/* 0x7c reserved */ | 
|  | 626 | } ui_sun; | 
|  | 627 | struct { | 
|  | 628 | __fs32	ui_uid;		/* 0x70 File owner */ | 
|  | 629 | __fs32	ui_gid;		/* 0x74 File group */ | 
|  | 630 | __fs32	ui_spare[2];	/* 0x78 reserved */ | 
|  | 631 | } ui_44; | 
|  | 632 | struct { | 
|  | 633 | __fs32	ui_uid;		/* 0x70 */ | 
|  | 634 | __fs32	ui_gid;		/* 0x74 */ | 
|  | 635 | __fs16	ui_modeh;	/* 0x78 mode high bits */ | 
|  | 636 | __fs16	ui_spare;	/* 0x7A unused */ | 
|  | 637 | __fs32	ui_trans;	/* 0x7c filesystem translator */ | 
|  | 638 | } ui_hurd; | 
|  | 639 | } ui_u3; | 
|  | 640 | }; | 
|  | 641 |  | 
|  | 642 | #define UFS_NXADDR  2            /* External addresses in inode. */ | 
|  | 643 | struct ufs2_inode { | 
|  | 644 | __fs16     ui_mode;        /*   0: IFMT, permissions; see below. */ | 
|  | 645 | __fs16     ui_nlink;       /*   2: File link count. */ | 
|  | 646 | __fs32     ui_uid;         /*   4: File owner. */ | 
|  | 647 | __fs32     ui_gid;         /*   8: File group. */ | 
|  | 648 | __fs32     ui_blksize;     /*  12: Inode blocksize. */ | 
|  | 649 | __fs64     ui_size;        /*  16: File byte count. */ | 
|  | 650 | __fs64     ui_blocks;      /*  24: Bytes actually held. */ | 
| Evgeniy Dushistov | 2189850 | 2007-03-16 13:38:07 -0800 | [diff] [blame] | 651 | __fs64   ui_atime;       /*  32: Last access time. */ | 
|  | 652 | __fs64   ui_mtime;       /*  40: Last modified time. */ | 
|  | 653 | __fs64   ui_ctime;       /*  48: Last inode change time. */ | 
|  | 654 | __fs64   ui_birthtime;   /*  56: Inode creation time. */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | __fs32     ui_mtimensec;   /*  64: Last modified time. */ | 
|  | 656 | __fs32     ui_atimensec;   /*  68: Last access time. */ | 
|  | 657 | __fs32     ui_ctimensec;   /*  72: Last inode change time. */ | 
|  | 658 | __fs32     ui_birthnsec;   /*  76: Inode creation time. */ | 
|  | 659 | __fs32     ui_gen;         /*  80: Generation number. */ | 
|  | 660 | __fs32     ui_kernflags;   /*  84: Kernel flags. */ | 
|  | 661 | __fs32     ui_flags;       /*  88: Status flags (chflags). */ | 
|  | 662 | __fs32     ui_extsize;     /*  92: External attributes block. */ | 
|  | 663 | __fs64     ui_extb[UFS_NXADDR];/*  96: External attributes block. */ | 
|  | 664 | union { | 
|  | 665 | struct { | 
|  | 666 | __fs64     ui_db[UFS_NDADDR]; /* 112: Direct disk blocks. */ | 
|  | 667 | __fs64     ui_ib[UFS_NINDIR];/* 208: Indirect disk blocks.*/ | 
|  | 668 | } ui_addr; | 
|  | 669 | __u8	ui_symlink[2*4*(UFS_NDADDR+UFS_NINDIR)];/* 0x28 fast symlink */ | 
|  | 670 | } ui_u2; | 
|  | 671 | __fs64     ui_spare[3];    /* 232: Reserved; currently unused */ | 
|  | 672 | }; | 
|  | 673 |  | 
|  | 674 |  | 
|  | 675 | /* FreeBSD has these in sys/stat.h */ | 
|  | 676 | /* ui_flags that can be set by a file owner */ | 
|  | 677 | #define UFS_UF_SETTABLE   0x0000ffff | 
|  | 678 | #define UFS_UF_NODUMP     0x00000001  /* do not dump */ | 
|  | 679 | #define UFS_UF_IMMUTABLE  0x00000002  /* immutable (can't "change") */ | 
|  | 680 | #define UFS_UF_APPEND     0x00000004  /* append-only */ | 
|  | 681 | #define UFS_UF_OPAQUE     0x00000008  /* directory is opaque (unionfs) */ | 
|  | 682 | #define UFS_UF_NOUNLINK   0x00000010  /* can't be removed or renamed */ | 
|  | 683 | /* ui_flags that only root can set */ | 
|  | 684 | #define UFS_SF_SETTABLE   0xffff0000 | 
|  | 685 | #define UFS_SF_ARCHIVED   0x00010000  /* archived */ | 
|  | 686 | #define UFS_SF_IMMUTABLE  0x00020000  /* immutable (can't "change") */ | 
|  | 687 | #define UFS_SF_APPEND     0x00040000  /* append-only */ | 
|  | 688 | #define UFS_SF_NOUNLINK   0x00100000  /* can't be removed or renamed */ | 
|  | 689 |  | 
|  | 690 | /* | 
|  | 691 | * This structure is used for reading disk structures larger | 
|  | 692 | * than the size of fragment. | 
|  | 693 | */ | 
|  | 694 | struct ufs_buffer_head { | 
|  | 695 | __u64 fragment;			/* first fragment */ | 
|  | 696 | __u64 count;				/* number of fragments */ | 
|  | 697 | struct buffer_head * bh[UFS_MAXFRAG];	/* buffers */ | 
|  | 698 | }; | 
|  | 699 |  | 
|  | 700 | struct ufs_cg_private_info { | 
| Evgeniy Dushistov | 9695ef1 | 2006-06-25 05:47:22 -0700 | [diff] [blame] | 701 | struct ufs_buffer_head c_ubh; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | __u32	c_cgx;		/* number of cylidner group */ | 
|  | 703 | __u16	c_ncyl;		/* number of cyl's this cg */ | 
|  | 704 | __u16	c_niblk;	/* number of inode blocks this cg */ | 
|  | 705 | __u32	c_ndblk;	/* number of data blocks this cg */ | 
|  | 706 | __u32	c_rotor;	/* position of last used block */ | 
|  | 707 | __u32	c_frotor;	/* position of last used frag */ | 
|  | 708 | __u32	c_irotor;	/* position of last used inode */ | 
|  | 709 | __u32	c_btotoff;	/* (__u32) block totals per cylinder */ | 
|  | 710 | __u32	c_boff;		/* (short) free block positions */ | 
|  | 711 | __u32	c_iusedoff;	/* (char) used inode map */ | 
|  | 712 | __u32	c_freeoff;	/* (u_char) free block map */ | 
|  | 713 | __u32	c_nextfreeoff;	/* (u_char) next available space */ | 
|  | 714 | __u32	c_clustersumoff;/* (u_int32) counts of avail clusters */ | 
|  | 715 | __u32	c_clusteroff;	/* (u_int8) free cluster map */ | 
|  | 716 | __u32	c_nclusterblks;	/* number of clusters this cg */ | 
|  | 717 | }; | 
|  | 718 |  | 
| Evgeniy Dushistov | 54fb996 | 2007-02-12 00:54:32 -0800 | [diff] [blame] | 719 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | struct ufs_sb_private_info { | 
|  | 721 | struct ufs_buffer_head s_ubh; /* buffer containing super block */ | 
| Al Viro | 44aa535 | 2006-08-13 01:54:30 -0400 | [diff] [blame] | 722 | struct ufs_csum_core cs_total; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 723 | __u32	s_sblkno;	/* offset of super-blocks in filesys */ | 
|  | 724 | __u32	s_cblkno;	/* offset of cg-block in filesys */ | 
|  | 725 | __u32	s_iblkno;	/* offset of inode-blocks in filesys */ | 
|  | 726 | __u32	s_dblkno;	/* offset of first data after cg */ | 
|  | 727 | __u32	s_cgoffset;	/* cylinder group offset in cylinder */ | 
|  | 728 | __u32	s_cgmask;	/* used to calc mod fs_ntrak */ | 
|  | 729 | __u32	s_size;		/* number of blocks (fragments) in fs */ | 
|  | 730 | __u32	s_dsize;	/* number of data blocks in fs */ | 
|  | 731 | __u64	s_u2_size;	/* ufs2: number of blocks (fragments) in fs */ | 
|  | 732 | __u64	s_u2_dsize;	/*ufs2:  number of data blocks in fs */ | 
|  | 733 | __u32	s_ncg;		/* number of cylinder groups */ | 
|  | 734 | __u32	s_bsize;	/* size of basic blocks */ | 
|  | 735 | __u32	s_fsize;	/* size of fragments */ | 
|  | 736 | __u32	s_fpb;		/* fragments per block */ | 
|  | 737 | __u32	s_minfree;	/* minimum percentage of free blocks */ | 
|  | 738 | __u32	s_bmask;	/* `blkoff'' calc of blk offsets */ | 
|  | 739 | __u32	s_fmask;	/* s_fsize mask */ | 
|  | 740 | __u32	s_bshift;	/* `lblkno'' calc of logical blkno */ | 
|  | 741 | __u32   s_fshift;	/* s_fsize shift */ | 
|  | 742 | __u32	s_fpbshift;	/* fragments per block shift */ | 
|  | 743 | __u32	s_fsbtodb;	/* fsbtodb and dbtofsb shift constant */ | 
|  | 744 | __u32	s_sbsize;	/* actual size of super block */ | 
|  | 745 | __u32   s_csmask;	/* csum block offset */ | 
|  | 746 | __u32	s_csshift;	/* csum block number */ | 
|  | 747 | __u32	s_nindir;	/* value of NINDIR */ | 
|  | 748 | __u32	s_inopb;	/* value of INOPB */ | 
|  | 749 | __u32	s_nspf;		/* value of NSPF */ | 
|  | 750 | __u32	s_npsect;	/* # sectors/track including spares */ | 
|  | 751 | __u32	s_interleave;	/* hardware sector interleave */ | 
|  | 752 | __u32	s_trackskew;	/* sector 0 skew, per track */ | 
| Evgeniy Dushistov | 3313e29 | 2007-02-12 00:54:31 -0800 | [diff] [blame] | 753 | __u64	s_csaddr;	/* blk addr of cyl grp summary area */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 754 | __u32	s_cssize;	/* size of cyl grp summary area */ | 
|  | 755 | __u32	s_cgsize;	/* cylinder group size */ | 
|  | 756 | __u32	s_ntrak;	/* tracks per cylinder */ | 
|  | 757 | __u32	s_nsect;	/* sectors per track */ | 
|  | 758 | __u32	s_spc;		/* sectors per cylinder */ | 
|  | 759 | __u32	s_ipg;		/* inodes per cylinder group */ | 
|  | 760 | __u32	s_fpg;		/* fragments per group */ | 
|  | 761 | __u32	s_cpc;		/* cyl per cycle in postbl */ | 
|  | 762 | __s32	s_contigsumsize;/* size of cluster summary array, 44bsd */ | 
|  | 763 | __s64	s_qbmask;	/* ~usb_bmask */ | 
|  | 764 | __s64	s_qfmask;	/* ~usb_fmask */ | 
|  | 765 | __s32	s_postblformat;	/* format of positional layout tables */ | 
|  | 766 | __s32	s_nrpos;	/* number of rotational positions */ | 
|  | 767 | __s32	s_postbloff;	/* (__s16) rotation block list head */ | 
|  | 768 | __s32	s_rotbloff;	/* (__u8) blocks for each rotation */ | 
|  | 769 |  | 
|  | 770 | __u32	s_fpbmask;	/* fragments per block mask */ | 
|  | 771 | __u32	s_apb;		/* address per block */ | 
|  | 772 | __u32	s_2apb;		/* address per block^2 */ | 
|  | 773 | __u32	s_3apb;		/* address per block^3 */ | 
|  | 774 | __u32	s_apbmask;	/* address per block mask */ | 
|  | 775 | __u32	s_apbshift;	/* address per block shift */ | 
|  | 776 | __u32	s_2apbshift;	/* address per block shift * 2 */ | 
|  | 777 | __u32	s_3apbshift;	/* address per block shift * 3 */ | 
|  | 778 | __u32	s_nspfshift;	/* number of sector per fragment shift */ | 
|  | 779 | __u32	s_nspb;		/* number of sector per block */ | 
|  | 780 | __u32	s_inopf;	/* inodes per fragment */ | 
|  | 781 | __u32	s_sbbase;	/* offset of NeXTstep superblock */ | 
|  | 782 | __u32	s_bpf;		/* bits per fragment */ | 
|  | 783 | __u32	s_bpfshift;	/* bits per fragment shift*/ | 
|  | 784 | __u32	s_bpfmask;	/* bits per fragment mask */ | 
|  | 785 |  | 
|  | 786 | __u32	s_maxsymlinklen;/* upper limit on fast symlinks' size */ | 
|  | 787 | __s32	fs_magic;       /* filesystem magic */ | 
| Evgeniy Dushistov | f336953 | 2007-02-08 14:20:25 -0800 | [diff] [blame] | 788 | unsigned int s_dirblksize; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 789 | }; | 
|  | 790 |  | 
|  | 791 | /* | 
|  | 792 | * Sizes of this structures are: | 
|  | 793 | *	ufs_super_block_first	512 | 
|  | 794 | *	ufs_super_block_second	512 | 
|  | 795 | *	ufs_super_block_third	356 | 
|  | 796 | */ | 
|  | 797 | struct ufs_super_block_first { | 
| Mark Fortescue | 252e211 | 2007-10-16 23:26:31 -0700 | [diff] [blame] | 798 | union { | 
|  | 799 | struct { | 
|  | 800 | __fs32	fs_link;	/* UNUSED */ | 
|  | 801 | } fs_42; | 
|  | 802 | struct { | 
|  | 803 | __fs32	fs_state;	/* file system state flag */ | 
|  | 804 | } fs_sun; | 
|  | 805 | } fs_u0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | __fs32	fs_rlink; | 
|  | 807 | __fs32	fs_sblkno; | 
|  | 808 | __fs32	fs_cblkno; | 
|  | 809 | __fs32	fs_iblkno; | 
|  | 810 | __fs32	fs_dblkno; | 
|  | 811 | __fs32	fs_cgoffset; | 
|  | 812 | __fs32	fs_cgmask; | 
|  | 813 | __fs32	fs_time; | 
|  | 814 | __fs32	fs_size; | 
|  | 815 | __fs32	fs_dsize; | 
|  | 816 | __fs32	fs_ncg; | 
|  | 817 | __fs32	fs_bsize; | 
|  | 818 | __fs32	fs_fsize; | 
|  | 819 | __fs32	fs_frag; | 
|  | 820 | __fs32	fs_minfree; | 
|  | 821 | __fs32	fs_rotdelay; | 
|  | 822 | __fs32	fs_rps; | 
|  | 823 | __fs32	fs_bmask; | 
|  | 824 | __fs32	fs_fmask; | 
|  | 825 | __fs32	fs_bshift; | 
|  | 826 | __fs32	fs_fshift; | 
|  | 827 | __fs32	fs_maxcontig; | 
|  | 828 | __fs32	fs_maxbpg; | 
|  | 829 | __fs32	fs_fragshift; | 
|  | 830 | __fs32	fs_fsbtodb; | 
|  | 831 | __fs32	fs_sbsize; | 
|  | 832 | __fs32	fs_csmask; | 
|  | 833 | __fs32	fs_csshift; | 
|  | 834 | __fs32	fs_nindir; | 
|  | 835 | __fs32	fs_inopb; | 
|  | 836 | __fs32	fs_nspf; | 
|  | 837 | __fs32	fs_optim; | 
|  | 838 | union { | 
|  | 839 | struct { | 
|  | 840 | __fs32	fs_npsect; | 
|  | 841 | } fs_sun; | 
|  | 842 | struct { | 
|  | 843 | __fs32	fs_state; | 
|  | 844 | } fs_sunx86; | 
|  | 845 | } fs_u1; | 
|  | 846 | __fs32	fs_interleave; | 
|  | 847 | __fs32	fs_trackskew; | 
|  | 848 | __fs32	fs_id[2]; | 
|  | 849 | __fs32	fs_csaddr; | 
|  | 850 | __fs32	fs_cssize; | 
|  | 851 | __fs32	fs_cgsize; | 
|  | 852 | __fs32	fs_ntrak; | 
|  | 853 | __fs32	fs_nsect; | 
|  | 854 | __fs32	fs_spc; | 
|  | 855 | __fs32	fs_ncyl; | 
|  | 856 | __fs32	fs_cpg; | 
|  | 857 | __fs32	fs_ipg; | 
|  | 858 | __fs32	fs_fpg; | 
|  | 859 | struct ufs_csum fs_cstotal; | 
|  | 860 | __s8	fs_fmod; | 
|  | 861 | __s8	fs_clean; | 
|  | 862 | __s8	fs_ronly; | 
|  | 863 | __s8	fs_flags; | 
|  | 864 | __s8	fs_fsmnt[UFS_MAXMNTLEN - 212]; | 
|  | 865 |  | 
|  | 866 | }; | 
|  | 867 |  | 
|  | 868 | struct ufs_super_block_second { | 
| Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 869 | union { | 
|  | 870 | struct { | 
|  | 871 | __s8	fs_fsmnt[212]; | 
|  | 872 | __fs32	fs_cgrotor; | 
|  | 873 | __fs32	fs_csp[UFS_MAXCSBUFS]; | 
|  | 874 | __fs32	fs_maxcluster; | 
|  | 875 | __fs32	fs_cpc; | 
|  | 876 | __fs16	fs_opostbl[82]; | 
|  | 877 | } fs_u1; | 
|  | 878 | struct { | 
|  | 879 | __s8  fs_fsmnt[UFS2_MAXMNTLEN - UFS_MAXMNTLEN + 212]; | 
|  | 880 | __u8   fs_volname[UFS2_MAXVOLLEN]; | 
|  | 881 | __fs64  fs_swuid; | 
|  | 882 | __fs32  fs_pad; | 
|  | 883 | __fs32   fs_cgrotor; | 
|  | 884 | __fs32   fs_ocsp[UFS2_NOCSPTRS]; | 
|  | 885 | __fs32   fs_contigdirs; | 
|  | 886 | __fs32   fs_csp; | 
|  | 887 | __fs32   fs_maxcluster; | 
|  | 888 | __fs32   fs_active; | 
|  | 889 | __fs32   fs_old_cpc; | 
|  | 890 | __fs32   fs_maxbsize; | 
|  | 891 | __fs64   fs_sparecon64[17]; | 
|  | 892 | __fs64   fs_sblockloc; | 
|  | 893 | __fs64	cs_ndir; | 
|  | 894 | __fs64	cs_nbfree; | 
|  | 895 | } fs_u2; | 
|  | 896 | } fs_un; | 
|  | 897 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 898 |  | 
|  | 899 | struct ufs_super_block_third { | 
| Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 900 | union { | 
|  | 901 | struct { | 
|  | 902 | __fs16	fs_opostbl[46]; | 
|  | 903 | } fs_u1; | 
|  | 904 | struct { | 
|  | 905 | __fs64	cs_nifree;	/* number of free inodes */ | 
|  | 906 | __fs64	cs_nffree;	/* number of free frags */ | 
|  | 907 | __fs64   cs_numclusters;	/* number of free clusters */ | 
|  | 908 | __fs64   cs_spare[3];	/* future expansion */ | 
|  | 909 | struct  ufs_timeval    fs_time;		/* last time written */ | 
|  | 910 | __fs64    fs_size;		/* number of blocks in fs */ | 
|  | 911 | __fs64    fs_dsize;	/* number of data blocks in fs */ | 
|  | 912 | __fs64   fs_csaddr;	/* blk addr of cyl grp summary area */ | 
|  | 913 | __fs64    fs_pendingblocks;/* blocks in process of being freed */ | 
|  | 914 | __fs32    fs_pendinginodes;/*inodes in process of being freed */ | 
| Eric Sandeen | 86f4f0f | 2006-11-02 22:07:05 -0800 | [diff] [blame] | 915 | } __attribute__ ((packed)) fs_u2; | 
| Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 916 | } fs_un1; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 917 | union { | 
|  | 918 | struct { | 
|  | 919 | __fs32	fs_sparecon[53];/* reserved for future constants */ | 
|  | 920 | __fs32	fs_reclaim; | 
|  | 921 | __fs32	fs_sparecon2[1]; | 
|  | 922 | __fs32	fs_state;	/* file system state time stamp */ | 
|  | 923 | __fs32	fs_qbmask[2];	/* ~usb_bmask */ | 
|  | 924 | __fs32	fs_qfmask[2];	/* ~usb_fmask */ | 
|  | 925 | } fs_sun; | 
|  | 926 | struct { | 
|  | 927 | __fs32	fs_sparecon[53];/* reserved for future constants */ | 
|  | 928 | __fs32	fs_reclaim; | 
|  | 929 | __fs32	fs_sparecon2[1]; | 
|  | 930 | __fs32	fs_npsect;	/* # sectors/track including spares */ | 
|  | 931 | __fs32	fs_qbmask[2];	/* ~usb_bmask */ | 
|  | 932 | __fs32	fs_qfmask[2];	/* ~usb_fmask */ | 
|  | 933 | } fs_sunx86; | 
|  | 934 | struct { | 
|  | 935 | __fs32	fs_sparecon[50];/* reserved for future constants */ | 
|  | 936 | __fs32	fs_contigsumsize;/* size of cluster summary array */ | 
|  | 937 | __fs32	fs_maxsymlinklen;/* max length of an internal symlink */ | 
|  | 938 | __fs32	fs_inodefmt;	/* format of on-disk inodes */ | 
|  | 939 | __fs32	fs_maxfilesize[2];	/* max representable file size */ | 
|  | 940 | __fs32	fs_qbmask[2];	/* ~usb_bmask */ | 
|  | 941 | __fs32	fs_qfmask[2];	/* ~usb_fmask */ | 
|  | 942 | __fs32	fs_state;	/* file system state time stamp */ | 
|  | 943 | } fs_44; | 
| Evgeniy Dushistov | 647b7e8 | 2006-06-25 05:47:29 -0700 | [diff] [blame] | 944 | } fs_un2; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 945 | __fs32	fs_postblformat; | 
|  | 946 | __fs32	fs_nrpos; | 
|  | 947 | __fs32	fs_postbloff; | 
|  | 948 | __fs32	fs_rotbloff; | 
|  | 949 | __fs32	fs_magic; | 
|  | 950 | __u8	fs_space[1]; | 
|  | 951 | }; | 
|  | 952 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 953 | #endif /* __LINUX_UFS_FS_H */ |