ufs_fs.h 37 KB

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