source: svn/trunk/newcon3bcm2_21bu/toolchain/mips-linux-uclibc/include/linux/ufs_fs.h

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

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