1 /*
2  *  linux/include/linux/ufs_fs_sb.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  * $Id: ufs_fs_sb.h,v 1.8 1998/05/06 12:04:40 jj Exp $
10  *
11  * Write support by Daniel Pirkl <daniel.pirkl@email.cz>
12  */
13 
14 #ifndef __LINUX_UFS_FS_SB_H
15 #define __LINUX_UFS_FS_SB_H
16 
17 #include <linux/ufs_fs.h>
18 
19 /*
20  * This structure is used for reading disk structures larger
21  * than the size of fragment.
22  */
23 struct ufs_buffer_head {
24 	unsigned fragment;			/* first fragment */
25 	unsigned count;				/* number of fragments */
26 	struct buffer_head * bh[UFS_MAXFRAG];	/* buffers */
27 };
28 
29 struct ufs_cg_private_info {
30 	struct ufs_cylinder_group ucg;
31 	__u32	c_cgx;		/* number of cylidner group */
32 	__u16	c_ncyl;		/* number of cyl's this cg */
33 	__u16	c_niblk;	/* number of inode blocks this cg */
34 	__u32	c_ndblk;	/* number of data blocks this cg */
35 	__u32	c_rotor;	/* position of last used block */
36 	__u32	c_frotor;	/* position of last used frag */
37 	__u32	c_irotor;	/* position of last used inode */
38 	__u32	c_btotoff;	/* (__u32) block totals per cylinder */
39 	__u32	c_boff;		/* (short) free block positions */
40 	__u32	c_iusedoff;	/* (char) used inode map */
41 	__u32	c_freeoff;	/* (u_char) free block map */
42 	__u32	c_nextfreeoff;	/* (u_char) next available space */
43 	__u32	c_clustersumoff;/* (u_int32) counts of avail clusters */
44 	__u32	c_clusteroff;	/* (u_int8) free cluster map */
45 	__u32	c_nclusterblks;	/* number of clusters this cg */
46 };
47 
48 struct ufs_sb_private_info {
49 	struct ufs_buffer_head s_ubh; /* buffer containing super block */
50 	__u32	s_sblkno;	/* offset of super-blocks in filesys */
51 	__u32	s_cblkno;	/* offset of cg-block in filesys */
52 	__u32	s_iblkno;	/* offset of inode-blocks in filesys */
53 	__u32	s_dblkno;	/* offset of first data after cg */
54 	__u32	s_cgoffset;	/* cylinder group offset in cylinder */
55 	__u32	s_cgmask;	/* used to calc mod fs_ntrak */
56 	__u32	s_size;		/* number of blocks (fragments) in fs */
57 	__u32	s_dsize;	/* number of data blocks in fs */
58 	__u32	s_ncg;		/* number of cylinder groups */
59 	__u32	s_bsize;	/* size of basic blocks */
60 	__u32	s_fsize;	/* size of fragments */
61 	__u32	s_fpb;		/* fragments per block */
62 	__u32	s_minfree;	/* minimum percentage of free blocks */
63 	__u32	s_bmask;	/* `blkoff'' calc of blk offsets */
64 	__u32	s_fmask;	/* s_fsize mask */
65 	__u32	s_bshift;	/* `lblkno'' calc of logical blkno */
66 	__u32   s_fshift;	/* s_fsize shift */
67 	__u32	s_fpbshift;	/* fragments per block shift */
68 	__u32	s_fsbtodb;	/* fsbtodb and dbtofsb shift constant */
69 	__u32	s_sbsize;	/* actual size of super block */
70 	__u32   s_csmask;	/* csum block offset */
71 	__u32	s_csshift;	/* csum block number */
72 	__u32	s_nindir;	/* value of NINDIR */
73 	__u32	s_inopb;	/* value of INOPB */
74 	__u32	s_nspf;		/* value of NSPF */
75 	__u32	s_npsect;	/* # sectors/track including spares */
76 	__u32	s_interleave;	/* hardware sector interleave */
77 	__u32	s_trackskew;	/* sector 0 skew, per track */
78 	__u32	s_csaddr;	/* blk addr of cyl grp summary area */
79 	__u32	s_cssize;	/* size of cyl grp summary area */
80 	__u32	s_cgsize;	/* cylinder group size */
81 	__u32	s_ntrak;	/* tracks per cylinder */
82 	__u32	s_nsect;	/* sectors per track */
83 	__u32	s_spc;		/* sectors per cylinder */
84 	__u32	s_ipg;		/* inodes per group */
85 	__u32	s_fpg;		/* fragments per group */
86 	__u32	s_cpc;		/* cyl per cycle in postbl */
87 	__s32	s_contigsumsize;/* size of cluster summary array, 44bsd */
88 	__s64	s_qbmask;	/* ~usb_bmask */
89 	__s64	s_qfmask;	/* ~usb_fmask */
90 	__s32	s_postblformat;	/* format of positional layout tables */
91 	__s32	s_nrpos;	/* number of rotational positions */
92         __s32	s_postbloff;	/* (__s16) rotation block list head */
93 	__s32	s_rotbloff;	/* (__u8) blocks for each rotation */
94 
95 	__u32	s_fpbmask;	/* fragments per block mask */
96 	__u32	s_apb;		/* address per block */
97 	__u32	s_2apb;		/* address per block^2 */
98 	__u32	s_3apb;		/* address per block^3 */
99 	__u32	s_apbmask;	/* address per block mask */
100 	__u32	s_apbshift;	/* address per block shift */
101 	__u32	s_2apbshift;	/* address per block shift * 2 */
102 	__u32	s_3apbshift;	/* address per block shift * 3 */
103 	__u32	s_nspfshift;	/* number of sector per fragment shift */
104 	__u32	s_nspb;		/* number of sector per block */
105 	__u32	s_inopf;	/* inodes per fragment */
106 	__u32	s_sbbase;	/* offset of NeXTstep superblock */
107 	__u32	s_bpf;		/* bits per fragment */
108 	__u32	s_bpfshift;	/* bits per fragment shift*/
109 	__u32	s_bpfmask;	/* bits per fragment mask */
110 
111 	__u32	s_maxsymlinklen;/* upper limit on fast symlinks' size */
112 };
113 
114 
115 #define UFS_MAX_GROUP_LOADED 8
116 #define UFS_CGNO_EMPTY ((unsigned)-1)
117 
118 struct ufs_sb_info {
119 	struct ufs_sb_private_info * s_uspi;
120 	struct ufs_csum	* s_csp[UFS_MAXCSBUFS];
121 	unsigned s_bytesex;
122 	unsigned s_flags;
123 	struct buffer_head ** s_ucg;
124 	struct ufs_cg_private_info * s_ucpi[UFS_MAX_GROUP_LOADED];
125 	unsigned s_cgno[UFS_MAX_GROUP_LOADED];
126 	unsigned short s_cg_loaded;
127 	unsigned s_mount_opt;
128 };
129 
130 /*
131  * Sizes of this structures are:
132  *	ufs_super_block_first	512
133  *	ufs_super_block_second	512
134  *	ufs_super_block_third	356
135  */
136 struct ufs_super_block_first {
137 	__u32	fs_link;
138 	__u32	fs_rlink;
139 	__u32	fs_sblkno;
140 	__u32	fs_cblkno;
141 	__u32	fs_iblkno;
142 	__u32	fs_dblkno;
143 	__u32	fs_cgoffset;
144 	__u32	fs_cgmask;
145 	__u32	fs_time;
146 	__u32	fs_size;
147 	__u32	fs_dsize;
148 	__u32	fs_ncg;
149 	__u32	fs_bsize;
150 	__u32	fs_fsize;
151 	__u32	fs_frag;
152 	__u32	fs_minfree;
153 	__u32	fs_rotdelay;
154 	__u32	fs_rps;
155 	__u32	fs_bmask;
156 	__u32	fs_fmask;
157 	__u32	fs_bshift;
158 	__u32	fs_fshift;
159 	__u32	fs_maxcontig;
160 	__u32	fs_maxbpg;
161 	__u32	fs_fragshift;
162 	__u32	fs_fsbtodb;
163 	__u32	fs_sbsize;
164 	__u32	fs_csmask;
165 	__u32	fs_csshift;
166 	__u32	fs_nindir;
167 	__u32	fs_inopb;
168 	__u32	fs_nspf;
169 	__u32	fs_optim;
170 	union {
171 		struct {
172 			__u32	fs_npsect;
173 		} fs_sun;
174 		struct {
175 			__s32	fs_state;
176 		} fs_sunx86;
177 	} fs_u1;
178 	__u32	fs_interleave;
179 	__u32	fs_trackskew;
180 	__u32	fs_id[2];
181 	__u32	fs_csaddr;
182 	__u32	fs_cssize;
183 	__u32	fs_cgsize;
184 	__u32	fs_ntrak;
185 	__u32	fs_nsect;
186 	__u32	fs_spc;
187 	__u32	fs_ncyl;
188 	__u32	fs_cpg;
189 	__u32	fs_ipg;
190 	__u32	fs_fpg;
191 	struct ufs_csum fs_cstotal;
192 	__s8	fs_fmod;
193 	__s8	fs_clean;
194 	__s8	fs_ronly;
195 	__s8	fs_flags;
196 	__s8	fs_fsmnt[UFS_MAXMNTLEN - 212];
197 
198 };
199 
200 struct ufs_super_block_second {
201 	__s8	fs_fsmnt[212];
202 	__u32	fs_cgrotor;
203 	__u32	fs_csp[UFS_MAXCSBUFS];
204 	__u32	fs_maxcluster;
205 	__u32	fs_cpc;
206 	__u16	fs_opostbl[82];
207 };
208 
209 struct ufs_super_block_third {
210 	__u16	fs_opostbl[46];
211 	union {
212 		struct {
213 			__s32	fs_sparecon[53];/* reserved for future constants */
214 			__s32	fs_reclaim;
215 			__s32	fs_sparecon2[1];
216 			__s32	fs_state;	/* file system state time stamp */
217 			__u32	fs_qbmask[2];	/* ~usb_bmask */
218 			__u32	fs_qfmask[2];	/* ~usb_fmask */
219 		} fs_sun;
220 		struct {
221 			__s32	fs_sparecon[53];/* reserved for future constants */
222 			__s32	fs_reclaim;
223 			__s32	fs_sparecon2[1];
224 			__u32	fs_npsect;	/* # sectors/track including spares */
225 			__u32	fs_qbmask[2];	/* ~usb_bmask */
226 			__u32	fs_qfmask[2];	/* ~usb_fmask */
227 		} fs_sunx86;
228 		struct {
229 			__s32	fs_sparecon[50];/* reserved for future constants */
230 			__s32	fs_contigsumsize;/* size of cluster summary array */
231 			__s32	fs_maxsymlinklen;/* max length of an internal symlink */
232 			__s32	fs_inodefmt;	/* format of on-disk inodes */
233 			__u32	fs_maxfilesize[2];	/* max representable file size */
234 			__u32	fs_qbmask[2];	/* ~usb_bmask */
235 			__u32	fs_qfmask[2];	/* ~usb_fmask */
236 			__s32	fs_state;	/* file system state time stamp */
237 		} fs_44;
238 	} fs_u2;
239 	__s32	fs_postblformat;
240 	__s32	fs_nrpos;
241 	__s32	fs_postbloff;
242 	__s32	fs_rotbloff;
243 	__s32	fs_magic;
244 	__u8	fs_space[1];
245 };
246 
247 #endif /* __LINUX_UFS_FS_SB_H */
248