2
* linux/include/linux/ufs_fs.h
5
* Adrian Rodriguez (adrian@franklins-tower.rutgers.edu)
6
* Laboratory for Computer Science Research Computing Facility
7
* Rutgers, The State University of New Jersey
9
* $Id: ufs_fs.h,v 1.1 2001/04/27 21:55:09 bencollins Exp $
13
#ifndef __LINUX_UFS_FS_H
14
#define __LINUX_UFS_FS_H
16
#include <non-linux/types.h>
19
#define UFS_BBSIZE 8192
20
#define UFS_SBLOCK 8192
21
#define UFS_SBSIZE 8192
23
#define UFS_MAGIC 0x00011954
25
#define UFS_FSIZE 1024
26
#define UFS_BSIZE 8192
31
#define UFS_IND_BLOCK (UFS_NDADDR + 0)
32
#define UFS_DIND_BLOCK (UFS_NDADDR + 1)
33
#define UFS_TIND_BLOCK (UFS_NDADDR + 2)
37
#define UFS_USEEFT ((__u16)65535)
39
#define UFS_FSOK 0x7c269d38
40
#define UFS_FSACTIVE ((char)0x00)
41
#define UFS_FSCLEAN ((char)0x01)
42
#define UFS_FSSTABLE ((char)0x02)
43
#define UFS_FSBAD ((char)0xff)
45
/* Flags for ufs_sb_info */
46
#define UFS_DEBUG 0x00000001
47
#define UFS_DEBUG_INODE 0x00000002
48
#define UFS_DEBUG_NAMEI 0x00000004
49
#define UFS_DEBUG_LINKS 0x00000008
51
#define UFS_ADDR_PER_BLOCK(sb) ((sb)->u.ufs_sb.s_bsize >> 2)
52
#define UFS_ADDR_PER_BLOCK_BITS(sb) ((sb)->u.ufs_sb.s_bshift - 2)
54
/* Test if the inode number is valid. */
55
#define ufs_ino_ok(inode) ((inode->i_ino < 2) && \
56
(inode->i_ino > (inode->i_sb->u.ufs_sb.s_ncg * inode->i_sb->u.ufs_sb.s_ipg - 1)))
58
/* Convert (sb,cg) to the first physical block number for that cg. */
59
#define ufs_cgstart(sb, cg) \
60
(((sb)->u.ufs_sb.s_fpg * (cg)) + (sb)->u.ufs_sb.s_cgoffset * ((cg) & ~((sb)->u.ufs_sb.s_cgmask)))
62
/* Convert (sb,cg) to the first phys. block number for inodes in that cg. */
63
#define ufs_cgimin(sb, cg) (ufs_cgstart((sb), (cg)) + (sb)->u.ufs_sb.s_iblkno)
64
#define ufs_cgdmin(sb, cg) (ufs_cgstart((sb), (cg)) + (sb)->u.ufs_sb.s_dblkno)
66
/* Convert an inode number to a cg number. */
67
/* XXX - this can be optimized if s_ipg is a power of 2. */
68
#define ufs_ino2cg(inode) ((inode)->i_ino/(inode)->i_sb->u.ufs_sb.s_ipg)
70
#define UFS_MAXNAMLEN 255
72
#define ufs_lbn(sb, block) ((block) >> (sb)->u.ufs_sb.s_lshift)
73
#define ufs_boff(sb, block) ((block) & ~((sb)->u.ufs_sb.s_lmask))
74
#define ufs_dbn(sb, block, boff) ((block) + ufs_boff((sb), (boff)))
77
__u32 d_ino; /* inode number of this entry */
78
__u16 d_reclen; /* length of this entry */
79
__u16 d_namlen; /* actual length of d_name */
80
char d_name[UFS_MAXNAMLEN + 1]; /* file name */
87
__u32 cs_ndir; /* number of directories */
88
__u32 cs_nbfree; /* number of free blocks */
89
__u32 cs_nifree; /* number of free inodes */
90
__u32 cs_nffree; /* number of free frags */
93
typedef struct _ufsquad {
98
* This is the actual superblock, as it is laid out on the disk.
100
struct ufs_superblock {
101
__u32 fs_link; /* UNUSED */
102
__u32 fs_rlink; /* UNUSED */
103
__u32 fs_sblkno; /* addr of super-block in filesys */
104
__u32 fs_cblkno; /* offset of cyl-block in filesys */
105
__u32 fs_iblkno; /* offset of inode-blocks in filesys */
106
__u32 fs_dblkno; /* offset of first data after cg */
107
__u32 fs_cgoffset; /* cylinder group offset in cylinder */
108
__u32 fs_cgmask; /* used to calc mod fs_ntrak */
109
time_t fs_time; /* last time written */
110
__u32 fs_size; /* number of blocks in fs */
111
__u32 fs_dsize; /* number of data blocks in fs */
112
__u32 fs_ncg; /* number of cylinder groups */
113
__u32 fs_bsize; /* size of basic blocks in fs */
114
__u32 fs_fsize; /* size of frag blocks in fs */
115
__u32 fs_frag; /* number of frags in a block in fs */
116
/* these are configuration parameters */
117
__u32 fs_minfree; /* minimum percentage of free blocks */
118
__u32 fs_rotdelay; /* num of ms for optimal next block */
119
__u32 fs_rps; /* disk revolutions per second */
120
/* these fields can be computed from the others */
121
__u32 fs_bmask; /* ``blkoff'' calc of blk offsets */
122
__u32 fs_fmask; /* ``fragoff'' calc of frag offsets */
123
__u32 fs_bshift; /* ``lblkno'' calc of logical blkno */
124
__u32 fs_fshift; /* ``numfrags'' calc number of frags */
125
/* these are configuration parameters */
126
__u32 fs_maxcontig; /* max number of contiguous blks */
127
__u32 fs_maxbpg; /* max number of blks per cyl group */
128
/* these fields can be computed from the others */
129
__u32 fs_fragshift; /* block to frag shift */
130
__u32 fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */
131
__u32 fs_sbsize; /* actual size of super block */
132
__u32 fs_csmask; /* csum block offset */
133
__u32 fs_csshift; /* csum block number */
134
__u32 fs_nindir; /* value of NINDIR */
135
__u32 fs_inopb; /* value of INOPB */
136
__u32 fs_nspf; /* value of NSPF */
137
/* yet another configuration parameter */
138
__u32 fs_optim; /* optimization preference, see below */
139
/* these fields are derived from the hardware */
140
__u32 fs_npsect; /* # sectors/track including spares */
141
__u32 fs_interleave; /* hardware sector interleave */
142
__u32 fs_trackskew; /* sector 0 skew, per track */
143
/* a unique id for this filesystem (currently unused and unmaintained) */
144
/* In 4.3 Tahoe this space is used by fs_headswitch and fs_trkseek */
145
/* Neither of those fields is used in the Tahoe code right now but */
146
/* there could be problems if they are. */
147
__u32 fs_id[2]; /* file system id */
148
/* sizes determined by number of cylinder groups and their sizes */
149
__u32 fs_csaddr; /* blk addr of cyl grp summary area */
150
__u32 fs_cssize; /* size of cyl grp summary area */
151
__u32 fs_cgsize; /* cylinder group size */
152
/* these fields are derived from the hardware */
153
__u32 fs_ntrak; /* tracks per cylinder */
154
__u32 fs_nsect; /* sectors per track */
155
__u32 fs_spc; /* sectors per cylinder */
156
/* this comes from the disk driver partitioning */
157
__u32 fs_ncyl; /* cylinders in file system */
158
/* these fields can be computed from the others */
159
__u32 fs_cpg; /* cylinders per group */
160
__u32 fs_ipg; /* inodes per group */
161
__u32 fs_fpg; /* blocks per group * fs_frag */
162
/* this data must be re-computed after crashes */
163
struct ufs_csum fs_cstotal; /* cylinder summary information */
164
/* these fields are cleared at mount time */
165
__u8 fs_fmod; /* super block modified flag */
166
__u8 fs_clean; /* file system is clean flag */
167
__u8 fs_ronly; /* mounted read-only flag */
168
__u8 fs_flags; /* currently unused flag */
169
__u8 fs_fsmnt[MAXMNTLEN]; /* name mounted on */
170
/* these fields retain the current block allocation info */
171
__u32 fs_cgrotor; /* last cg searched */
172
struct ufs_csum * fs_csp[MAXCSBUFS]; /* list of fs_cs info buffers */
173
__u32 fs_cpc; /* cyl per cycle in postbl */
174
__u16 fs_opostbl[16][8]; /* old rotation block list head */
175
__s32 fs_sparecon[55]; /* reserved for future constants */
176
__s32 fs_state; /* file system state time stamp */
177
ufsquad fs_qbmask; /* ~usb_bmask - for use with __s64 size */
178
ufsquad fs_qfmask; /* ~usb_fmask - for use with __s64 size */
179
__s32 fs_postblformat; /* format of positional layout tables */
180
__s32 fs_nrpos; /* number of rotational positions */
181
__s32 fs_postbloff; /* (__s16) rotation block list head */
182
__s32 fs_rotbloff; /* (__u8) blocks for each rotation */
183
__s32 fs_magic; /* magic number */
184
__u8 fs_space[1]; /* list of blocks for each rotation */
189
* structure of an on-disk inode
192
__u16 ui_mode; /* 0x0 */
193
__u16 ui_nlink; /* 0x2 */
194
__u16 ui_suid; /* 0x4 */
195
__u16 ui_sgid; /* 0x6 */
196
ufsquad ui_size; /* 0x8 */ /* XXX - should be __u64 */
197
struct timeval ui_atime; /* 0x10 */
198
struct timeval ui_mtime; /* 0x18 */
199
struct timeval ui_ctime; /* 0x20 */
200
__u32 ui_db[UFS_NDADDR]; /* 0x28 data blocks */
201
__u32 ui_ib[UFS_NINDIR]; /* 0x58 indirect blocks */
202
__u32 ui_flags; /* 0x64 unused */
203
__u32 ui_blocks; /* 0x68 blocks in use */
204
__u32 ui_gen; /* 0x6c generation number XXX - what is this? */
205
__u32 ui_shadow; /* 0x70 shadow inode XXX - what is this?*/
206
__u32 ui_uid; /* 0x74 long EFT version of uid */
207
__u32 ui_gid; /* 0x78 long EFT version of gid */
208
__u32 ui_oeftflag; /* 0x7c reserved */
214
* Function prototypes
218
extern int ufs_bmap (struct inode *, int);
219
extern void ufs_read_inode(struct inode * inode);
220
extern void ufs_put_inode(struct inode * inode);
222
extern void ufs_print_inode (struct inode *);
225
extern int ufs_lookup (struct inode *, const char *, int, struct inode **);
228
extern void ufs_warning (struct super_block *, const char *, const char *, ...)
229
__attribute__ ((format (printf, 3, 4)));
230
extern int init_ufs_fs(void);
233
* Inodes and files operations
237
extern struct inode_operations ufs_dir_inode_operations;
238
extern struct file_operations ufs_dir_operations;
241
extern struct inode_operations ufs_file_inode_operations;
242
extern struct file_operations ufs_file_operations;
245
extern struct inode_operations ufs_symlink_inode_operations;
246
extern struct file_operations ufs_symlink_operations;
248
/* Byte swapping 32/16-bit quantities into little endian format. */
249
extern int ufs_need_swab;
251
extern __inline__ __u32 ufs_swab32(__u32 value)
253
return (ufs_need_swab ? ((value >> 24) |
254
((value >> 8) & 0xff00) |
255
((value << 8) & 0xff0000) |
256
(value << 24)) : value);
259
extern __inline__ __u16 ufs_swab16(__u16 value)
261
return (ufs_need_swab ? ((value >> 8) |
262
(value << 8)) : value);
265
#endif /* __KERNEL__ */
267
#endif /* __LINUX_UFS_FS_H */