Rev 3 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | pj | 1 | /* |
2 | * Project: HARTIK (HA-rd R-eal TI-me K-ernel) |
||
3 | * |
||
4 | * Coordinators: Giorgio Buttazzo <giorgio@sssup.it> |
||
5 | * Gerardo Lamastra <gerardo@sssup.it> |
||
6 | * |
||
7 | * Authors : Massimiliano Giorgi <massy@hartik.sssup.it> |
||
8 | * (see authors.txt for full list of hartik's authors) |
||
9 | * |
||
10 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
11 | * |
||
12 | * http://www.sssup.it |
||
13 | * http://retis.sssup.it |
||
14 | * http://hartik.sssup.it |
||
15 | */ |
||
16 | |||
17 | /* |
||
18 | * Copyright (C) 1999 Massimiliano Giorgi |
||
19 | * |
||
20 | * This program is free software; you can redistribute it and/or modify |
||
21 | * it under the terms of the GNU General Public License as published by |
||
22 | * the Free Software Foundation; either version 2 of the License, or |
||
23 | * (at your option) any later version. |
||
24 | * |
||
25 | * This program is distributed in the hope that it will be useful, |
||
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
28 | * GNU General Public License for more details. |
||
29 | * |
||
30 | * You should have received a copy of the GNU General Public License |
||
31 | * along with this program; if not, write to the Free Software |
||
32 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
33 | * |
||
34 | */ |
||
35 | |||
36 | /* |
||
927 | pj | 37 | * CVS : $Id: msdos_s.c,v 1.2 2005-01-08 14:59:23 pj Exp $ |
2 | pj | 38 | * |
39 | * File: $File$ |
||
927 | pj | 40 | * Revision: $Revision: 1.2 $ |
41 | * Last update: $Date: 2005-01-08 14:59:23 $ |
||
2 | pj | 42 | */ |
43 | |||
44 | #include <fs/types.h> |
||
45 | #include <fs/const.h> |
||
46 | #include <fs/stat.h> |
||
47 | #include <fs/fsinit.h> |
||
48 | #include <fs/fsind.h> |
||
49 | #include <fs/util.h> |
||
50 | #include <fs/mount.h> |
||
51 | #include <fs/util.h> |
||
52 | #include <fs/mount.h> |
||
53 | #include <fs/assert.h> |
||
54 | |||
55 | #include "dcache.h" |
||
56 | #include "fs.h" |
||
57 | |||
58 | #include "msdos/msdos.h" |
||
59 | #include "msdos/msdos_s.h" |
||
60 | #include "msdos/msdos_i.h" |
||
61 | |||
62 | #define DEBUG_READSUPER KERN_DEBUG |
||
63 | #undef DEBUG_READSUPER |
||
64 | |||
65 | #ifdef DEBUG_READSUPER |
||
66 | #define printk0(fmt,args...) \ |
||
67 | printk(DEBUG_READSUPER fmt,##args) |
||
68 | #else |
||
69 | #define printk0(fmt,args...) |
||
70 | #endif |
||
71 | |||
72 | static struct super_block *msdos_read_super(__dev_t dev, __uint8_t fs_ind, |
||
73 | struct mount_opts *options); |
||
74 | |||
75 | static struct file_system_type msdosfs[]={ |
||
76 | {"fat16",0,FS_MSDOS,msdos_read_super}, |
||
77 | }; |
||
78 | /*{"fat16+",0,FS_DOSBIG,msdos_read_super}*/ |
||
79 | |||
80 | int msdos_fs_init(FILESYSTEM_PARMS *ptr) |
||
81 | { |
||
82 | int i; |
||
83 | for (i=0;i<sizeof(msdosfs)/sizeof(struct file_system_type);i++) |
||
84 | filesystem_register(msdosfs+i); |
||
85 | return 0; |
||
86 | } |
||
87 | |||
88 | |||
89 | /*-----------------------------------------*/ |
||
90 | |||
91 | /* |
||
92 | * boot record (akin to super block) |
||
93 | */ |
||
94 | |||
95 | struct bootrecord { |
||
96 | __uint8_t reserved[3]; |
||
97 | char oemname[8]; |
||
98 | __uint16_t bytespersector; |
||
99 | __uint8_t sectorspercluster; |
||
100 | __uint16_t hiddensectors; |
||
101 | __uint8_t fatsnumber; |
||
102 | __uint16_t rootentry; |
||
103 | __uint16_t sectors; |
||
104 | __uint8_t media; |
||
105 | __uint16_t sectorsperfat; |
||
106 | __uint16_t sectorpertrak; |
||
107 | __uint16_t headsperdisk; |
||
108 | __uint32_t hiddensectors32; |
||
109 | __uint32_t sectors32; |
||
110 | __uint16_t physicaldrive; |
||
111 | __uint8_t signature; |
||
112 | __uint8_t serialnumber[4]; |
||
113 | char volumelabel[11]; |
||
114 | char fattype[8]; |
||
115 | } __attribute__ ((packed)); |
||
116 | |||
117 | static char *chr2str(char *s, int n) |
||
118 | { |
||
119 | static char str[12]; |
||
120 | memcpy(str,s,n); |
||
121 | str[n]='\0'; |
||
122 | return str; |
||
123 | } |
||
124 | |||
125 | static __inline__ __uint32_t br_numhiddensectors(struct bootrecord *br) |
||
126 | { |
||
127 | return br->hiddensectors?(long)br->hiddensectors:(long)br->hiddensectors32; |
||
128 | } |
||
129 | |||
130 | static __inline__ __uint32_t br_numsectors(struct bootrecord *br) |
||
131 | { |
||
132 | return br->sectors?(long)br->sectors:(long)br->sectors32; |
||
133 | } |
||
134 | |||
135 | static void dump_br(struct bootrecord *br) __attribute__ ((unused)); |
||
136 | |||
137 | static void dump_br(struct bootrecord *br) |
||
138 | { |
||
139 | printk(KERN_DEBUG "oem : %s",chr2str(br->oemname,8)); |
||
140 | printk(KERN_DEBUG "label : %s",chr2str(br->volumelabel,11)); |
||
141 | printk(KERN_DEBUG "fat type: %s",chr2str(br->fattype,8)); |
||
142 | printk(KERN_DEBUG "serial : %02x%02x-%02x%02x",br->serialnumber[3], |
||
143 | br->serialnumber[2], |
||
144 | br->serialnumber[1], |
||
145 | br->serialnumber[0]); |
||
146 | printk(KERN_DEBUG "sector : %i bytes",(int)br->bytespersector); |
||
147 | printk(KERN_DEBUG "cluster : %i sectors",(int)br->sectorspercluster); |
||
148 | printk(KERN_DEBUG "fat : %i copies",(int)br->fatsnumber); |
||
149 | printk(KERN_DEBUG "root : %i sectors", |
||
150 | br->rootentry*32/br->bytespersector); |
||
151 | printk(KERN_DEBUG "fat : %i sectors",(int)br->sectorsperfat); |
||
152 | printk(KERN_DEBUG "hidden : %li sectors",br->hiddensectors? |
||
153 | (long)br->hiddensectors:(long)br->hiddensectors32); |
||
154 | printk(KERN_DEBUG "size : %li sectors",br->sectors? |
||
155 | (long)br->sectors:(long)br->sectors32); |
||
156 | |||
157 | } |
||
158 | |||
159 | /* from Linux */ |
||
160 | /* time,date conversions routine */ |
||
161 | |||
162 | static int day_n[]={ |
||
163 | 0,31,59,90,120,151,181,212,243,273,304,334,0,0,0,0 |
||
164 | }; |
||
165 | |||
166 | /* Convert a MS-DOS time/date pair to a UNIX date (seconds since 1 1 70). */ |
||
167 | __time_t date_dos2unix(__uint16_t time,__uint16_t date) |
||
168 | { |
||
169 | int month,year; |
||
170 | __time_t secs; |
||
171 | |||
172 | month = ((date >> 5) & 15)-1; |
||
173 | year = date >> 9; |
||
174 | secs = (time & 31)*2l+60l*((time >> 5) & 63)+(time >> 11)*3600l+86400l* |
||
175 | ((date & 31)-1+day_n[month]+(year/4l)+year*365l-((year & 3) == 0 && |
||
176 | month < 2 ? 1 : 0)+3653l); |
||
177 | /* days since 1.1.70 plus 80's leap day */ |
||
178 | /*secs += sys_tz.tz_minuteswest*60;*/ |
||
179 | /*if (sys_tz.tz_dsttime) secs -= 3600;*/ |
||
180 | return secs; |
||
181 | } |
||
182 | |||
183 | /* Convert linear UNIX date to a MS-DOS time/date pair. */ |
||
184 | void date_unix2dos(__time_t unix_date,__uint16_t *time, |
||
185 | __uint16_t *date) |
||
186 | { |
||
187 | int day,year,nl_day,month; |
||
188 | |||
189 | /*unix_date -= sys_tz.tz_minuteswest*60;*/ |
||
190 | /*if (sys_tz.tz_dsttime) unix_date += 3600;*/ |
||
191 | |||
192 | *time = (unix_date % 60)/2+(((unix_date/60) % 60) << 5)+ |
||
193 | (((unix_date/3600) % 24) << 11); |
||
194 | day = unix_date/86400-3652; |
||
195 | year = day/365; |
||
196 | if ((year+3)/4+365*year > day) year--; |
||
197 | day -= (year+3)/4+365*year; |
||
198 | if (day == 59 && !(year & 3)) { |
||
199 | nl_day = day; |
||
200 | month = 2; |
||
201 | } |
||
202 | else { |
||
203 | nl_day = (year & 3) || day <= 59 ? day : day-1; |
||
204 | for (month = 0; month < 12; month++) |
||
205 | if (day_n[month] > nl_day) break; |
||
206 | } |
||
207 | *date = nl_day-day_n[month-1]+1+(month << 5)+(year << 9); |
||
208 | } |
||
209 | |||
210 | /* |
||
211 | * |
||
212 | * Super operations |
||
213 | * |
||
214 | */ |
||
215 | |||
216 | static int msdos_init_inode(struct inode *in); |
||
217 | static int msdos_read_inode(struct inode *in); |
||
218 | static int msdos_write_inode(struct inode *in); |
||
219 | static int msdos_put_super(struct super_block *sb); |
||
220 | static int msdos_delete_inode(struct inode *in); |
||
221 | |||
222 | static struct super_operations msdos_super_operations={ |
||
223 | msdos_init_inode, |
||
224 | msdos_read_inode, |
||
225 | msdos_write_inode, |
||
226 | msdos_put_super, |
||
227 | msdos_delete_inode |
||
228 | }; |
||
229 | |||
230 | static int msdos_put_super(struct super_block *sb) |
||
231 | { |
||
232 | return 0; |
||
233 | } |
||
234 | |||
235 | static int msdos_init_inode(struct inode *in) |
||
236 | { |
||
237 | __uint16_t cluster; |
||
238 | __uint32_t lsector; |
||
239 | __uint16_t deoffs,offs; |
||
240 | |||
241 | /*i_sb gia' messo*/ |
||
242 | /*i_st.st_ino gia' messo*/ |
||
243 | cluster=INODE2CLUSTER(in->i_st.st_ino); |
||
244 | deoffs=INODE2DEOFFS(in->i_st.st_ino); |
||
245 | |||
246 | _assert(cluster!=ROOT_CLUSTER); |
||
247 | if (cluster==SPECIAL_CLUSTER) |
||
248 | lsector=MSDOS_SB(in->i_sb).lroot; |
||
249 | else |
||
250 | lsector=(cluster-2)*MSDOS_SB(in->i_sb).spc+MSDOS_SB(in->i_sb).ldata; |
||
251 | lsector+=(__uint16_t)(((__uint32_t)deoffs*DIRENTRYSIZE)/SECTORSIZE); |
||
252 | offs=(((__uint16_t)deoffs*DIRENTRYSIZE)%SECTORSIZE)/DIRENTRYSIZE; |
||
253 | |||
254 | MSDOS_I(in).lsector=lsector; |
||
255 | MSDOS_I(in).offs=offs; |
||
256 | |||
257 | in->i_st.st_dev=in->i_sb->sb_dev; |
||
258 | in->i_st.st_mode=__DEFFILEMODE; |
||
259 | in->i_st.st_mode|=__S_IFREG; |
||
260 | in->i_st.st_blksize=SECTORSIZE; |
||
261 | in->i_st.st_nlink=1; |
||
262 | in->i_st.st_uid=0; |
||
263 | in->i_st.st_gid=0; |
||
264 | in->i_st.st_size=0; |
||
265 | in->i_st.st_atime=in->i_st.st_mtime=in->i_st.st_ctime=0; |
||
266 | /* for safety */ |
||
267 | if (in->i_sb->sb_mopts.flags&MOUNT_FLAG_RW) |
||
268 | in->i_op=&msdos_inode_rw_operations; |
||
269 | else |
||
270 | in->i_op=&msdos_inode_ro_operations; |
||
271 | |||
272 | MSDOS_I(in).scluster=FREE_CLUSTER; |
||
273 | |||
274 | in->i_dirty=1; |
||
275 | return 0; |
||
276 | } |
||
277 | |||
278 | static int msdos_read_inode(struct inode *in) |
||
279 | { |
||
280 | struct directoryentry *den; |
||
281 | dcache_t *ptr; |
||
282 | __uint16_t cluster; |
||
283 | __uint32_t lsector; |
||
284 | __uint16_t deoffs,offs; |
||
285 | |||
286 | /*i_sb gia' messo*/ |
||
287 | /*i_st.st_ino gia' messo*/ |
||
288 | |||
289 | cluster=INODE2CLUSTER(in->i_st.st_ino); |
||
290 | deoffs=INODE2DEOFFS(in->i_st.st_ino); |
||
291 | if (cluster==ROOT_CLUSTER) { |
||
292 | /* special case: root inode */ |
||
293 | MSDOS_I(in).lsector=0; |
||
294 | MSDOS_I(in).offs=0; |
||
295 | MSDOS_I(in).scluster=ROOT_CLUSTER; |
||
296 | in->i_st.st_dev=in->i_sb->sb_dev; |
||
297 | in->i_st.st_mode=__S_IRWXO|__S_IRWXG|__S_IRWXU; |
||
298 | in->i_st.st_mode|=__S_IFDIR; |
||
299 | in->i_st.st_nlink=1+1; /* must be fixed */ |
||
300 | in->i_st.st_blksize=SECTORSIZE; |
||
301 | in->i_st.st_uid=0; |
||
302 | in->i_st.st_gid=0; |
||
303 | in->i_st.st_size=MSDOS_SB(in->i_sb).rootsect*SECTORSIZE; |
||
304 | in->i_st.st_atime=in->i_st.st_mtime=in->i_st.st_ctime=0; |
||
305 | |||
306 | /* for safety */ |
||
307 | if (in->i_sb->sb_mopts.flags&MOUNT_FLAG_RW) |
||
308 | in->i_op=&msdos_inode_rw_operations; |
||
309 | else |
||
310 | in->i_op=&msdos_inode_ro_operations; |
||
311 | |||
312 | in->i_dirty=0; |
||
313 | return 0; |
||
314 | } else if (cluster==SPECIAL_CLUSTER) { |
||
315 | /* special case: an inode on root directory */ |
||
316 | lsector=MSDOS_SB(in->i_sb).lroot; |
||
317 | } else { |
||
318 | /* normal inode */ |
||
319 | lsector=(cluster-2)*MSDOS_SB(in->i_sb).spc+MSDOS_SB(in->i_sb).ldata; |
||
320 | } |
||
321 | lsector+=(__uint16_t)(((__uint32_t)deoffs*DIRENTRYSIZE)/SECTORSIZE); |
||
322 | offs=(((__uint16_t)deoffs*DIRENTRYSIZE)%SECTORSIZE)/DIRENTRYSIZE; |
||
323 | |||
324 | MSDOS_I(in).lsector=lsector; |
||
325 | MSDOS_I(in).offs=offs; |
||
326 | |||
327 | ptr=dcache_lock(in->i_sb->sb_dev,lsector); |
||
328 | if (ptr==NULL) return -1; |
||
329 | den=(struct directoryentry *)(ptr->buffer)+offs; |
||
330 | |||
331 | in->i_st.st_dev=in->i_sb->sb_dev; |
||
332 | in->i_st.st_mode=__S_IRWXO|__S_IRWXG|__S_IRWXU; |
||
333 | in->i_st.st_mode|=(den->attribute&ATTR_DIR?__S_IFDIR:__S_IFREG); |
||
334 | in->i_st.st_nlink=1+(__S_ISDIR(in->i_st.st_mode)?1:0); /* must be fixed */ |
||
335 | in->i_st.st_blksize=SECTORSIZE; |
||
336 | in->i_st.st_uid=0; |
||
337 | in->i_st.st_gid=0; |
||
338 | in->i_st.st_size=den->size; |
||
339 | in->i_st.st_atime=in->i_st.st_mtime=in->i_st.st_ctime= |
||
340 | date_dos2unix(den->time,den->date); |
||
341 | /* for safety */ |
||
342 | if (in->i_sb->sb_mopts.flags&MOUNT_FLAG_RW) |
||
343 | in->i_op=&msdos_inode_rw_operations; |
||
344 | else |
||
345 | in->i_op=&msdos_inode_ro_operations; |
||
346 | |||
347 | if (den->cluster==FREECLUSTER) |
||
348 | MSDOS_I(in).scluster=FREE_CLUSTER; |
||
349 | else |
||
350 | MSDOS_I(in).scluster=den->cluster; |
||
351 | |||
352 | in->i_dirty=0; |
||
353 | dcache_unlock(ptr); |
||
354 | return 0; |
||
355 | } |
||
356 | |||
357 | static int msdos_write_inode(struct inode *in) |
||
358 | { |
||
359 | struct directoryentry *den; |
||
360 | dcache_t *ptr; |
||
361 | __uint16_t cluster; |
||
362 | |||
363 | cluster=INODE2CLUSTER(in->i_st.st_ino); |
||
364 | if (cluster==ROOT_CLUSTER) return 0; |
||
365 | |||
366 | ptr=dcache_acquire(in->i_sb->sb_dev,MSDOS_I(in).lsector); |
||
367 | if (ptr==NULL) { |
||
368 | dcache_release(ptr); |
||
369 | return -1; |
||
370 | } |
||
371 | den=(struct directoryentry *)(ptr->buffer)+MSDOS_I(in).offs; |
||
372 | |||
373 | //printk("writing inode\n start cluster=0x%04x\n",MSDOS_I(in).scluster); |
||
374 | |||
375 | cluster=MSDOS_I(in).scluster; |
||
376 | _assert(cluster!=NO_CLUSTER&& |
||
377 | cluster!=ROOT_CLUSTER&& |
||
378 | cluster!=SPECIAL_CLUSTER); |
||
379 | if (cluster==FREE_CLUSTER) cluster=FREECLUSTER; |
||
380 | |||
381 | date_unix2dos(in->i_st.st_atime,&den->time,&den->date); |
||
382 | den->cluster=cluster; |
||
383 | den->size=in->i_st.st_size; |
||
384 | |||
385 | in->i_dirty=0; |
||
386 | dcache_dirty(ptr); |
||
387 | |||
388 | dcache_release(ptr); |
||
389 | return 0; |
||
390 | } |
||
391 | |||
392 | static int msdos_delete_inode(struct inode *in) |
||
393 | { |
||
394 | struct directoryentry *den; |
||
395 | dcache_t *ptr; |
||
396 | __uint16_t cluster; |
||
397 | |||
398 | cluster=INODE2CLUSTER(in->i_st.st_ino); |
||
399 | if (cluster==ROOT_CLUSTER) return 0; |
||
400 | |||
401 | ptr=dcache_acquire(in->i_sb->sb_dev,MSDOS_I(in).lsector); |
||
402 | if (ptr==NULL) { |
||
403 | dcache_release(ptr); |
||
404 | return -1; |
||
405 | } |
||
406 | den=(struct directoryentry *)(ptr->buffer)+MSDOS_I(in).offs; |
||
407 | |||
408 | msdos_markentryfree(den); |
||
409 | |||
410 | dcache_dirty(ptr); |
||
411 | dcache_release(ptr); |
||
412 | return 0; |
||
413 | |||
414 | } |
||
415 | |||
416 | static int msdos_dump_inode(struct inode *in) __attribute__((unused)); |
||
417 | |||
418 | static int msdos_dump_inode(struct inode *in) |
||
419 | { |
||
420 | printk(KERN_DEBUG "dev : %i",in->i_st.st_dev); |
||
421 | printk(KERN_DEBUG "inode : %08lx",(long)in->i_st.st_ino); |
||
422 | printk(KERN_DEBUG "mode : %04x",in->i_st.st_mode); |
||
423 | printk(KERN_DEBUG "nlink : %i",in->i_st.st_nlink); |
||
424 | printk(KERN_DEBUG "uid : %i",in->i_st.st_uid); |
||
425 | printk(KERN_DEBUG "gid : %i",in->i_st.st_gid); |
||
426 | //printk(KERN_DEBUG "rdev : %i",in->i_st.st_rdev); |
||
427 | printk(KERN_DEBUG "size : %li",in->i_st.st_size); |
||
428 | printk(KERN_DEBUG "atime : %li",(long)in->i_st.st_atime); |
||
429 | printk(KERN_DEBUG "mtime : %li",(long)in->i_st.st_mtime); |
||
430 | printk(KERN_DEBUG "ctime : %li",(long)in->i_st.st_ctime); |
||
431 | |||
432 | printk(KERN_DEBUG "lsect : %li",(long)MSDOS_I(in).lsector); |
||
433 | printk(KERN_DEBUG "off : %li",(long)MSDOS_I(in).offs); |
||
434 | printk(KERN_DEBUG "sclust: %li",(long)MSDOS_I(in).scluster); |
||
435 | |||
436 | return 0; |
||
437 | } |
||
438 | |||
439 | /* |
||
440 | * |
||
441 | * Mount operation |
||
442 | * |
||
443 | */ |
||
444 | |||
445 | #define MSDOSSBSIGNATURE 0x29 |
||
446 | |||
447 | static struct super_block *msdos_read_super(__dev_t dev, __uint8_t fs_ind, |
||
448 | struct mount_opts *opts) |
||
449 | { |
||
450 | struct inode *in; |
||
451 | struct bootrecord *br; |
||
452 | struct super_block *sb; |
||
453 | dcache_t *dc; |
||
454 | int res; |
||
455 | |||
456 | printk0("msdos_read_super(): START"); |
||
457 | |||
458 | dc=dcache_lock(dev,0); |
||
459 | if (dc==NULL) { |
||
460 | printk(KERN_DEBUG "msdos_read_super FAIL: can't read/lock cache"); |
||
461 | return NULL; |
||
462 | } |
||
463 | br=(struct bootrecord*)dc->buffer; |
||
464 | if (br->fatsnumber>MAXFATS) { |
||
465 | dcache_unlock(dc); |
||
466 | printk(KERN_DEBUG "msdos_read_super FAIL: too many FATS (%i)", |
||
467 | br->fatsnumber); |
||
468 | return NULL; |
||
469 | } |
||
470 | if (br->signature!=MSDOSSBSIGNATURE) { |
||
471 | dcache_unlock(dc); |
||
472 | printk(KERN_DEBUG "msdos_read_super FAIL: can't find MSDOS signature"); |
||
473 | return NULL; |
||
474 | } |
||
475 | |||
476 | printk0("msdos_read_super(): boot sector locked"); |
||
477 | |||
478 | sb=super_getblock(); |
||
479 | if (sb==NULL) { |
||
480 | dcache_unlock(dc); |
||
481 | printk(KERN_DEBUG "msdos_read_super FAIL: can't have a super struct"); |
||
482 | return NULL; |
||
483 | } |
||
484 | |||
485 | printk0("msdos_read_super(): super structure allocated"); |
||
486 | |||
487 | if (opts==NULL) {msdosfs_std_parms(sb->sb_mopts);} |
||
488 | else memcpy(&sb->sb_mopts,opts,sizeof(struct mount_opts)); |
||
489 | |||
490 | sb->sb_dev=dev; |
||
491 | sb->sb_op=&msdos_super_operations; |
||
492 | sb->sb_dop=&msdos_dentry_operations; |
||
493 | |||
494 | MSDOS_SB(sb).lfat=br_numhiddensectors(br); |
||
495 | MSDOS_SB(sb).lroot=MSDOS_SB(sb).lfat+ |
||
496 | (__uint32_t)br->sectorsperfat*br->fatsnumber; |
||
497 | MSDOS_SB(sb).ldata=MSDOS_SB(sb).lroot+ |
||
498 | br->rootentry*DIRENTRYSIZE/br->bytespersector; |
||
499 | MSDOS_SB(sb).lsize=br_numsectors(br)+br_numhiddensectors(br); |
||
500 | MSDOS_SB(sb).spc=br->sectorspercluster; |
||
501 | MSDOS_SB(sb).rootsect=(__uint32_t)br->rootentry*DIRENTRYSIZE/ |
||
502 | br->bytespersector; |
||
503 | MSDOS_SB(sb).spf=br->sectorsperfat; |
||
504 | MSDOS_SB(sb).nfat=br->fatsnumber; |
||
505 | MSDOS_SB(sb).stclust=STARTCLUSTER; |
||
506 | |||
507 | printk0("msdos_read_super(): super structure filled"); |
||
508 | |||
509 | in=catch_inode(); |
||
510 | if (in==NULL) { |
||
511 | super_freeblock(sb); |
||
512 | dcache_unlock(dc); |
||
513 | printk(KERN_DEBUG "msdos_read_super FAIL: can't have an inode struct"); |
||
514 | return NULL; |
||
515 | } |
||
516 | |||
517 | printk0("msdos_read_super(): inode structure allocated"); |
||
518 | |||
519 | sb->sb_root=in; |
||
520 | in->i_sb=sb; |
||
521 | in->i_st.st_ino=ROOT_INODE; |
||
522 | res=msdos_read_inode(in); |
||
523 | if (res!=0) { |
||
524 | free_inode(in); |
||
525 | super_freeblock(sb); |
||
526 | dcache_unlock(dc); |
||
527 | printk(KERN_DEBUG "msdos_read_super FAIL: can't read inode"); |
||
528 | return NULL; |
||
529 | } |
||
530 | |||
531 | printk0("msdos_read_super(): root inode read"); |
||
532 | |||
533 | insert_inode(in); |
||
534 | |||
535 | printk0("msdos_read_super(): root inode inserted"); |
||
536 | |||
537 | dcache_unlock(dc); |
||
538 | printk0("msdos_read_super(): boot sector released"); |
||
539 | printk0("msdos_read_super(): END"); |
||
540 | return sb; |
||
541 | } |
||
542 | |||
543 | |||
544 | /* to remove */ |
||
545 | /* |
||
546 | { |
||
547 | struct qstr str; |
||
548 | struct inode *in2,*in3,*in4; |
||
549 | struct dentry *d; |
||
550 | |||
551 | extern struct inode *msdos_lookup(struct inode *, struct dentry *); |
||
552 | |||
553 | printk(KERN_DEBUG "---ROOT INODE---\n"); |
||
554 | msdos_dump_inode(in); |
||
555 | |||
556 | d=get_dentry(); |
||
557 | if (d!=NULL) { |
||
927 | pj | 558 | exit(1234); |
2 | pj | 559 | } |
560 | strcpy(d->d_name.name,"BC45"); |
||
561 | d->d_name.nameptr=NULL; |
||
562 | d->d_op=&msdos_dentry_operations; |
||
563 | |||
564 | printk(KERN_DEBUG "searching --------------------------\n"); |
||
565 | in2=msdos_lookup(in,d); |
||
566 | if (in2!=NULL) printk(KERN_DEBUG "found!\n"); |
||
567 | else printk(KERN_DEBUG "not found!\n"); |
||
568 | |||
569 | printk(KERN_DEBUG "---IN2 INODE---\n"); |
||
570 | msdos_dump_inode(in2); |
||
571 | |||
572 | printk(KERN_DEBUG "searching --------------------------\n"); |
||
573 | strcpy(d->d_name.name,"BIN"); |
||
574 | in3=msdos_lookup(in2,d); |
||
575 | if (in3!=NULL) printk(KERN_DEBUG "found!\n"); |
||
576 | else printk(KERN_DEBUG "not found!\n"); |
||
577 | |||
578 | printk(KERN_DEBUG "---IN3 INODE---\n"); |
||
579 | msdos_dump_inode(in3); |
||
580 | |||
581 | printk(KERN_DEBUG "searching --------------------------\n"); |
||
582 | strcpy(d->d_name.name,"pspsp"); |
||
583 | in4=msdos_lookup(in3,d); |
||
584 | if (in4!=NULL) printk(KERN_DEBUG "found!\n"); |
||
585 | else printk(KERN_DEBUG "not found!\n"); |
||
586 | |||
587 | printk(KERN_DEBUG "---IN4 INODE---\n"); |
||
588 | msdos_dump_inode(in4); |
||
589 | |||
590 | } |
||
591 | */ |
||
592 | /* end to remove */ |