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