Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

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