ufs_fs.h 36 KB

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