Import 2.3.48
[davej-history.git] / fs / isofs / inode.c
blobb4a633e9fc09f1005d5c430ca59867ea5283005a
1 /*
2 * linux/fs/isofs/inode.c
4 * (C) 1991 Linus Torvalds - minix filesystem
5 * 1992, 1993, 1994 Eric Youngdale Modified for ISO 9660 filesystem.
6 * 1994 Eberhard Moenkeberg - multi session handling.
7 * 1995 Mark Dobie - allow mounting of some weird VideoCDs and PhotoCDs.
8 * 1997 Gordon Chaffee - Joliet CDs
9 * 1998 Eric Lammerts - ISO 9660 Level 3
12 #include <linux/config.h>
13 #include <linux/module.h>
15 #include <linux/stat.h>
16 #include <linux/sched.h>
17 #include <linux/iso_fs.h>
18 #include <linux/kernel.h>
19 #include <linux/major.h>
20 #include <linux/mm.h>
21 #include <linux/string.h>
22 #include <linux/locks.h>
23 #include <linux/malloc.h>
24 #include <linux/errno.h>
25 #include <linux/cdrom.h>
26 #include <linux/init.h>
27 #include <linux/nls.h>
28 #include <linux/ctype.h>
29 #include <linux/smp_lock.h>
31 #include <asm/system.h>
32 #include <asm/uaccess.h>
35 * We have no support for "multi volume" CDs, but more and more disks carry
36 * wrong information within the volume descriptors.
38 #define IGNORE_WRONG_MULTI_VOLUME_SPECS
39 #define BEQUIET
41 #ifdef LEAK_CHECK
42 static int check_malloc = 0;
43 static int check_bread = 0;
44 #endif
46 static int isofs_hashi(struct dentry *parent, struct qstr *qstr);
47 static int isofs_hash(struct dentry *parent, struct qstr *qstr);
48 static int isofs_cmpi(struct dentry *dentry, struct qstr *a, struct qstr *b);
49 static int isofs_cmp(struct dentry *dentry, struct qstr *a, struct qstr *b);
51 #ifdef CONFIG_JOLIET
52 static int isofs_hashi_ms(struct dentry *parent, struct qstr *qstr);
53 static int isofs_hash_ms(struct dentry *parent, struct qstr *qstr);
54 static int isofs_cmpi_ms(struct dentry *dentry, struct qstr *a, struct qstr *b);
55 static int isofs_cmp_ms(struct dentry *dentry, struct qstr *a, struct qstr *b);
56 #endif
58 static void isofs_put_super(struct super_block *sb)
60 #ifdef CONFIG_JOLIET
61 if (sb->u.isofs_sb.s_nls_iocharset) {
62 unload_nls(sb->u.isofs_sb.s_nls_iocharset);
63 sb->u.isofs_sb.s_nls_iocharset = NULL;
65 #endif
67 #ifdef LEAK_CHECK
68 printk("Outstanding mallocs:%d, outstanding buffers: %d\n",
69 check_malloc, check_bread);
70 #endif
72 MOD_DEC_USE_COUNT;
73 return;
76 static void isofs_read_inode(struct inode *);
77 static int isofs_statfs (struct super_block *, struct statfs *, int);
79 static struct super_operations isofs_sops = {
80 read_inode: isofs_read_inode,
81 put_super: isofs_put_super,
82 statfs: isofs_statfs,
85 static struct dentry_operations isofs_dentry_ops[] = {
87 NULL, /* d_revalidate */
88 isofs_hash,
89 isofs_cmp,
90 NULL /* d_delete */
93 NULL, /* d_revalidate */
94 isofs_hashi,
95 isofs_cmpi,
96 NULL /* d_delete */
98 #ifdef CONFIG_JOLIET
100 NULL, /* d_revalidate */
101 isofs_hash_ms,
102 isofs_cmp_ms,
103 NULL /* d_delete */
106 NULL, /* d_revalidate */
107 isofs_hashi_ms,
108 isofs_cmpi_ms,
109 NULL /* d_delete */
111 #endif
114 struct iso9660_options{
115 char map;
116 char rock;
117 char joliet;
118 char cruft;
119 char unhide;
120 unsigned char check;
121 unsigned int blocksize;
122 mode_t mode;
123 gid_t gid;
124 uid_t uid;
125 char *iocharset;
126 unsigned char utf8;
127 /* LVE */
128 s32 session;
129 s32 sbsector;
133 * Compute the hash for the isofs name corresponding to the dentry.
135 static int
136 isofs_hash_common(struct dentry *dentry, struct qstr *qstr, int ms)
138 const char *name;
139 int len;
141 len = qstr->len;
142 name = qstr->name;
143 if (ms) {
144 while (len && name[len-1] == '.')
145 len--;
148 qstr->hash = full_name_hash(name, len);
150 return 0;
154 * Compute the hash for the isofs name corresponding to the dentry.
156 static int
157 isofs_hashi_common(struct dentry *dentry, struct qstr *qstr, int ms)
159 const char *name;
160 int len;
161 char c;
162 unsigned long hash;
164 len = qstr->len;
165 name = qstr->name;
166 if (ms) {
167 while (len && name[len-1] == '.')
168 len--;
171 hash = init_name_hash();
172 while (len--) {
173 c = tolower(*name++);
174 hash = partial_name_hash(tolower(c), hash);
176 qstr->hash = end_name_hash(hash);
178 return 0;
182 * Case insensitive compare of two isofs names.
184 static int
185 isofs_cmpi_common(struct dentry *dentry,struct qstr *a,struct qstr *b,int ms)
187 int alen, blen;
189 /* A filename cannot end in '.' or we treat it like it has none */
190 alen = a->len;
191 blen = b->len;
192 if (ms) {
193 while (alen && a->name[alen-1] == '.')
194 alen--;
195 while (blen && b->name[blen-1] == '.')
196 blen--;
198 if (alen == blen) {
199 if (strnicmp(a->name, b->name, alen) == 0)
200 return 0;
202 return 1;
206 * Case sensitive compare of two isofs names.
208 static int
209 isofs_cmp_common(struct dentry *dentry,struct qstr *a,struct qstr *b,int ms)
211 int alen, blen;
213 /* A filename cannot end in '.' or we treat it like it has none */
214 alen = a->len;
215 blen = b->len;
216 if (ms) {
217 while (alen && a->name[alen-1] == '.')
218 alen--;
219 while (blen && b->name[blen-1] == '.')
220 blen--;
222 if (alen == blen) {
223 if (strncmp(a->name, b->name, alen) == 0)
224 return 0;
226 return 1;
229 static int
230 isofs_hash(struct dentry *dentry, struct qstr *qstr)
232 return isofs_hash_common(dentry, qstr, 0);
235 static int
236 isofs_hashi(struct dentry *dentry, struct qstr *qstr)
238 return isofs_hashi_common(dentry, qstr, 0);
241 static int
242 isofs_cmp(struct dentry *dentry,struct qstr *a,struct qstr *b)
244 return isofs_cmp_common(dentry, a, b, 0);
247 static int
248 isofs_cmpi(struct dentry *dentry,struct qstr *a,struct qstr *b)
250 return isofs_cmpi_common(dentry, a, b, 0);
253 #ifdef CONFIG_JOLIET
254 static int
255 isofs_hash_ms(struct dentry *dentry, struct qstr *qstr)
257 return isofs_hash_common(dentry, qstr, 1);
260 static int
261 isofs_hashi_ms(struct dentry *dentry, struct qstr *qstr)
263 return isofs_hashi_common(dentry, qstr, 1);
266 static int
267 isofs_cmp_ms(struct dentry *dentry,struct qstr *a,struct qstr *b)
269 return isofs_cmp_common(dentry, a, b, 1);
272 static int
273 isofs_cmpi_ms(struct dentry *dentry,struct qstr *a,struct qstr *b)
275 return isofs_cmpi_common(dentry, a, b, 1);
277 #endif
279 static int parse_options(char *options, struct iso9660_options * popt)
281 char *this_char,*value;
283 popt->map = 'n';
284 popt->rock = 'y';
285 popt->joliet = 'y';
286 popt->cruft = 'n';
287 popt->unhide = 'n';
288 popt->check = 'u'; /* unset */
289 popt->blocksize = 1024;
290 popt->mode = S_IRUGO | S_IXUGO; /* r-x for all. The disc could
291 be shared with DOS machines so
292 virtually anything could be
293 a valid executable. */
294 popt->gid = 0;
295 popt->uid = 0;
296 popt->iocharset = NULL;
297 popt->utf8 = 0;
298 popt->session=-1;
299 popt->sbsector=-1;
300 if (!options) return 1;
301 for (this_char = strtok(options,","); this_char; this_char = strtok(NULL,",")) {
302 if (strncmp(this_char,"norock",6) == 0) {
303 popt->rock = 'n';
304 continue;
306 if (strncmp(this_char,"nojoliet",8) == 0) {
307 popt->joliet = 'n';
308 continue;
310 if (strncmp(this_char,"unhide",6) == 0) {
311 popt->unhide = 'y';
312 continue;
314 if (strncmp(this_char,"cruft",5) == 0) {
315 popt->cruft = 'y';
316 continue;
318 if (strncmp(this_char,"utf8",4) == 0) {
319 popt->utf8 = 1;
320 continue;
322 if ((value = strchr(this_char,'=')) != NULL)
323 *value++ = 0;
325 #ifdef CONFIG_JOLIET
326 if (!strcmp(this_char,"iocharset") && value) {
327 popt->iocharset = value;
328 while (*value && *value != ',')
329 value++;
330 if (value == popt->iocharset)
331 return 0;
332 *value = 0;
333 } else
334 #endif
335 if (!strcmp(this_char,"map") && value) {
336 if (value[0] && !value[1] && strchr("ano",*value))
337 popt->map = *value;
338 else if (!strcmp(value,"off")) popt->map = 'o';
339 else if (!strcmp(value,"normal")) popt->map = 'n';
340 else if (!strcmp(value,"acorn")) popt->map = 'a';
341 else return 0;
343 if (!strcmp(this_char,"session") && value) {
344 char * vpnt = value;
345 unsigned int ivalue = simple_strtoul(vpnt, &vpnt, 0);
346 if(ivalue < 0 || ivalue >99) return 0;
347 popt->session=ivalue+1;
349 if (!strcmp(this_char,"sbsector") && value) {
350 char * vpnt = value;
351 unsigned int ivalue = simple_strtoul(vpnt, &vpnt, 0);
352 if(ivalue < 0 || ivalue >660*512) return 0;
353 popt->sbsector=ivalue;
355 else if (!strcmp(this_char,"check") && value) {
356 if (value[0] && !value[1] && strchr("rs",*value))
357 popt->check = *value;
358 else if (!strcmp(value,"relaxed")) popt->check = 'r';
359 else if (!strcmp(value,"strict")) popt->check = 's';
360 else return 0;
362 else if (!strcmp(this_char,"conv") && value) {
363 /* no conversion is done anymore;
364 we still accept the same mount options,
365 but ignore them */
366 if (value[0] && !value[1] && strchr("btma",*value)) ;
367 else if (!strcmp(value,"binary")) ;
368 else if (!strcmp(value,"text")) ;
369 else if (!strcmp(value,"mtext")) ;
370 else if (!strcmp(value,"auto")) ;
371 else return 0;
373 else if (value &&
374 (!strcmp(this_char,"block") ||
375 !strcmp(this_char,"mode") ||
376 !strcmp(this_char,"uid") ||
377 !strcmp(this_char,"gid"))) {
378 char * vpnt = value;
379 unsigned int ivalue = simple_strtoul(vpnt, &vpnt, 0);
380 if (*vpnt) return 0;
381 switch(*this_char) {
382 case 'b':
383 if ( ivalue != 512
384 && ivalue != 1024
385 && ivalue != 2048) return 0;
386 popt->blocksize = ivalue;
387 break;
388 case 'u':
389 popt->uid = ivalue;
390 break;
391 case 'g':
392 popt->gid = ivalue;
393 break;
394 case 'm':
395 popt->mode = ivalue;
396 break;
399 else return 1;
401 return 1;
405 * look if the driver can tell the multi session redirection value
407 * don't change this if you don't know what you do, please!
408 * Multisession is legal only with XA disks.
409 * A non-XA disk with more than one volume descriptor may do it right, but
410 * usually is written in a nowhere standardized "multi-partition" manner.
411 * Multisession uses absolute addressing (solely the first frame of the whole
412 * track is #0), multi-partition uses relative addressing (each first frame of
413 * each track is #0), and a track is not a session.
415 * A broken CDwriter software or drive firmware does not set new standards,
416 * at least not if conflicting with the existing ones.
418 * emoenke@gwdg.de
420 #define WE_OBEY_THE_WRITTEN_STANDARDS 1
422 static unsigned int isofs_get_last_session(struct super_block *sb,s32 session )
424 struct cdrom_multisession ms_info;
425 unsigned int vol_desc_start;
426 struct block_device *bdev = sb->s_bdev;
427 kdev_t dev = sb->s_dev;
428 int i;
430 vol_desc_start=0;
431 ms_info.addr_format=CDROM_LBA;
432 /* If a minor device was explicitly opened, set session to the
433 * minor number. For instance, if /dev/hdc1 is mounted, session
434 * 1 on the CD-ROM is selected. CD_PART_MAX gives access to
435 * a max of 64 sessions on IDE. SCSI drives must still use
436 * the session option to mount.
438 if ((MINOR(dev) % CD_PART_MAX) && (MAJOR(dev) != SCSI_CDROM_MAJOR))
439 session = MINOR(dev) % CD_PART_MAX;
440 if(session >= 0 && session <= 99) {
441 struct cdrom_tocentry Te;
442 Te.cdte_track=session;
443 Te.cdte_format=CDROM_LBA;
444 i = ioctl_by_bdev(bdev, CDROMREADTOCENTRY, (unsigned long) &Te);
445 if (!i) {
446 printk(KERN_DEBUG "Session %d start %d type %d\n",
447 session, Te.cdte_addr.lba,
448 Te.cdte_ctrl&CDROM_DATA_TRACK);
449 if ((Te.cdte_ctrl&CDROM_DATA_TRACK) == 4)
450 return Te.cdte_addr.lba;
453 printk(KERN_ERR "Invalid session number or type of track\n");
455 i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long) &ms_info);
456 if(session > 0) printk(KERN_ERR "Invalid session number\n");
457 #if 0
458 printk("isofs.inode: CDROMMULTISESSION: rc=%d\n",i);
459 if (i==0) {
460 printk("isofs.inode: XA disk: %s\n",ms_info.xa_flag?"yes":"no");
461 printk("isofs.inode: vol_desc_start = %d\n", ms_info.addr.lba);
463 #endif
464 if (i==0)
465 #if WE_OBEY_THE_WRITTEN_STANDARDS
466 if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */
467 #endif
468 vol_desc_start=ms_info.addr.lba;
469 return vol_desc_start;
473 * Initialize the superblock and read the root inode.
475 * Note: a check_disk_change() has been done immediately prior
476 * to this call, so we don't need to check again.
478 static struct super_block *isofs_read_super(struct super_block *s, void *data,
479 int silent)
481 kdev_t dev = s->s_dev;
482 struct buffer_head * bh = NULL, *pri_bh = NULL;
483 struct hs_primary_descriptor * h_pri = NULL;
484 struct iso_primary_descriptor * pri = NULL;
485 struct iso_supplementary_descriptor *sec = NULL;
486 struct iso_directory_record * rootp;
487 int joliet_level = 0;
488 int high_sierra;
489 int iso_blknum, block;
490 int orig_zonesize;
491 int table;
492 unsigned int blocksize, blocksize_bits;
493 unsigned int vol_desc_start;
494 unsigned long first_data_zone;
495 struct inode * inode;
496 struct iso9660_options opt;
498 MOD_INC_USE_COUNT;
499 /* lock before any blocking operations */
500 lock_super(s);
502 if (!parse_options((char *) data, &opt))
503 goto out_unlock;
505 #if 0
506 printk("map = %c\n", opt.map);
507 printk("rock = %c\n", opt.rock);
508 printk("joliet = %c\n", opt.joliet);
509 printk("check = %c\n", opt.check);
510 printk("cruft = %c\n", opt.cruft);
511 printk("unhide = %c\n", opt.unhide);
512 printk("blocksize = %d\n", opt.blocksize);
513 printk("gid = %d\n", opt.gid);
514 printk("uid = %d\n", opt.uid);
515 printk("iocharset = %s\n", opt.iocharset);
516 #endif
519 * First of all, get the hardware blocksize for this device.
520 * If we don't know what it is, or the hardware blocksize is
521 * larger than the blocksize the user specified, then use
522 * that value.
524 blocksize = get_hardblocksize(dev);
525 if( (blocksize != 0)
526 && (blocksize > opt.blocksize) )
529 * Force the blocksize we are going to use to be the
530 * hardware blocksize.
532 opt.blocksize = blocksize;
535 blocksize_bits = 0;
537 int i = opt.blocksize;
538 while (i != 1){
539 blocksize_bits++;
540 i >>=1;
544 set_blocksize(dev, opt.blocksize);
546 s->u.isofs_sb.s_high_sierra = high_sierra = 0; /* default is iso9660 */
548 vol_desc_start = (opt.sbsector != -1) ?
549 opt.sbsector : isofs_get_last_session(s,opt.session);
551 for (iso_blknum = vol_desc_start+16;
552 iso_blknum < vol_desc_start+100; iso_blknum++)
554 struct hs_volume_descriptor * hdp;
555 struct iso_volume_descriptor * vdp;
557 block = iso_blknum << (ISOFS_BLOCK_BITS-blocksize_bits);
558 if (!(bh = bread(dev, block, opt.blocksize)))
559 goto out_no_read;
561 vdp = (struct iso_volume_descriptor *)bh->b_data;
562 hdp = (struct hs_volume_descriptor *)bh->b_data;
564 /* Due to the overlapping physical location of the descriptors,
565 * ISO CDs can match hdp->id==HS_STANDARD_ID as well. To ensure
566 * proper identification in this case, we first check for ISO.
568 if (strncmp (vdp->id, ISO_STANDARD_ID, sizeof vdp->id) == 0) {
569 if (isonum_711 (vdp->type) == ISO_VD_END)
570 break;
571 if (isonum_711 (vdp->type) == ISO_VD_PRIMARY) {
572 if (pri == NULL) {
573 pri = (struct iso_primary_descriptor *)vdp;
574 /* Save the buffer in case we need it ... */
575 pri_bh = bh;
576 bh = NULL;
579 #ifdef CONFIG_JOLIET
580 else if (isonum_711 (vdp->type) == ISO_VD_SUPPLEMENTARY) {
581 sec = (struct iso_supplementary_descriptor *)vdp;
582 if (sec->escape[0] == 0x25 && sec->escape[1] == 0x2f) {
583 if (opt.joliet == 'y') {
584 if (sec->escape[2] == 0x40) {
585 joliet_level = 1;
586 } else if (sec->escape[2] == 0x43) {
587 joliet_level = 2;
588 } else if (sec->escape[2] == 0x45) {
589 joliet_level = 3;
591 printk(KERN_DEBUG"ISO 9660 Extensions: Microsoft Joliet Level %d\n",
592 joliet_level);
594 goto root_found;
595 } else {
596 /* Unknown supplementary volume descriptor */
597 sec = NULL;
600 #endif
601 } else {
602 if (strncmp (hdp->id, HS_STANDARD_ID, sizeof hdp->id) == 0) {
603 if (isonum_711 (hdp->type) != ISO_VD_PRIMARY)
604 goto out_freebh;
606 s->u.isofs_sb.s_high_sierra = 1;
607 high_sierra = 1;
608 opt.rock = 'n';
609 h_pri = (struct hs_primary_descriptor *)vdp;
610 goto root_found;
614 /* Just skip any volume descriptors we don't recognize */
616 brelse(bh);
617 bh = NULL;
620 * If we fall through, either no volume descriptor was found,
621 * or else we passed a primary descriptor looking for others.
623 if (!pri)
624 goto out_unknown_format;
625 brelse(bh);
626 bh = pri_bh;
627 pri_bh = NULL;
629 root_found:
630 brelse(pri_bh);
632 if (joliet_level && opt.rock == 'n') {
633 /* This is the case of Joliet with the norock mount flag.
634 * A disc with both Joliet and Rock Ridge is handled later
636 pri = (struct iso_primary_descriptor *) sec;
639 if(high_sierra){
640 rootp = (struct iso_directory_record *) h_pri->root_directory_record;
641 #ifndef IGNORE_WRONG_MULTI_VOLUME_SPECS
642 if (isonum_723 (h_pri->volume_set_size) != 1)
643 goto out_no_support;
644 #endif IGNORE_WRONG_MULTI_VOLUME_SPECS
645 s->u.isofs_sb.s_nzones = isonum_733 (h_pri->volume_space_size);
646 s->u.isofs_sb.s_log_zone_size = isonum_723 (h_pri->logical_block_size);
647 s->u.isofs_sb.s_max_size = isonum_733(h_pri->volume_space_size);
648 } else {
649 rootp = (struct iso_directory_record *) pri->root_directory_record;
650 #ifndef IGNORE_WRONG_MULTI_VOLUME_SPECS
651 if (isonum_723 (pri->volume_set_size) != 1)
652 goto out_no_support;
653 #endif IGNORE_WRONG_MULTI_VOLUME_SPECS
654 s->u.isofs_sb.s_nzones = isonum_733 (pri->volume_space_size);
655 s->u.isofs_sb.s_log_zone_size = isonum_723 (pri->logical_block_size);
656 s->u.isofs_sb.s_max_size = isonum_733(pri->volume_space_size);
659 s->u.isofs_sb.s_ninodes = 0; /* No way to figure this out easily */
661 orig_zonesize = s -> u.isofs_sb.s_log_zone_size;
663 * If the zone size is smaller than the hardware sector size,
664 * this is a fatal error. This would occur if the disc drive
665 * had sectors that were 2048 bytes, but the filesystem had
666 * blocks that were 512 bytes (which should only very rarely
667 * happen.)
669 if(blocksize != 0 && orig_zonesize < blocksize)
670 goto out_bad_size;
672 /* RDE: convert log zone size to bit shift */
673 switch (s -> u.isofs_sb.s_log_zone_size)
674 { case 512: s -> u.isofs_sb.s_log_zone_size = 9; break;
675 case 1024: s -> u.isofs_sb.s_log_zone_size = 10; break;
676 case 2048: s -> u.isofs_sb.s_log_zone_size = 11; break;
678 default:
679 goto out_bad_zone_size;
682 s->s_magic = ISOFS_SUPER_MAGIC;
684 /* The CDROM is read-only, has no nodes (devices) on it, and since
685 all of the files appear to be owned by root, we really do not want
686 to allow suid. (suid or devices will not show up unless we have
687 Rock Ridge extensions) */
689 s->s_flags |= MS_RDONLY /* | MS_NODEV | MS_NOSUID */;
691 /* RDE: data zone now byte offset! */
693 first_data_zone = ((isonum_733 (rootp->extent) +
694 isonum_711 (rootp->ext_attr_length))
695 << s -> u.isofs_sb.s_log_zone_size);
696 s->u.isofs_sb.s_firstdatazone = first_data_zone;
697 #ifndef BEQUIET
698 printk(KERN_DEBUG "Max size:%ld Log zone size:%ld\n",
699 s->u.isofs_sb.s_max_size,
700 1UL << s->u.isofs_sb.s_log_zone_size);
701 printk(KERN_DEBUG "First datazone:%ld Root inode number:%ld\n",
702 s->u.isofs_sb.s_firstdatazone >> s -> u.isofs_sb.s_log_zone_size,
703 s->u.isofs_sb.s_firstdatazone);
704 if(high_sierra)
705 printk(KERN_DEBUG "Disc in High Sierra format.\n");
706 #endif
709 * If the Joliet level is set, we _may_ decide to use the
710 * secondary descriptor, but can't be sure until after we
711 * read the root inode. But before reading the root inode
712 * we may need to change the device blocksize, and would
713 * rather release the old buffer first. So, we cache the
714 * first_data_zone value from the secondary descriptor.
716 if (joliet_level) {
717 pri = (struct iso_primary_descriptor *) sec;
718 rootp = (struct iso_directory_record *)
719 pri->root_directory_record;
720 first_data_zone = ((isonum_733 (rootp->extent) +
721 isonum_711 (rootp->ext_attr_length))
722 << s -> u.isofs_sb.s_log_zone_size);
726 * We're all done using the volume descriptor, and may need
727 * to change the device blocksize, so release the buffer now.
729 brelse(bh);
732 * Force the blocksize to 512 for 512 byte sectors. The file
733 * read primitives really get it wrong in a bad way if we don't
734 * do this.
736 * Note - we should never be setting the blocksize to something
737 * less than the hardware sector size for the device. If we
738 * do, we would end up having to read larger buffers and split
739 * out portions to satisfy requests.
741 * Note2- the idea here is that we want to deal with the optimal
742 * zonesize in the filesystem. If we have it set to something less,
743 * then we have horrible problems with trying to piece together
744 * bits of adjacent blocks in order to properly read directory
745 * entries. By forcing the blocksize in this way, we ensure
746 * that we will never be required to do this.
748 if ( orig_zonesize != opt.blocksize ) {
749 set_blocksize(dev, orig_zonesize);
750 #ifndef BEQUIET
751 printk(KERN_DEBUG
752 "ISOFS: Forcing new log zone size:%d\n", orig_zonesize);
753 #endif
755 s->s_blocksize = orig_zonesize;
756 s->s_blocksize_bits = s -> u.isofs_sb.s_log_zone_size;
758 s->u.isofs_sb.s_nls_iocharset = NULL;
760 #ifdef CONFIG_JOLIET
761 if (joliet_level && opt.utf8 == 0) {
762 char * p = opt.iocharset ? opt.iocharset : "iso8859-1";
763 s->u.isofs_sb.s_nls_iocharset = load_nls(p);
764 if (! s->u.isofs_sb.s_nls_iocharset) {
765 /* Fail only if explicit charset specified */
766 if (opt.iocharset)
767 goto out_freebh;
768 s->u.isofs_sb.s_nls_iocharset = load_nls_default();
771 #endif
772 s->s_op = &isofs_sops;
773 s->u.isofs_sb.s_mapping = opt.map;
774 s->u.isofs_sb.s_rock = (opt.rock == 'y' ? 2 : 0);
775 s->u.isofs_sb.s_cruft = opt.cruft;
776 s->u.isofs_sb.s_unhide = opt.unhide;
777 s->u.isofs_sb.s_uid = opt.uid;
778 s->u.isofs_sb.s_gid = opt.gid;
779 s->u.isofs_sb.s_utf8 = opt.utf8;
781 * It would be incredibly stupid to allow people to mark every file on the disk
782 * as suid, so we merely allow them to set the default permissions.
784 s->u.isofs_sb.s_mode = opt.mode & 0777;
787 * Read the root inode, which _may_ result in changing
788 * the s_rock flag. Once we have the final s_rock value,
789 * we then decide whether to use the Joliet descriptor.
791 inode = iget(s, s->u.isofs_sb.s_firstdatazone);
794 * If this disk has both Rock Ridge and Joliet on it, then we
795 * want to use Rock Ridge by default. This can be overridden
796 * by using the norock mount option. There is still one other
797 * possibility that is not taken into account: a Rock Ridge
798 * CD with Unicode names. Until someone sees such a beast, it
799 * will not be supported.
801 if (s->u.isofs_sb.s_rock == 1) {
802 joliet_level = 0;
803 } else if (joliet_level) {
804 s->u.isofs_sb.s_rock = 0;
805 if (s->u.isofs_sb.s_firstdatazone != first_data_zone) {
806 s->u.isofs_sb.s_firstdatazone = first_data_zone;
807 printk(KERN_DEBUG
808 "ISOFS: changing to secondary root\n");
809 iput(inode);
810 inode = iget(s, s->u.isofs_sb.s_firstdatazone);
814 if (opt.check == 'u') {
815 /* Only Joliet is case insensitive by default */
816 if (joliet_level) opt.check = 'r';
817 else opt.check = 's';
819 s->u.isofs_sb.s_joliet_level = joliet_level;
821 /* check the root inode */
822 if (!inode)
823 goto out_no_root;
824 if (!inode->i_op)
825 goto out_bad_root;
826 /* get the root dentry */
827 s->s_root = d_alloc_root(inode);
828 if (!(s->s_root))
829 goto out_no_root;
831 table = 0;
832 if (joliet_level) table += 2;
833 if (opt.check == 'r') table++;
834 s->s_root->d_op = &isofs_dentry_ops[table];
836 unlock_super(s);
837 return s;
840 * Display error messages and free resources.
842 out_bad_root:
843 printk(KERN_WARNING "isofs_read_super: root inode not initialized\n");
844 goto out_iput;
845 out_no_root:
846 printk(KERN_WARNING "isofs_read_super: get root inode failed\n");
847 out_iput:
848 iput(inode);
849 #ifdef CONFIG_JOLIET
850 if (s->u.isofs_sb.s_nls_iocharset)
851 unload_nls(s->u.isofs_sb.s_nls_iocharset);
852 #endif
853 goto out_unlock;
854 out_no_read:
855 printk(KERN_WARNING "isofs_read_super: "
856 "bread failed, dev=%s, iso_blknum=%d, block=%d\n",
857 kdevname(dev), iso_blknum, block);
858 goto out_unlock;
859 out_bad_zone_size:
860 printk(KERN_WARNING "Bad logical zone size %ld\n",
861 s->u.isofs_sb.s_log_zone_size);
862 goto out_freebh;
863 out_bad_size:
864 printk(KERN_WARNING "Logical zone size(%d) < hardware blocksize(%u)\n",
865 orig_zonesize, blocksize);
866 goto out_freebh;
867 #ifndef IGNORE_WRONG_MULTI_VOLUME_SPECS
868 out_no_support:
869 printk(KERN_WARNING "Multi-volume disks not supported.\n");
870 goto out_freebh;
871 #endif
872 out_unknown_format:
873 if (!silent)
874 printk(KERN_WARNING "Unable to identify CD-ROM format.\n");
876 out_freebh:
877 brelse(bh);
878 out_unlock:
879 s->s_dev = 0;
880 unlock_super(s);
881 MOD_DEC_USE_COUNT;
882 return NULL;
885 static int isofs_statfs (struct super_block *sb, struct statfs *buf, int bufsiz)
887 struct statfs tmp;
889 tmp.f_type = ISOFS_SUPER_MAGIC;
890 tmp.f_bsize = sb->s_blocksize;
891 tmp.f_blocks = (sb->u.isofs_sb.s_nzones
892 << (sb->u.isofs_sb.s_log_zone_size - sb->s_blocksize_bits));
893 tmp.f_bfree = 0;
894 tmp.f_bavail = 0;
895 tmp.f_files = sb->u.isofs_sb.s_ninodes;
896 tmp.f_ffree = 0;
897 tmp.f_namelen = NAME_MAX;
898 return copy_to_user(buf, &tmp, bufsiz) ? -EFAULT : 0;
901 /* Life is simpler than for other filesystem since we never
902 * have to create a new block, only find an existing one.
904 int isofs_get_block(struct inode *inode, long iblock,
905 struct buffer_head *bh_result, int create)
907 unsigned long b_off;
908 unsigned offset, sect_size;
909 unsigned int firstext;
910 unsigned long nextino;
911 int i, err;
913 lock_kernel();
915 err = -EROFS;
916 if (create)
917 goto abort_create_attempted;
919 err = -EIO;
920 if (iblock < 0)
921 goto abort_negative;
923 b_off = iblock;
925 /* If we are *way* beyond the end of the file, print a message.
926 * Access beyond the end of the file up to the next page boundary
927 * is normal, however because of the way the page cache works.
928 * In this case, we just return 0 so that we can properly fill
929 * the page with useless information without generating any
930 * I/O errors.
932 if (b_off > ((inode->i_size + PAGE_SIZE - 1) >> ISOFS_BUFFER_BITS(inode)))
933 goto abort_beyond_end;
935 offset = 0;
936 firstext = inode->u.isofs_i.i_first_extent;
937 sect_size = inode->u.isofs_i.i_section_size >> ISOFS_BUFFER_BITS(inode);
938 nextino = inode->u.isofs_i.i_next_section_ino;
940 i = 0;
941 if (nextino) {
942 while (b_off >= (offset + sect_size)) {
943 struct inode *ninode;
945 offset += sect_size;
946 if (nextino == 0)
947 goto abort;
948 ninode = iget(inode->i_sb, nextino);
949 if (!ninode)
950 goto abort;
951 firstext = ninode->u.isofs_i.i_first_extent;
952 sect_size = ninode->u.isofs_i.i_section_size;
953 nextino = ninode->u.isofs_i.i_next_section_ino;
954 iput(ninode);
956 if (++i > 100)
957 goto abort_too_many_sections;
961 bh_result->b_dev = inode->i_dev;
962 bh_result->b_blocknr = firstext + b_off - offset;
963 bh_result->b_state |= (1UL << BH_Mapped);
964 err = 0;
966 abort:
967 unlock_kernel();
968 return err;
970 abort_create_attempted:
971 printk("_isofs_bmap: Kernel tries to allocate a block\n");
972 goto abort;
974 abort_negative:
975 printk("_isofs_bmap: block < 0\n");
976 goto abort;
978 abort_beyond_end:
979 printk("_isofs_bmap: block >= EOF (%ld, %ld)\n",
980 iblock, (unsigned long) inode->i_size);
981 goto abort;
983 abort_too_many_sections:
984 printk("isofs_bmap: More than 100 file sections ?!?, aborting...\n");
985 printk("isofs_bmap: ino=%lu block=%ld firstext=%u sect_size=%u nextino=%lu\n",
986 inode->i_ino, iblock, firstext, (unsigned) sect_size, nextino);
987 goto abort;
990 int isofs_bmap(struct inode *inode, int block)
992 struct buffer_head dummy;
993 int error;
995 dummy.b_state = 0;
996 dummy.b_blocknr = -1000;
997 error = isofs_get_block(inode, block, &dummy, 0);
998 if (!error)
999 return dummy.b_blocknr;
1000 return 0;
1003 static int isofs_readpage(struct dentry *dentry, struct page *page)
1005 return block_read_full_page(page,isofs_get_block);
1007 static int _isofs_bmap(struct address_space *mapping, long block)
1009 return generic_block_bmap(mapping,block,isofs_get_block);
1011 static struct address_space_operations isofs_aops = {
1012 readpage: isofs_readpage,
1013 bmap: _isofs_bmap
1016 static void test_and_set_uid(uid_t *p, uid_t value)
1018 if(value) {
1019 *p = value;
1020 #if 0
1021 printk("Resetting to %d\n", value);
1022 #endif
1026 static int isofs_read_level3_size(struct inode * inode)
1028 unsigned long ino = inode->i_ino;
1029 unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
1030 int high_sierra = inode->i_sb->u.isofs_sb.s_high_sierra;
1031 struct buffer_head * bh = NULL;
1032 int block = 0;
1033 int i = 0;
1034 int more_entries = 0;
1035 void *cpnt;
1036 struct iso_directory_record * raw_inode;
1038 inode->i_size = 0;
1039 inode->u.isofs_i.i_next_section_ino = 0;
1040 do {
1041 unsigned char *pnt;
1042 unsigned int reclen;
1043 int offset = (ino & (bufsize - 1));
1045 cpnt = NULL;
1046 /* Check whether to update our buffer */
1047 if (block != ino >> ISOFS_BUFFER_BITS(inode)) {
1048 block = ino >> ISOFS_BUFFER_BITS(inode);
1049 brelse(bh);
1050 bh = bread(inode->i_dev, block, bufsize);
1051 if (!bh)
1052 goto out_noread;
1054 pnt = ((unsigned char *) bh->b_data + offset);
1056 * Note: this is invariant even if the record
1057 * spans buffers and must be copied ...
1059 reclen = *pnt;
1061 /* N.B. this test doesn't trigger the i++ code ... */
1062 if(reclen == 0) {
1063 ino = (ino & ~(ISOFS_BLOCK_SIZE - 1)) + ISOFS_BLOCK_SIZE;
1064 continue;
1066 raw_inode = ((struct iso_directory_record *) pnt);
1068 /* Check whether the raw inode spans the buffer ... */
1069 if (offset + reclen > bufsize){
1070 int frag1 = bufsize - offset;
1072 cpnt = kmalloc(reclen, GFP_KERNEL);
1073 if (cpnt == NULL)
1074 goto out_nomem;
1075 memcpy(cpnt, pnt, frag1);
1076 brelse(bh);
1077 bh = bread(inode->i_dev, ++block, bufsize);
1078 if (!bh)
1079 goto out_noread;
1080 offset += reclen - bufsize;
1081 memcpy((char *)cpnt+frag1, bh->b_data, offset);
1082 raw_inode = ((struct iso_directory_record *) cpnt);
1085 inode->i_size += isonum_733 (raw_inode->size);
1086 if(i == 1) inode->u.isofs_i.i_next_section_ino = ino;
1088 more_entries = raw_inode->flags[-high_sierra] & 0x80;
1090 ino += reclen;
1091 if (cpnt)
1092 kfree (cpnt);
1093 i++;
1094 if(i > 100)
1095 goto out_toomany;
1096 } while(more_entries);
1097 out:
1098 brelse(bh);
1099 return 0;
1101 out_nomem:
1102 printk(KERN_INFO "ISOFS: NoMem ISO inode %lu\n", inode->i_ino);
1103 brelse(bh);
1104 return 1;
1105 out_noread:
1106 printk(KERN_INFO "ISOFS: unable to read i-node block %d\n", block);
1107 if (cpnt)
1108 kfree(cpnt);
1109 return 1;
1110 out_toomany:
1111 printk(KERN_INFO "isofs_read_level3_size: "
1112 "More than 100 file sections ?!?, aborting...\n"
1113 "isofs_read_level3_size: inode=%lu ino=%lu\n",
1114 inode->i_ino, ino);
1115 goto out;
1118 static void isofs_read_inode(struct inode * inode)
1120 struct super_block *sb = inode->i_sb;
1121 unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
1122 int block = inode->i_ino >> ISOFS_BUFFER_BITS(inode);
1123 int high_sierra = sb->u.isofs_sb.s_high_sierra;
1124 struct buffer_head * bh;
1125 struct iso_directory_record * raw_inode;
1126 unsigned char *pnt;
1127 int volume_seq_no, i;
1129 bh = bread(inode->i_dev, block, bufsize);
1130 if (!bh) {
1131 printk(KERN_WARNING "ISOFS: unable to read i-node block\n");
1132 goto fail;
1135 pnt = ((unsigned char *) bh->b_data
1136 + (inode->i_ino & (bufsize - 1)));
1137 raw_inode = ((struct iso_directory_record *) pnt);
1139 if (raw_inode->flags[-high_sierra] & 2) {
1140 inode->i_mode = S_IRUGO | S_IXUGO | S_IFDIR;
1141 inode->i_nlink = 1; /* Set to 1. We know there are 2, but
1142 the find utility tries to optimize
1143 if it is 2, and it screws up. It is
1144 easier to give 1 which tells find to
1145 do it the hard way. */
1146 } else {
1147 /* Everybody gets to read the file. */
1148 inode->i_mode = inode->i_sb->u.isofs_sb.s_mode;
1149 inode->i_nlink = 1;
1150 inode->i_mode |= S_IFREG;
1151 /* If there are no periods in the name,
1152 * then set the execute permission bit
1154 for(i=0; i< raw_inode->name_len[0]; i++)
1155 if(raw_inode->name[i]=='.' || raw_inode->name[i]==';')
1156 break;
1157 if(i == raw_inode->name_len[0] || raw_inode->name[i] == ';')
1158 inode->i_mode |= S_IXUGO; /* execute permission */
1160 inode->i_uid = inode->i_sb->u.isofs_sb.s_uid;
1161 inode->i_gid = inode->i_sb->u.isofs_sb.s_gid;
1162 inode->i_blocks = inode->i_blksize = 0;
1165 inode->u.isofs_i.i_section_size = isonum_733 (raw_inode->size);
1166 if(raw_inode->flags[-high_sierra] & 0x80) {
1167 if(isofs_read_level3_size(inode)) goto fail;
1168 } else {
1169 inode->i_size = isonum_733 (raw_inode->size);
1172 /* There are defective discs out there - we do this to protect
1173 ourselves. A cdrom will never contain more than 800Mb
1174 .. but a DVD may be up to 1Gig (Ulrich Habel) */
1175 if((inode->i_size < 0 || inode->i_size > 1073741824) &&
1176 inode->i_sb->u.isofs_sb.s_cruft == 'n') {
1177 printk(KERN_WARNING "Warning: defective CD-ROM. Enabling \"cruft\" mount option.\n");
1178 inode->i_sb->u.isofs_sb.s_cruft = 'y';
1181 /* Some dipshit decided to store some other bit of information in the high
1182 byte of the file length. Catch this and holler. WARNING: this will make
1183 it impossible for a file to be > 16Mb on the CDROM!!!*/
1185 if(inode->i_sb->u.isofs_sb.s_cruft == 'y' &&
1186 inode->i_size & 0xff000000){
1187 /* printk("Illegal format on cdrom. Pester manufacturer.\n"); */
1188 inode->i_size &= 0x00ffffff;
1191 if (raw_inode->interleave[0]) {
1192 printk("Interleaved files not (yet) supported.\n");
1193 inode->i_size = 0;
1196 /* I have no idea what file_unit_size is used for, so
1197 we will flag it for now */
1198 if(raw_inode->file_unit_size[0] != 0){
1199 printk("File unit size != 0 for ISO file (%ld).\n",inode->i_ino);
1202 /* I have no idea what other flag bits are used for, so
1203 we will flag it for now */
1204 #ifdef DEBUG
1205 if((raw_inode->flags[-high_sierra] & ~2)!= 0){
1206 printk("Unusual flag settings for ISO file (%ld %x).\n",
1207 inode->i_ino, raw_inode->flags[-high_sierra]);
1209 #endif
1211 #ifdef DEBUG
1212 printk("Get inode %x: %d %d: %d\n",inode->i_ino, block,
1213 ((int)pnt) & 0x3ff, inode->i_size);
1214 #endif
1216 inode->i_mtime = inode->i_atime = inode->i_ctime =
1217 iso_date(raw_inode->date, high_sierra);
1219 inode->u.isofs_i.i_first_extent = (isonum_733 (raw_inode->extent) +
1220 isonum_711 (raw_inode->ext_attr_length));
1222 /* Now test for possible Rock Ridge extensions which will override some of
1223 these numbers in the inode structure. */
1225 if (!high_sierra) {
1226 parse_rock_ridge_inode(raw_inode, inode);
1227 /* hmm..if we want uid or gid set, override the rock ridge setting */
1228 test_and_set_uid(&inode->i_uid, inode->i_sb->u.isofs_sb.s_uid);
1231 #ifdef DEBUG
1232 printk("Inode: %x extent: %x\n",inode->i_ino, inode->u.isofs_i.i_first_extent);
1233 #endif
1235 /* get the volume sequence number */
1236 volume_seq_no = isonum_723 (raw_inode->volume_sequence_number) ;
1239 * All done with buffer ... no more references to buffer memory!
1241 brelse(bh);
1244 * Disable checking if we see any volume number other than 0 or 1.
1245 * We could use the cruft option, but that has multiple purposes, one
1246 * of which is limiting the file size to 16Mb. Thus we silently allow
1247 * volume numbers of 0 to go through without complaining.
1249 if (inode->i_sb->u.isofs_sb.s_cruft == 'n' &&
1250 (volume_seq_no != 0) && (volume_seq_no != 1)) {
1251 printk(KERN_WARNING "Warning: defective CD-ROM (volume sequence number). Enabling \"cruft\" mount option.\n");
1252 inode->i_sb->u.isofs_sb.s_cruft = 'y';
1255 /* Install the inode operations vector */
1256 #ifndef IGNORE_WRONG_MULTI_VOLUME_SPECS
1257 if (inode->i_sb->u.isofs_sb.s_cruft != 'y' &&
1258 (volume_seq_no != 0) && (volume_seq_no != 1)) {
1259 printk(KERN_WARNING "Multi-volume CD somehow got mounted.\n");
1260 } else
1261 #endif IGNORE_WRONG_MULTI_VOLUME_SPECS
1263 if (S_ISREG(inode->i_mode)) {
1264 inode->i_fop = &generic_ro_fops;
1265 inode->i_data.a_ops = &isofs_aops;
1266 } else if (S_ISDIR(inode->i_mode)) {
1267 inode->i_op = &isofs_dir_inode_operations;
1268 inode->i_fop = &isofs_dir_operations;
1269 } else if (S_ISLNK(inode->i_mode)) {
1270 inode->i_op = &page_symlink_inode_operations;
1271 inode->i_data.a_ops = &isofs_symlink_aops;
1272 } else
1273 /* XXX - parse_rock_ridge_inode() had already set i_rdev. */
1274 init_special_inode(inode, inode->i_mode, kdev_t_to_nr(inode->i_rdev));
1276 return;
1278 fail:
1279 /* With a data error we return this information */
1280 make_bad_inode(inode);
1281 return;
1284 /* There are times when we need to know the inode number of a parent of
1285 a particular directory. When control passes through a routine that
1286 has access to the parent information, it fills it into the inode structure,
1287 but sometimes the inode gets flushed out of the queue, and someone
1288 remembers the number. When they try to open up again, we have lost
1289 the information. The '..' entry on the disc points to the data area
1290 for a particular inode, so we can follow these links back up, but since
1291 we do not know the inode number, we do not actually know how large the
1292 directory is. The disc is almost always correct, and there is
1293 enough error checking on the drive itself, but an open ended search
1294 makes me a little nervous.
1296 The BSD iso filesystem uses the extent number for an inode, and this
1297 would work really nicely for us except that the read_inode function
1298 would not have any clean way of finding the actual directory record
1299 that goes with the file. If we had such info, then it would pay
1300 to change the inode numbers and eliminate this function.
1303 int isofs_lookup_grandparent(struct inode * parent, int extent)
1305 unsigned long bufsize = ISOFS_BUFFER_SIZE(parent);
1306 unsigned char bufbits = ISOFS_BUFFER_BITS(parent);
1307 unsigned int block,offset;
1308 int parent_dir, inode_number;
1309 int result;
1310 int directory_size;
1311 struct buffer_head * bh;
1312 struct iso_directory_record * de;
1314 offset = 0;
1315 block = extent << (ISOFS_ZONE_BITS(parent) - bufbits);
1316 if (!(bh = bread(parent->i_dev, block, bufsize))) return -1;
1318 while (1 == 1) {
1319 de = (struct iso_directory_record *) (bh->b_data + offset);
1320 if (*((unsigned char *) de) == 0)
1322 brelse(bh);
1323 printk("Directory .. not found\n");
1324 return -1;
1327 offset += *((unsigned char *) de);
1329 if (offset >= bufsize)
1331 printk(".. Directory not in first block"
1332 " of directory.\n");
1333 brelse(bh);
1334 return -1;
1337 if (de->name_len[0] == 1 && de->name[0] == 1)
1339 parent_dir = find_rock_ridge_relocation(de, parent);
1340 directory_size = isonum_733 (de->size);
1341 brelse(bh);
1342 break;
1345 #ifdef DEBUG
1346 printk("Parent dir:%x\n",parent_dir);
1347 #endif
1348 /* Now we know the extent where the parent dir starts on. */
1350 result = -1;
1352 offset = 0;
1353 block = parent_dir << (ISOFS_ZONE_BITS(parent) - bufbits);
1354 if (!block || !(bh = bread(parent->i_dev,block, bufsize)))
1356 return -1;
1359 for(;;)
1361 de = (struct iso_directory_record *) (bh->b_data + offset);
1362 inode_number = (block << bufbits)+(offset & (bufsize - 1));
1364 /* If the length byte is zero, we should move on to the next
1365 CDROM sector. If we are at the end of the directory, we
1366 kick out of the while loop. */
1368 if ((*((unsigned char *) de) == 0) || (offset == bufsize) )
1370 brelse(bh);
1371 offset = 0;
1372 block++;
1373 directory_size -= bufsize;
1374 if(directory_size < 0) return -1;
1375 if((block & 1) && (ISOFS_ZONE_BITS(parent) - bufbits) == 1)
1377 return -1;
1379 if((block & 3) && (ISOFS_ZONE_BITS(parent) - bufbits) == 2)
1381 return -1;
1383 if (!block
1384 || !(bh = bread(parent->i_dev,block, bufsize)))
1386 return -1;
1388 continue;
1391 /* Make sure that the entire directory record is in the current
1392 bh block. If not, we malloc a buffer, and put the two
1393 halves together, so that we can cleanly read the block. */
1395 offset += *((unsigned char *) de);
1397 if (offset > bufsize)
1399 printk("Directory overrun\n");
1400 goto out;
1403 if (find_rock_ridge_relocation(de, parent) == extent){
1404 result = inode_number;
1405 goto out;
1410 /* We go here for any condition we cannot handle.
1411 We also drop through to here at the end of the directory. */
1413 out:
1414 brelse(bh);
1415 #ifdef DEBUG
1416 printk("Resultant Inode %d\n",result);
1417 #endif
1418 return result;
1421 #ifdef LEAK_CHECK
1422 #undef malloc
1423 #undef free_s
1424 #undef bread
1425 #undef brelse
1427 void * leak_check_malloc(unsigned int size){
1428 void * tmp;
1429 check_malloc++;
1430 tmp = kmalloc(size, GFP_KERNEL);
1431 return tmp;
1434 void leak_check_free_s(void * obj, int size){
1435 check_malloc--;
1436 return kfree_s(obj, size);
1439 struct buffer_head * leak_check_bread(int dev, int block, int size){
1440 check_bread++;
1441 return bread(dev, block, size);
1444 void leak_check_brelse(struct buffer_head * bh){
1445 check_bread--;
1446 return brelse(bh);
1449 #endif
1451 static struct file_system_type iso9660_fs_type = {
1452 "iso9660",
1453 FS_REQUIRES_DEV,
1454 isofs_read_super,
1455 NULL
1458 int __init init_iso9660_fs(void)
1460 return register_filesystem(&iso9660_fs_type);
1463 #ifdef MODULE
1464 EXPORT_NO_SYMBOLS;
1466 int init_module(void)
1468 return init_iso9660_fs();
1471 void cleanup_module(void)
1473 unregister_filesystem(&iso9660_fs_type);
1476 #endif