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