This source file includes following definitions.
- init_ufs_fs
- init_module
- cleanup_module
- ufs_print_super_stuff
- ufs_read_super
- ufs_put_super
- ufs_statfs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #include <linux/module.h>
22
23 #include <linux/kernel.h>
24 #include <linux/fs.h>
25 #include <linux/ufs_fs.h>
26 #include <linux/module.h>
27 #include <linux/locks.h>
28
29 #include <asm/segment.h>
30
31 struct super_block * ufs_read_super(struct super_block * sb, void * data, int silent);
32 void ufs_put_super (struct super_block * sb);
33 void ufs_statfs(struct super_block * sb, struct statfs * buf, int bufsize);
34
35 extern void ufs_read_inode(struct inode * inode);
36 extern void ufs_put_inode(struct inode * inode);
37
38 static struct super_operations ufs_super_ops = {
39 ufs_read_inode,
40 NULL,
41 NULL,
42 ufs_put_inode,
43 ufs_put_super,
44 NULL,
45 ufs_statfs,
46 NULL,
47 };
48
49 static struct file_system_type ufs_fs_type = {
50 ufs_read_super, "ufs", 1, NULL
51 };
52
53 int
54 init_ufs_fs(void)
55 {
56 return(register_filesystem(&ufs_fs_type));
57 }
58
59 #ifdef MODULE
60 int init_module(void)
61 {
62 int status;
63
64 if ((status = init_ufs_fs()) == 0)
65 register_symtab(0);
66 return status;
67 }
68
69 void cleanup_module(void)
70 {
71 unregister_filesystem(&ufs_fs_type);
72 }
73 #endif
74
75 #if 0
76 static void
77 ufs_print_super_stuff(struct super_block * sb, struct ufs_superblock * usb)
78 {
79
80 printk("fs_sblkno: 0x%8.8x\n", usb->fs_sblkno);
81 printk("fs_size: 0x%8.8x\n", usb->fs_size);
82 printk("fs_ncg: 0x%8.8x\n", usb->fs_ncg);
83 printk("fs_bsize: 0x%8.8x\n", usb->fs_bsize);
84 printk("fs_frag: 0x%8.8x\n", usb->fs_frag);
85 printk("fs_nindir: 0x%8.8x\n", usb->fs_nindir);
86 printk("fs_inopb: 0x%8.8x\n", usb->fs_inopb);
87 printk("fs_optim: 0x%8.8x\n", usb->fs_optim);
88 printk("fs_ncyl: 0x%8.8x\n", usb->fs_ncyl);
89 printk("fs_state: 0x%8.8x\n", usb->fs_state);
90 printk("fs_magic: 0x%8.8x\n", usb->fs_magic);
91 printk("fs_fsmnt: `%s'\n", usb->fs_fsmnt);
92
93 return;
94 }
95 #endif
96
97 struct super_block *
98 ufs_read_super(struct super_block * sb, void * data, int silent)
99 {
100 struct ufs_superblock * usb;
101 struct buffer_head * bh1, *bh2;
102
103
104
105
106
107
108
109
110 MOD_INC_USE_COUNT;
111 lock_super (sb);
112
113
114 sb->s_flags |= MS_RDONLY;
115
116 if (!(bh1 = bread(sb->s_dev, UFS_SBLOCK/BLOCK_SIZE, BLOCK_SIZE)) ||
117 !(bh2 = bread(sb->s_dev, (UFS_SBLOCK + BLOCK_SIZE)/BLOCK_SIZE,
118 BLOCK_SIZE))) {
119 sb->s_dev = 0;
120 unlock_super (sb);
121 if (bh1) {
122 brelse(bh1);
123 }
124 printk ("ufs_read_super: unable to read superblock\n");
125
126 MOD_DEC_USE_COUNT;
127 return(NULL);
128 }
129
130 usb = (struct ufs_superblock *)__get_free_page(GFP_KERNEL);
131 if (usb == NULL) {
132 printk ("ufs_read_super: get_free_page() failed\n");
133 }
134
135 memcpy((char *)usb, bh1->b_data, BLOCK_SIZE);
136 memcpy((char *)usb + BLOCK_SIZE, bh2->b_data,
137 sizeof(struct ufs_superblock) - BLOCK_SIZE);
138
139 brelse(bh1);
140 brelse(bh2);
141
142 if (usb->fs_magic != UFS_MAGIC) {
143
144 if (usb->fs_magic == 0x54190100) {
145 printk ("ufs_read_super: can't grok byteswapped fs on dev %d/%d\n",
146 MAJOR(sb->s_dev), MINOR(sb->s_dev));
147 silent = 1;
148 }
149 sb->s_dev = 0;
150 unlock_super (sb);
151 if (!silent)
152 printk ("ufs_read_super: bad magic number 0x%8.8x on dev %d/%d\n",
153 usb->fs_magic, MAJOR(sb->s_dev),
154 MINOR(sb->s_dev));
155 MOD_DEC_USE_COUNT;
156 return(NULL);
157 }
158
159
160
161
162
163 if (usb->fs_bsize != UFS_BSIZE) {
164 printk("ufs_read_super: fs_bsize %d != %d\n", usb->fs_bsize,
165 UFS_BSIZE);
166 goto ufs_read_super_lose;
167 }
168
169 if (usb->fs_fsize != UFS_FSIZE) {
170 printk("ufs_read_super: fs_fsize %d != %d\n", usb->fs_fsize,
171 UFS_FSIZE);
172 goto ufs_read_super_lose;
173 }
174
175 if (usb->fs_nindir != UFS_NINDIR) {
176 printk("ufs_read_super: fs_nindir %d != %d\n", usb->fs_nindir,
177 UFS_NINDIR);
178 printk("ufs_read_super: fucking Sun blows me\n");
179 }
180
181 printk("ufs_read_super: fs last mounted on \"%s\"\n", usb->fs_fsmnt);
182
183 if (usb->fs_state == UFS_FSOK - usb->fs_time) {
184 switch(usb->fs_clean) {
185 case UFS_FSCLEAN:
186 printk("ufs_read_super: fs is clean\n");
187 break;
188 case UFS_FSSTABLE:
189 printk("ufs_read_super: fs is stable\n");
190 break;
191 case UFS_FSACTIVE:
192 printk("ufs_read_super: fs is active\n");
193 sb->s_flags |= MS_RDONLY;
194 break;
195 case UFS_FSBAD:
196 printk("ufs_read_super: fs is bad\n");
197 sb->s_flags |= MS_RDONLY;
198 break;
199 default:
200 printk("ufs_read_super: can't grok fs_clean 0x%x\n",
201 usb->fs_clean);
202 sb->s_flags |= MS_RDONLY;
203 break;
204 }
205 } else {
206 printk("ufs_read_super: fs needs fsck\n");
207 sb->s_flags |= MS_RDONLY;
208
209 }
210
211
212
213 sb->s_blocksize = usb->fs_fsize;
214 sb->s_blocksize_bits = 10;
215
216 sb->s_op = &ufs_super_ops;
217 sb->dq_op = 0;
218 sb->s_magic = usb->fs_magic;
219
220
221
222 sb->u.ufs_sb.s_raw_sb = usb;
223 sb->u.ufs_sb.s_flags = 0;
224 sb->u.ufs_sb.s_ncg = usb->fs_ncg;
225 sb->u.ufs_sb.s_ipg = usb->fs_ipg;
226 sb->u.ufs_sb.s_fpg = usb->fs_fpg;
227 sb->u.ufs_sb.s_fsize = usb->fs_fsize;
228 sb->u.ufs_sb.s_bsize = usb->fs_bsize;
229 sb->u.ufs_sb.s_iblkno = usb->fs_iblkno;
230 sb->u.ufs_sb.s_dblkno = usb->fs_dblkno;
231 sb->u.ufs_sb.s_cgoffset = usb->fs_cgoffset;
232 sb->u.ufs_sb.s_cgmask = usb->fs_cgmask;
233 sb->u.ufs_sb.s_inopb = usb->fs_inopb;
234 sb->u.ufs_sb.s_fsfrag = usb->fs_frag;
235 sb->s_mounted = iget(sb, UFS_ROOTINO);
236
237 printk("ufs_read_super: inopb %u\n", sb->u.ufs_sb.s_inopb);
238
239
240
241
242 unlock_super(sb);
243 return(sb);
244
245 ufs_read_super_lose:
246
247 MOD_DEC_USE_COUNT;
248 return(NULL);
249 }
250
251 void ufs_put_super (struct super_block * sb)
252 {
253
254 printk("ufs_put_super\n");
255
256 lock_super (sb);
257
258 sb->s_dev = 0;
259
260
261
262 unlock_super (sb);
263 MOD_DEC_USE_COUNT;
264
265 return;
266 }
267
268 void ufs_statfs(struct super_block * sb, struct statfs * buf, int bufsiz)
269 {
270 struct statfs tmp;
271
272 printk("ufs_statfs\n");
273 tmp.f_type = sb->s_magic;
274 tmp.f_bsize = PAGE_SIZE;
275 tmp.f_blocks = sb->u.ufs_sb.s_raw_sb->fs_dsize;
276 tmp.f_bfree = sb->u.ufs_sb.s_raw_sb->fs_cstotal.cs_nbfree;
277 tmp.f_bavail = sb->u.ufs_sb.s_raw_sb->fs_cstotal.cs_nbfree;
278 tmp.f_files = sb->u.ufs_sb.s_ncg * sb->u.ufs_sb.s_ipg;
279 tmp.f_ffree = sb->u.ufs_sb.s_raw_sb->fs_cstotal.cs_nifree;
280 tmp.f_fsid.val[0] = sb->u.ufs_sb.s_raw_sb->fs_id[0];
281 tmp.f_fsid.val[1] = sb->u.ufs_sb.s_raw_sb->fs_id[1];
282 tmp.f_namelen = MAXNAMLEN;
283
284
285 memcpy_tofs(buf, &tmp, bufsiz);
286
287 return;
288 }
289
290
291
292
293
294
295
296
297
298
299