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