File: /usr/src/linux/fs/isofs/inode.c

1     /*
2      *  linux/fs/isofs/inode.c
3      *
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
10      */
11     
12     #include <linux/config.h>
13     #include <linux/module.h>
14     
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/slab.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>
30     #include <linux/blkdev.h>
31     
32     #include <asm/system.h>
33     #include <asm/uaccess.h>
34     
35     /*
36      * We have no support for "multi volume" CDs, but more and more disks carry
37      * wrong information within the volume descriptors.
38      */
39     #define IGNORE_WRONG_MULTI_VOLUME_SPECS
40     #define BEQUIET
41     
42     #ifdef LEAK_CHECK
43     static int check_malloc = 0;
44     static int check_bread = 0;
45     #endif
46     
47     static int isofs_hashi(struct dentry *parent, struct qstr *qstr);
48     static int isofs_hash(struct dentry *parent, struct qstr *qstr);
49     static int isofs_dentry_cmpi(struct dentry *dentry, struct qstr *a, struct qstr *b);
50     static int isofs_dentry_cmp(struct dentry *dentry, struct qstr *a, struct qstr *b);
51     
52     #ifdef CONFIG_JOLIET
53     static int isofs_hashi_ms(struct dentry *parent, struct qstr *qstr);
54     static int isofs_hash_ms(struct dentry *parent, struct qstr *qstr);
55     static int isofs_dentry_cmpi_ms(struct dentry *dentry, struct qstr *a, struct qstr *b);
56     static int isofs_dentry_cmp_ms(struct dentry *dentry, struct qstr *a, struct qstr *b);
57     #endif
58     
59     static void isofs_put_super(struct super_block *sb)
60     {
61     #ifdef CONFIG_JOLIET
62     	if (sb->u.isofs_sb.s_nls_iocharset) {
63     		unload_nls(sb->u.isofs_sb.s_nls_iocharset);
64     		sb->u.isofs_sb.s_nls_iocharset = NULL;
65     	}
66     #endif
67     
68     #ifdef LEAK_CHECK
69     	printk("Outstanding mallocs:%d, outstanding buffers: %d\n",
70     	       check_malloc, check_bread);
71     #endif
72     
73     	return;
74     }
75     
76     static void isofs_read_inode(struct inode *);
77     static int isofs_statfs (struct super_block *, struct statfs *);
78     
79     static struct super_operations isofs_sops = {
80     	read_inode:	isofs_read_inode,
81     	put_super:	isofs_put_super,
82     	statfs:		isofs_statfs,
83     };
84     
85     static struct dentry_operations isofs_dentry_ops[] = {
86     	{
87     		d_hash:		isofs_hash,
88     		d_compare:	isofs_dentry_cmp,
89     	},
90     	{
91     		d_hash:		isofs_hashi,
92     		d_compare:	isofs_dentry_cmpi,
93     	},
94     #ifdef CONFIG_JOLIET
95     	{
96     		d_hash:		isofs_hash_ms,
97     		d_compare:	isofs_dentry_cmp_ms,
98     	},
99     	{
100     		d_hash:		isofs_hashi_ms,
101     		d_compare:	isofs_dentry_cmpi_ms,
102     	}
103     #endif
104     };
105     
106     struct iso9660_options{
107     	char map;
108     	char rock;
109     	char joliet;
110     	char cruft;
111     	char unhide;
112     	unsigned char check;
113     	unsigned int blocksize;
114     	mode_t mode;
115     	gid_t gid;
116     	uid_t uid;
117     	char *iocharset;
118     	unsigned char utf8;
119             /* LVE */
120             s32 session;
121             s32 sbsector;
122     };
123     
124     /*
125      * Compute the hash for the isofs name corresponding to the dentry.
126      */
127     static int
128     isofs_hash_common(struct dentry *dentry, struct qstr *qstr, int ms)
129     {
130     	const char *name;
131     	int len;
132     
133     	len = qstr->len;
134     	name = qstr->name;
135     	if (ms) {
136     		while (len && name[len-1] == '.')
137     			len--;
138     	}
139     
140     	qstr->hash = full_name_hash(name, len);
141     
142     	return 0;
143     }
144     
145     /*
146      * Compute the hash for the isofs name corresponding to the dentry.
147      */
148     static int
149     isofs_hashi_common(struct dentry *dentry, struct qstr *qstr, int ms)
150     {
151     	const char *name;
152     	int len;
153     	char c;
154     	unsigned long hash;
155     
156     	len = qstr->len;
157     	name = qstr->name;
158     	if (ms) {
159     		while (len && name[len-1] == '.')
160     			len--;
161     	}
162     
163     	hash = init_name_hash();
164     	while (len--) {
165     		c = tolower(*name++);
166     		hash = partial_name_hash(tolower(c), hash);
167     	}
168     	qstr->hash = end_name_hash(hash);
169     
170     	return 0;
171     }
172     
173     /*
174      * Case insensitive compare of two isofs names.
175      */
176     static int
177     isofs_dentry_cmpi_common(struct dentry *dentry,struct qstr *a,struct qstr *b,int ms)
178     {
179     	int alen, blen;
180     
181     	/* A filename cannot end in '.' or we treat it like it has none */
182     	alen = a->len;
183     	blen = b->len;
184     	if (ms) {
185     		while (alen && a->name[alen-1] == '.')
186     			alen--;
187     		while (blen && b->name[blen-1] == '.')
188     			blen--;
189     	}
190     	if (alen == blen) {
191     		if (strnicmp(a->name, b->name, alen) == 0)
192     			return 0;
193     	}
194     	return 1;
195     }
196     
197     /*
198      * Case sensitive compare of two isofs names.
199      */
200     static int
201     isofs_dentry_cmp_common(struct dentry *dentry,struct qstr *a,struct qstr *b,int ms)
202     {
203     	int alen, blen;
204     
205     	/* A filename cannot end in '.' or we treat it like it has none */
206     	alen = a->len;
207     	blen = b->len;
208     	if (ms) {
209     		while (alen && a->name[alen-1] == '.')
210     			alen--;
211     		while (blen && b->name[blen-1] == '.')
212     			blen--;
213     	}
214     	if (alen == blen) {
215     		if (strncmp(a->name, b->name, alen) == 0)
216     			return 0;
217     	}
218     	return 1;
219     }
220     
221     static int
222     isofs_hash(struct dentry *dentry, struct qstr *qstr)
223     {
224     	return isofs_hash_common(dentry, qstr, 0);
225     }
226     
227     static int
228     isofs_hashi(struct dentry *dentry, struct qstr *qstr)
229     {
230     	return isofs_hashi_common(dentry, qstr, 0);
231     }
232     
233     static int
234     isofs_dentry_cmp(struct dentry *dentry,struct qstr *a,struct qstr *b)
235     {
236     	return isofs_dentry_cmp_common(dentry, a, b, 0);
237     }
238     
239     static int
240     isofs_dentry_cmpi(struct dentry *dentry,struct qstr *a,struct qstr *b)
241     {
242     	return isofs_dentry_cmpi_common(dentry, a, b, 0);
243     }
244     
245     #ifdef CONFIG_JOLIET
246     static int
247     isofs_hash_ms(struct dentry *dentry, struct qstr *qstr)
248     {
249     	return isofs_hash_common(dentry, qstr, 1);
250     }
251     
252     static int
253     isofs_hashi_ms(struct dentry *dentry, struct qstr *qstr)
254     {
255     	return isofs_hashi_common(dentry, qstr, 1);
256     }
257     
258     static int
259     isofs_dentry_cmp_ms(struct dentry *dentry,struct qstr *a,struct qstr *b)
260     {
261     	return isofs_dentry_cmp_common(dentry, a, b, 1);
262     }
263     
264     static int
265     isofs_dentry_cmpi_ms(struct dentry *dentry,struct qstr *a,struct qstr *b)
266     {
267     	return isofs_dentry_cmpi_common(dentry, a, b, 1);
268     }
269     #endif
270     
271     static int parse_options(char *options, struct iso9660_options * popt)
272     {
273     	char *this_char,*value;
274     
275     	popt->map = 'n';
276     	popt->rock = 'y';
277     	popt->joliet = 'y';
278     	popt->cruft = 'n';
279     	popt->unhide = 'n';
280     	popt->check = 'u';		/* unset */
281     	popt->blocksize = 1024;
282     	popt->mode = S_IRUGO | S_IXUGO; /* r-x for all.  The disc could
283     					   be shared with DOS machines so
284     					   virtually anything could be
285     					   a valid executable. */
286     	popt->gid = 0;
287     	popt->uid = 0;
288     	popt->iocharset = NULL;
289     	popt->utf8 = 0;
290     	popt->session=-1;
291     	popt->sbsector=-1;
292     	if (!options) return 1;
293     	for (this_char = strtok(options,","); this_char; this_char = strtok(NULL,",")) {
294     	        if (strncmp(this_char,"norock",6) == 0) {
295     		  popt->rock = 'n';
296     		  continue;
297     		}
298     	        if (strncmp(this_char,"nojoliet",8) == 0) {
299     		  popt->joliet = 'n';
300     		  continue;
301     		}
302     	        if (strncmp(this_char,"unhide",6) == 0) {
303     		  popt->unhide = 'y';
304     		  continue;
305     		}
306     	        if (strncmp(this_char,"cruft",5) == 0) {
307     		  popt->cruft = 'y';
308     		  continue;
309     		}
310     	        if (strncmp(this_char,"utf8",4) == 0) {
311     		  popt->utf8 = 1;
312     		  continue;
313     		}
314     		if ((value = strchr(this_char,'=')) != NULL)
315     			*value++ = 0;
316     
317     #ifdef CONFIG_JOLIET
318     		if (!strcmp(this_char,"iocharset") && value) {
319     			popt->iocharset = value;
320     			while (*value && *value != ',')
321     				value++;
322     			if (value == popt->iocharset)
323     				return 0;
324     			*value = 0;
325     		} else
326     #endif
327     		if (!strcmp(this_char,"map") && value) {
328     			if (value[0] && !value[1] && strchr("ano",*value))
329     				popt->map = *value;
330     			else if (!strcmp(value,"off")) popt->map = 'o';
331     			else if (!strcmp(value,"normal")) popt->map = 'n';
332     			else if (!strcmp(value,"acorn")) popt->map = 'a';
333     			else return 0;
334     		}
335     		if (!strcmp(this_char,"session") && value) {
336     			char * vpnt = value;
337     			unsigned int ivalue = simple_strtoul(vpnt, &vpnt, 0);
338     			if(ivalue < 0 || ivalue >99) return 0;
339     			popt->session=ivalue+1;
340     		}
341     		if (!strcmp(this_char,"sbsector") && value) {
342     			char * vpnt = value;
343     			unsigned int ivalue = simple_strtoul(vpnt, &vpnt, 0);
344     			if(ivalue < 0 || ivalue >660*512) return 0;
345     			popt->sbsector=ivalue;
346     		}
347     		else if (!strcmp(this_char,"check") && value) {
348     			if (value[0] && !value[1] && strchr("rs",*value))
349     				popt->check = *value;
350     			else if (!strcmp(value,"relaxed")) popt->check = 'r';
351     			else if (!strcmp(value,"strict")) popt->check = 's';
352     			else return 0;
353     		}
354     		else if (!strcmp(this_char,"conv") && value) {
355     			/* no conversion is done anymore;
356     			   we still accept the same mount options,
357     			   but ignore them */
358     			if (value[0] && !value[1] && strchr("btma",*value)) ;
359     			else if (!strcmp(value,"binary")) ;
360     			else if (!strcmp(value,"text")) ;
361     			else if (!strcmp(value,"mtext")) ;
362     			else if (!strcmp(value,"auto")) ;
363     			else return 0;
364     		}
365     		else if (value &&
366     			 (!strcmp(this_char,"block") ||
367     			  !strcmp(this_char,"mode") ||
368     			  !strcmp(this_char,"uid") ||
369     			  !strcmp(this_char,"gid"))) {
370     		  char * vpnt = value;
371     		  unsigned int ivalue = simple_strtoul(vpnt, &vpnt, 0);
372     		  if (*vpnt) return 0;
373     		  switch(*this_char) {
374     		  case 'b':
375     		    if (   ivalue != 512
376     			&& ivalue != 1024
377     			&& ivalue != 2048) return 0;
378     		    popt->blocksize = ivalue;
379     		    break;
380     		  case 'u':
381     		    popt->uid = ivalue;
382     		    break;
383     		  case 'g':
384     		    popt->gid = ivalue;
385     		    break;
386     		  case 'm':
387     		    popt->mode = ivalue;
388     		    break;
389     		  }
390     		}
391     		else return 1;
392     	}
393     	return 1;
394     }
395     
396     /*
397      * look if the driver can tell the multi session redirection value
398      *
399      * don't change this if you don't know what you do, please!
400      * Multisession is legal only with XA disks.
401      * A non-XA disk with more than one volume descriptor may do it right, but
402      * usually is written in a nowhere standardized "multi-partition" manner.
403      * Multisession uses absolute addressing (solely the first frame of the whole
404      * track is #0), multi-partition uses relative addressing (each first frame of
405      * each track is #0), and a track is not a session.
406      *
407      * A broken CDwriter software or drive firmware does not set new standards,
408      * at least not if conflicting with the existing ones.
409      *
410      * emoenke@gwdg.de
411      */
412     #define WE_OBEY_THE_WRITTEN_STANDARDS 1
413     
414     static unsigned int isofs_get_last_session(struct super_block *sb,s32 session )
415     {
416     	struct cdrom_multisession ms_info;
417     	unsigned int vol_desc_start;
418     	struct block_device *bdev = sb->s_bdev;
419     	int i;
420     
421     	vol_desc_start=0;
422     	ms_info.addr_format=CDROM_LBA;
423     	if(session >= 0 && session <= 99) {
424     		struct cdrom_tocentry Te;
425     		Te.cdte_track=session;
426     		Te.cdte_format=CDROM_LBA;
427     		i = ioctl_by_bdev(bdev, CDROMREADTOCENTRY, (unsigned long) &Te);
428     		if (!i) {
429     			printk(KERN_DEBUG "Session %d start %d type %d\n",
430     			       session, Te.cdte_addr.lba,
431     			       Te.cdte_ctrl&CDROM_DATA_TRACK);
432     			if ((Te.cdte_ctrl&CDROM_DATA_TRACK) == 4)
433     				return Te.cdte_addr.lba;
434     		}
435     			
436     		printk(KERN_ERR "Invalid session number or type of track\n");
437     	}
438     	i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long) &ms_info);
439     	if(session > 0) printk(KERN_ERR "Invalid session number\n");
440     #if 0
441     	printk("isofs.inode: CDROMMULTISESSION: rc=%d\n",i);
442     	if (i==0) {
443     		printk("isofs.inode: XA disk: %s\n",ms_info.xa_flag?"yes":"no");
444     		printk("isofs.inode: vol_desc_start = %d\n", ms_info.addr.lba);
445     	}
446     #endif
447     	if (i==0)
448     #if WE_OBEY_THE_WRITTEN_STANDARDS
449             if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */
450     #endif
451     		vol_desc_start=ms_info.addr.lba;
452     	return vol_desc_start;
453     }
454     
455     /*
456      * Initialize the superblock and read the root inode.
457      *
458      * Note: a check_disk_change() has been done immediately prior
459      * to this call, so we don't need to check again.
460      */
461     static struct super_block *isofs_read_super(struct super_block *s, void *data,
462     					    int silent)
463     {
464     	kdev_t				dev = s->s_dev;
465     	struct buffer_head	      * bh = NULL, *pri_bh = NULL;
466     	struct hs_primary_descriptor  * h_pri = NULL;
467     	struct iso_primary_descriptor * pri = NULL;
468     	struct iso_supplementary_descriptor *sec = NULL;
469     	struct iso_directory_record   * rootp;
470     	int				joliet_level = 0;
471     	int				high_sierra;
472     	int				iso_blknum, block;
473     	int				orig_zonesize;
474     	int				table;
475     	unsigned int			blocksize, blocksize_bits;
476     	unsigned int			vol_desc_start;
477     	unsigned long			first_data_zone;
478     	struct inode		      * inode;
479     	struct iso9660_options		opt;
480     
481     	if (!parse_options((char *) data, &opt))
482     		goto out_unlock;
483     
484     #if 0
485     	printk("map = %c\n", opt.map);
486     	printk("rock = %c\n", opt.rock);
487     	printk("joliet = %c\n", opt.joliet);
488     	printk("check = %c\n", opt.check);
489     	printk("cruft = %c\n", opt.cruft);
490     	printk("unhide = %c\n", opt.unhide);
491     	printk("blocksize = %d\n", opt.blocksize);
492     	printk("gid = %d\n", opt.gid);
493     	printk("uid = %d\n", opt.uid);
494     	printk("iocharset = %s\n", opt.iocharset);
495     #endif
496     
497     	/*
498     	 * First of all, get the hardware blocksize for this device.
499     	 * If we don't know what it is, or the hardware blocksize is
500     	 * larger than the blocksize the user specified, then use
501     	 * that value.
502     	 */
503     	blocksize = get_hardsect_size(dev);
504     	if(blocksize > opt.blocksize) {
505     	    /*
506     	     * Force the blocksize we are going to use to be the
507     	     * hardware blocksize.
508     	     */
509     	    opt.blocksize = blocksize;
510     	}
511     
512     	blocksize_bits = 0;
513     	{
514     	  int i = opt.blocksize;
515     	  while (i != 1){
516     	    blocksize_bits++;
517     	    i >>=1;
518     	  }
519     	}
520     
521     	set_blocksize(dev, opt.blocksize);
522     
523     	s->u.isofs_sb.s_high_sierra = high_sierra = 0; /* default is iso9660 */
524     
525     	vol_desc_start = (opt.sbsector != -1) ?
526     		opt.sbsector : isofs_get_last_session(s,opt.session);
527     
528       	for (iso_blknum = vol_desc_start+16;
529                  iso_blknum < vol_desc_start+100; iso_blknum++)
530     	{
531     	    struct hs_volume_descriptor   * hdp;
532     	    struct iso_volume_descriptor  * vdp;
533     
534     	    block = iso_blknum << (ISOFS_BLOCK_BITS-blocksize_bits);
535     	    if (!(bh = bread(dev, block, opt.blocksize)))
536     		goto out_no_read;		
537     
538     	    vdp = (struct iso_volume_descriptor *)bh->b_data;
539     	    hdp = (struct hs_volume_descriptor *)bh->b_data;
540     	    
541     	    /* Due to the overlapping physical location of the descriptors, 
542     	     * ISO CDs can match hdp->id==HS_STANDARD_ID as well. To ensure 
543     	     * proper identification in this case, we first check for ISO.
544     	     */
545     	    if (strncmp (vdp->id, ISO_STANDARD_ID, sizeof vdp->id) == 0) {
546     		if (isonum_711 (vdp->type) == ISO_VD_END)
547     		    break;
548     		if (isonum_711 (vdp->type) == ISO_VD_PRIMARY) {
549     		    if (pri == NULL) {
550     			pri = (struct iso_primary_descriptor *)vdp;
551     			/* Save the buffer in case we need it ... */
552     			pri_bh = bh;
553     			bh = NULL;
554     		    }
555     		}
556     #ifdef CONFIG_JOLIET
557     		else if (isonum_711 (vdp->type) == ISO_VD_SUPPLEMENTARY) {
558     		    sec = (struct iso_supplementary_descriptor *)vdp;
559     		    if (sec->escape[0] == 0x25 && sec->escape[1] == 0x2f) {
560     			if (opt.joliet == 'y') {
561     			    if (sec->escape[2] == 0x40) {
562     				joliet_level = 1;
563     			    } else if (sec->escape[2] == 0x43) {
564     				joliet_level = 2;
565     			    } else if (sec->escape[2] == 0x45) {
566     				joliet_level = 3;
567     			    }
568     			    printk(KERN_DEBUG"ISO 9660 Extensions: Microsoft Joliet Level %d\n",
569     				   joliet_level);
570     			}
571     			goto root_found;
572     		    } else {
573     			/* Unknown supplementary volume descriptor */
574     			sec = NULL;
575     		    }
576     		}
577     #endif
578     	    } else {
579     	        if (strncmp (hdp->id, HS_STANDARD_ID, sizeof hdp->id) == 0) {
580     		    if (isonum_711 (hdp->type) != ISO_VD_PRIMARY)
581     		        goto out_freebh;
582     		
583     		    s->u.isofs_sb.s_high_sierra = 1;
584     		    high_sierra = 1;
585     		    opt.rock = 'n';
586     		    h_pri = (struct hs_primary_descriptor *)vdp;
587     		    goto root_found;
588     		}
589     	    }
590     
591                 /* Just skip any volume descriptors we don't recognize */
592     
593     	    brelse(bh);
594     	    bh = NULL;
595     	}
596     	/*
597     	 * If we fall through, either no volume descriptor was found,
598     	 * or else we passed a primary descriptor looking for others.
599     	 */
600     	if (!pri)
601     		goto out_unknown_format;
602     	brelse(bh);
603     	bh = pri_bh;
604     	pri_bh = NULL;
605     
606     root_found:
607     
608     	if (joliet_level && (pri == NULL || opt.rock == 'n')) {
609     	    /* This is the case of Joliet with the norock mount flag.
610     	     * A disc with both Joliet and Rock Ridge is handled later
611     	     */
612     	    pri = (struct iso_primary_descriptor *) sec;
613     	}
614     
615     	if(high_sierra){
616     	  rootp = (struct iso_directory_record *) h_pri->root_directory_record;
617     #ifndef IGNORE_WRONG_MULTI_VOLUME_SPECS
618     	  if (isonum_723 (h_pri->volume_set_size) != 1)
619     		goto out_no_support;
620     #endif /* IGNORE_WRONG_MULTI_VOLUME_SPECS */
621     	  s->u.isofs_sb.s_nzones = isonum_733 (h_pri->volume_space_size);
622     	  s->u.isofs_sb.s_log_zone_size = isonum_723 (h_pri->logical_block_size);
623     	  s->u.isofs_sb.s_max_size = isonum_733(h_pri->volume_space_size);
624     	} else {
625     	  rootp = (struct iso_directory_record *) pri->root_directory_record;
626     #ifndef IGNORE_WRONG_MULTI_VOLUME_SPECS
627     	  if (isonum_723 (pri->volume_set_size) != 1)
628     		goto out_no_support;
629     #endif /* IGNORE_WRONG_MULTI_VOLUME_SPECS */
630     	  s->u.isofs_sb.s_nzones = isonum_733 (pri->volume_space_size);
631     	  s->u.isofs_sb.s_log_zone_size = isonum_723 (pri->logical_block_size);
632     	  s->u.isofs_sb.s_max_size = isonum_733(pri->volume_space_size);
633     	}
634     
635     	s->u.isofs_sb.s_ninodes = 0; /* No way to figure this out easily */
636     
637     	orig_zonesize = s -> u.isofs_sb.s_log_zone_size;
638     	/*
639     	 * If the zone size is smaller than the hardware sector size,
640     	 * this is a fatal error.  This would occur if the disc drive
641     	 * had sectors that were 2048 bytes, but the filesystem had
642     	 * blocks that were 512 bytes (which should only very rarely
643     	 * happen.)
644     	 */
645     	if(blocksize != 0 && orig_zonesize < blocksize)
646     		goto out_bad_size;
647     
648     	/* RDE: convert log zone size to bit shift */
649     	switch (s -> u.isofs_sb.s_log_zone_size)
650     	  { case  512: s -> u.isofs_sb.s_log_zone_size =  9; break;
651     	    case 1024: s -> u.isofs_sb.s_log_zone_size = 10; break;
652     	    case 2048: s -> u.isofs_sb.s_log_zone_size = 11; break;
653     
654     	    default:
655     		goto out_bad_zone_size;
656     	  }
657     
658     	s->s_magic = ISOFS_SUPER_MAGIC;
659     
660     	/* The CDROM is read-only, has no nodes (devices) on it, and since
661     	   all of the files appear to be owned by root, we really do not want
662     	   to allow suid.  (suid or devices will not show up unless we have
663     	   Rock Ridge extensions) */
664     
665     	s->s_flags |= MS_RDONLY /* | MS_NODEV | MS_NOSUID */;
666     
667     	/* Set this for reference. Its not currently used except on write
668     	   which we don't have .. */
669     	   
670     	/* RDE: data zone now byte offset! */
671     
672     	first_data_zone = ((isonum_733 (rootp->extent) +
673     			  isonum_711 (rootp->ext_attr_length))
674     			 << s -> u.isofs_sb.s_log_zone_size);
675     	s->u.isofs_sb.s_firstdatazone = first_data_zone;
676     #ifndef BEQUIET
677     	printk(KERN_DEBUG "Max size:%ld   Log zone size:%ld\n",
678     	       s->u.isofs_sb.s_max_size,
679     	       1UL << s->u.isofs_sb.s_log_zone_size);
680     	printk(KERN_DEBUG "First datazone:%ld   Root inode number:%ld\n",
681     	       s->u.isofs_sb.s_firstdatazone >> s -> u.isofs_sb.s_log_zone_size,
682     	       s->u.isofs_sb.s_firstdatazone);
683     	if(high_sierra)
684     		printk(KERN_DEBUG "Disc in High Sierra format.\n");
685     #endif
686     
687     	/*
688     	 * If the Joliet level is set, we _may_ decide to use the
689     	 * secondary descriptor, but can't be sure until after we
690     	 * read the root inode. But before reading the root inode
691     	 * we may need to change the device blocksize, and would
692     	 * rather release the old buffer first. So, we cache the
693     	 * first_data_zone value from the secondary descriptor.
694     	 */
695     	if (joliet_level) {
696     		pri = (struct iso_primary_descriptor *) sec;
697     		rootp = (struct iso_directory_record *)
698     			pri->root_directory_record;
699     		first_data_zone = ((isonum_733 (rootp->extent) +
700     			  	isonum_711 (rootp->ext_attr_length))
701     				 << s -> u.isofs_sb.s_log_zone_size);
702     	}
703     
704     	/*
705     	 * We're all done using the volume descriptor, and may need
706     	 * to change the device blocksize, so release the buffer now.
707     	 */
708     	brelse(pri_bh);
709     	brelse(bh);
710     
711     	/*
712     	 * Force the blocksize to 512 for 512 byte sectors.  The file
713     	 * read primitives really get it wrong in a bad way if we don't
714     	 * do this.
715     	 *
716     	 * Note - we should never be setting the blocksize to something
717     	 * less than the hardware sector size for the device.  If we
718     	 * do, we would end up having to read larger buffers and split
719     	 * out portions to satisfy requests.
720     	 *
721     	 * Note2- the idea here is that we want to deal with the optimal
722     	 * zonesize in the filesystem.  If we have it set to something less,
723     	 * then we have horrible problems with trying to piece together
724     	 * bits of adjacent blocks in order to properly read directory
725     	 * entries.  By forcing the blocksize in this way, we ensure
726     	 * that we will never be required to do this.
727     	 */
728     	if ( orig_zonesize != opt.blocksize ) {
729     		set_blocksize(dev, orig_zonesize);
730     #ifndef BEQUIET
731     		printk(KERN_DEBUG 
732     			"ISOFS: Forcing new log zone size:%d\n", orig_zonesize);
733     #endif
734     	}
735     	s->s_blocksize = orig_zonesize;
736     	s->s_blocksize_bits = s -> u.isofs_sb.s_log_zone_size;
737     
738     	s->u.isofs_sb.s_nls_iocharset = NULL;
739     
740     #ifdef CONFIG_JOLIET
741     	if (joliet_level && opt.utf8 == 0) {
742     		char * p = opt.iocharset ? opt.iocharset : "iso8859-1";
743     		s->u.isofs_sb.s_nls_iocharset = load_nls(p);
744     		if (! s->u.isofs_sb.s_nls_iocharset) {
745     			/* Fail only if explicit charset specified */
746     			if (opt.iocharset)
747     				goto out_unlock;
748     			s->u.isofs_sb.s_nls_iocharset = load_nls_default();
749     		}
750     	}
751     #endif
752     	s->s_op = &isofs_sops;
753     	s->u.isofs_sb.s_mapping = opt.map;
754     	s->u.isofs_sb.s_rock = (opt.rock == 'y' ? 2 : 0);
755     	s->u.isofs_sb.s_rock_offset = -1; /* initial offset, will guess until SP is found*/
756     	s->u.isofs_sb.s_cruft = opt.cruft;
757     	s->u.isofs_sb.s_unhide = opt.unhide;
758     	s->u.isofs_sb.s_uid = opt.uid;
759     	s->u.isofs_sb.s_gid = opt.gid;
760     	s->u.isofs_sb.s_utf8 = opt.utf8;
761     	/*
762     	 * It would be incredibly stupid to allow people to mark every file
763     	 * on the disk as suid, so we merely allow them to set the default
764     	 * permissions.
765     	 */
766     	s->u.isofs_sb.s_mode = opt.mode & 0777;
767     
768     	/*
769     	 * Read the root inode, which _may_ result in changing
770     	 * the s_rock flag. Once we have the final s_rock value,
771     	 * we then decide whether to use the Joliet descriptor.
772     	 */
773     	inode = iget(s, s->u.isofs_sb.s_firstdatazone);
774     
775     	/*
776     	 * If this disk has both Rock Ridge and Joliet on it, then we
777     	 * want to use Rock Ridge by default.  This can be overridden
778     	 * by using the norock mount option.  There is still one other
779     	 * possibility that is not taken into account: a Rock Ridge
780     	 * CD with Unicode names.  Until someone sees such a beast, it
781     	 * will not be supported.
782     	 */
783     	if (s->u.isofs_sb.s_rock == 1) {
784     		joliet_level = 0;
785     	} else if (joliet_level) {
786     		s->u.isofs_sb.s_rock = 0;
787     		if (s->u.isofs_sb.s_firstdatazone != first_data_zone) {
788     			s->u.isofs_sb.s_firstdatazone = first_data_zone;
789     			printk(KERN_DEBUG 
790     				"ISOFS: changing to secondary root\n");
791     			iput(inode);
792     			inode = iget(s, s->u.isofs_sb.s_firstdatazone);
793     		}
794     	}
795     
796     	if (opt.check == 'u') {
797     		/* Only Joliet is case insensitive by default */
798     		if (joliet_level) opt.check = 'r';
799     		else opt.check = 's';
800     	}
801     	s->u.isofs_sb.s_joliet_level = joliet_level;
802     
803     	/* check the root inode */
804     	if (!inode)
805     		goto out_no_root;
806     	if (!inode->i_op)
807     		goto out_bad_root;
808     	/* get the root dentry */
809     	s->s_root = d_alloc_root(inode);
810     	if (!(s->s_root))
811     		goto out_no_root;
812     
813     	table = 0;
814     	if (joliet_level) table += 2;
815     	if (opt.check == 'r') table++;
816     	s->s_root->d_op = &isofs_dentry_ops[table];
817     
818     	return s;
819     
820     	/*
821     	 * Display error messages and free resources.
822     	 */
823     out_bad_root:
824     	printk(KERN_WARNING "isofs_read_super: root inode not initialized\n");
825     	goto out_iput;
826     out_no_root:
827     	printk(KERN_WARNING "isofs_read_super: get root inode failed\n");
828     out_iput:
829     	iput(inode);
830     #ifdef CONFIG_JOLIET
831     	if (s->u.isofs_sb.s_nls_iocharset)
832     		unload_nls(s->u.isofs_sb.s_nls_iocharset);
833     #endif
834     	goto out_unlock;
835     out_no_read:
836     	printk(KERN_WARNING "isofs_read_super: "
837     		"bread failed, dev=%s, iso_blknum=%d, block=%d\n",
838     		kdevname(dev), iso_blknum, block);
839     	goto out_unlock;
840     out_bad_zone_size:
841     	printk(KERN_WARNING "Bad logical zone size %ld\n",
842     		s->u.isofs_sb.s_log_zone_size);
843     	goto out_freebh;
844     out_bad_size:
845     	printk(KERN_WARNING "Logical zone size(%d) < hardware blocksize(%u)\n",
846     		orig_zonesize, blocksize);
847     	goto out_freebh;
848     #ifndef IGNORE_WRONG_MULTI_VOLUME_SPECS
849     out_no_support:
850     	printk(KERN_WARNING "Multi-volume disks not supported.\n");
851     	goto out_freebh;
852     #endif
853     out_unknown_format:
854     	if (!silent)
855     		printk(KERN_WARNING "Unable to identify CD-ROM format.\n");
856     
857     out_freebh:
858     	brelse(bh);
859     out_unlock:
860     	return NULL;
861     }
862     
863     static int isofs_statfs (struct super_block *sb, struct statfs *buf)
864     {
865     	buf->f_type = ISOFS_SUPER_MAGIC;
866     	buf->f_bsize = sb->s_blocksize;
867     	buf->f_blocks = (sb->u.isofs_sb.s_nzones
868                       << (sb->u.isofs_sb.s_log_zone_size - sb->s_blocksize_bits));
869     	buf->f_bfree = 0;
870     	buf->f_bavail = 0;
871     	buf->f_files = sb->u.isofs_sb.s_ninodes;
872     	buf->f_ffree = 0;
873     	buf->f_namelen = NAME_MAX;
874     	return 0;
875     }
876     
877     /* Life is simpler than for other filesystem since we never
878      * have to create a new block, only find an existing one.
879      */
880     static int isofs_get_block(struct inode *inode, long iblock,
881     		    struct buffer_head *bh_result, int create)
882     {
883     	unsigned long b_off;
884     	unsigned offset, sect_size;
885     	unsigned int firstext;
886     	unsigned long nextino;
887     	int i, err;
888     
889     	lock_kernel();
890     
891     	err = -EROFS;
892     	if (create)
893     		goto abort_create_attempted;
894     
895     	err = -EIO;
896     	if (iblock < 0)
897     		goto abort_negative;
898     
899     	b_off = iblock;
900     
901     	/* If we are *way* beyond the end of the file, print a message.
902     	 * Access beyond the end of the file up to the next page boundary
903     	 * is normal, however because of the way the page cache works.
904     	 * In this case, we just return 0 so that we can properly fill
905     	 * the page with useless information without generating any
906     	 * I/O errors.
907     	 */
908     	if (b_off > ((inode->i_size + PAGE_SIZE - 1) >> ISOFS_BUFFER_BITS(inode)))
909     		goto abort_beyond_end;
910     
911     	offset    = 0;
912     	firstext  = inode->u.isofs_i.i_first_extent;
913     	sect_size = inode->u.isofs_i.i_section_size >> ISOFS_BUFFER_BITS(inode);
914     	nextino   = inode->u.isofs_i.i_next_section_ino;
915     
916     	i = 0;
917     	if (nextino) {
918     		while (b_off >= (offset + sect_size)) {
919     			struct inode *ninode;
920     
921     			offset += sect_size;
922     			if (nextino == 0)
923     				goto abort;
924     			ninode = iget(inode->i_sb, nextino);
925     			if (!ninode)
926     				goto abort;
927     			firstext  = ninode->u.isofs_i.i_first_extent;
928     			sect_size = ninode->u.isofs_i.i_section_size;
929     			nextino   = ninode->u.isofs_i.i_next_section_ino;
930     			iput(ninode);
931     
932     			if (++i > 100)
933     				goto abort_too_many_sections;
934     		}
935     	}
936     
937     	bh_result->b_dev = inode->i_dev;
938     	bh_result->b_blocknr = firstext + b_off - offset;
939     	bh_result->b_state |= (1UL << BH_Mapped);
940     	err = 0;
941     
942     abort:
943     	unlock_kernel();
944     	return err;
945     
946     abort_create_attempted:
947     	printk("isofs_get_block: Kernel tries to allocate a block\n");
948     	goto abort;
949     
950     abort_negative:
951     	printk("isofs_get_block: block < 0\n");
952     	goto abort;
953     
954     abort_beyond_end:
955     	printk("isofs_get_block: block >= EOF (%ld, %ld)\n",
956     	       iblock, (unsigned long) inode->i_size);
957     	goto abort;
958     
959     abort_too_many_sections:
960     	printk("isofs_get_block: More than 100 file sections ?!?, aborting...\n");
961     	printk("isofs_get_block: ino=%lu block=%ld firstext=%u sect_size=%u nextino=%lu\n",
962     	       inode->i_ino, iblock, firstext, (unsigned) sect_size, nextino);
963     	goto abort;
964     }
965     
966     static int isofs_bmap(struct inode *inode, int block)
967     {
968     	struct buffer_head dummy;
969     	int error;
970     
971     	dummy.b_state = 0;
972     	dummy.b_blocknr = -1000;
973     	error = isofs_get_block(inode, block, &dummy, 0);
974     	if (!error)
975     		return dummy.b_blocknr;
976     	return 0;
977     }
978     
979     struct buffer_head *isofs_bread(struct inode *inode, unsigned int bufsize, unsigned int block)
980     {
981     	unsigned int blknr = isofs_bmap(inode, block);
982     	if (!blknr)
983     		return NULL;
984     	return bread(inode->i_dev, blknr, bufsize);
985     }
986     
987     static int isofs_readpage(struct file *file, struct page *page)
988     {
989     	return block_read_full_page(page,isofs_get_block);
990     }
991     
992     static int _isofs_bmap(struct address_space *mapping, long block)
993     {
994     	return generic_block_bmap(mapping,block,isofs_get_block);
995     }
996     
997     static struct address_space_operations isofs_aops = {
998     	readpage: isofs_readpage,
999     	sync_page: block_sync_page,
1000     	bmap: _isofs_bmap
1001     };
1002     
1003     static inline void test_and_set_uid(uid_t *p, uid_t value)
1004     {
1005     	if(value) {
1006     		*p = value;
1007     	}
1008     }
1009     
1010     static inline void test_and_set_gid(gid_t *p, gid_t value)
1011     {
1012             if(value) {
1013                     *p = value;
1014             }
1015     }
1016     
1017     static int isofs_read_level3_size(struct inode * inode)
1018     {
1019     	unsigned long f_pos = inode->i_ino;
1020     	unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
1021     	int high_sierra = inode->i_sb->u.isofs_sb.s_high_sierra;
1022     	struct buffer_head * bh = NULL;
1023     	unsigned long block, offset;
1024     	int i = 0;
1025     	int more_entries = 0;
1026     	struct iso_directory_record * tmpde = NULL;
1027     
1028     	inode->i_size = 0;
1029     	inode->u.isofs_i.i_next_section_ino = 0;
1030     
1031     	block = f_pos >> ISOFS_BUFFER_BITS(inode);
1032     	offset = f_pos & (bufsize-1);
1033     
1034     	do {
1035     		struct iso_directory_record * de;
1036     		unsigned int de_len;
1037     
1038     		if (!bh) {
1039     			bh = bread(inode->i_dev, block, bufsize);
1040     			if (!bh)
1041     				goto out_noread;
1042     		}
1043     		de = (struct iso_directory_record *) (bh->b_data + offset);
1044     		de_len = *(unsigned char *) de;
1045     
1046     		if (de_len == 0) {
1047     			brelse(bh);
1048     			bh = NULL;
1049     			f_pos = (f_pos + ISOFS_BLOCK_SIZE) & ~(ISOFS_BLOCK_SIZE - 1);
1050     			block = f_pos >> ISOFS_BUFFER_BITS(inode);
1051     			offset = 0;
1052     			continue;
1053     		}
1054     
1055     		offset += de_len;
1056     
1057     		/* Make sure we have a full directory entry */
1058     		if (offset >= bufsize) {
1059     			int slop = bufsize - offset + de_len;
1060     			if (!tmpde) {
1061     				tmpde = kmalloc(256, GFP_KERNEL);
1062     				if (!tmpde)
1063     					goto out_nomem;
1064     			}
1065     			memcpy(tmpde, de, slop);
1066     			offset &= bufsize - 1;
1067     			block++;
1068     			brelse(bh);
1069     			bh = NULL;
1070     			if (offset) {
1071     				bh = bread(inode->i_dev, block, bufsize);
1072     				if (!bh)
1073     					goto out_noread;
1074     				memcpy((void *) tmpde + slop, bh->b_data, offset);
1075     			}
1076     			de = tmpde;
1077     		}
1078     
1079     		inode->i_size += isonum_733(de->size);
1080     		if (i == 1)
1081     			inode->u.isofs_i.i_next_section_ino = f_pos;
1082     
1083     		more_entries = de->flags[-high_sierra] & 0x80;
1084     
1085     		f_pos += de_len;
1086     		i++;
1087     		if(i > 100)
1088     			goto out_toomany;
1089     	} while(more_entries);
1090     out:
1091     	if (tmpde)
1092     		kfree(tmpde);
1093     	if (bh)
1094     		brelse(bh);
1095     	return 0;
1096     
1097     out_nomem:
1098     	if (bh)
1099     		brelse(bh);
1100     	return -ENOMEM;
1101     
1102     out_noread:
1103     	printk(KERN_INFO "ISOFS: unable to read i-node block %lu\n", block);
1104     	if (tmpde)
1105     		kfree(tmpde);
1106     	return -EIO;
1107     
1108     out_toomany:
1109     	printk(KERN_INFO "isofs_read_level3_size: "
1110     		"More than 100 file sections ?!?, aborting...\n"
1111     	  	"isofs_read_level3_size: inode=%lu ino=%lu\n",
1112     		inode->i_ino, f_pos);
1113     	goto out;
1114     }
1115     
1116     static void isofs_read_inode(struct inode * inode)
1117     {
1118     	struct super_block *sb = inode->i_sb;
1119     	unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
1120     	int block = inode->i_ino >> ISOFS_BUFFER_BITS(inode);
1121     	int high_sierra = sb->u.isofs_sb.s_high_sierra;
1122     	struct buffer_head * bh = NULL;
1123     	struct iso_directory_record * de;
1124     	struct iso_directory_record * tmpde = NULL;
1125     	unsigned int de_len;
1126     	unsigned long offset;
1127     	int volume_seq_no, i;
1128     
1129     	bh = bread(inode->i_dev, block, bufsize);
1130     	if (!bh)
1131     		goto out_badread;
1132     
1133     	offset = (inode->i_ino & (bufsize - 1));
1134     	de = (struct iso_directory_record *) (bh->b_data + offset);
1135     	de_len = *(unsigned char *) de;
1136     
1137     	if (offset + de_len > bufsize) {
1138     		int frag1 = bufsize - offset;
1139     
1140     		tmpde = kmalloc(de_len, GFP_KERNEL);
1141     		if (tmpde == NULL) {
1142     			printk(KERN_INFO "isofs_read_inode: out of memory\n");
1143     			goto fail;
1144     		}
1145     		memcpy(tmpde, bh->b_data + offset, frag1);
1146     		brelse(bh);
1147     		bh = bread(inode->i_dev, ++block, bufsize);
1148     		if (!bh)
1149     			goto out_badread;
1150     		memcpy((char *)tmpde+frag1, bh->b_data, de_len - frag1);
1151     		de = tmpde;
1152     	}
1153     
1154     	if (de->flags[-high_sierra] & 2) {
1155     		inode->i_mode = S_IRUGO | S_IXUGO | S_IFDIR;
1156     		inode->i_nlink = 1; /* Set to 1.  We know there are 2, but
1157     				       the find utility tries to optimize
1158     				       if it is 2, and it screws up.  It is
1159     				       easier to give 1 which tells find to
1160     				       do it the hard way. */
1161     	} else {
1162      		/* Everybody gets to read the file. */
1163     		inode->i_mode = inode->i_sb->u.isofs_sb.s_mode;
1164     		inode->i_nlink = 1;
1165     	        inode->i_mode |= S_IFREG;
1166     		/* If there are no periods in the name,
1167     		 * then set the execute permission bit
1168     		 */
1169     		for(i=0; i< de->name_len[0]; i++)
1170     			if(de->name[i]=='.' || de->name[i]==';')
1171     				break;
1172     		if(i == de->name_len[0] || de->name[i] == ';')
1173     			inode->i_mode |= S_IXUGO; /* execute permission */
1174     	}
1175     	inode->i_uid = inode->i_sb->u.isofs_sb.s_uid;
1176     	inode->i_gid = inode->i_sb->u.isofs_sb.s_gid;
1177     	inode->i_blocks = inode->i_blksize = 0;
1178     
1179     
1180     	inode->u.isofs_i.i_section_size = isonum_733 (de->size);
1181     	if(de->flags[-high_sierra] & 0x80) {
1182     		if(isofs_read_level3_size(inode)) goto fail;
1183     	} else {
1184     		inode->i_size = isonum_733 (de->size);
1185     	}
1186     
1187     	/* There are defective discs out there - we do this to protect
1188     	   ourselves.  A cdrom will never contain more than 800Mb 
1189     	   .. but a DVD may be up to 1Gig (Ulrich Habel) */
1190     
1191     	if ((inode->i_size < 0 || inode->i_size > 1073741824) &&
1192     	    inode->i_sb->u.isofs_sb.s_cruft == 'n') {
1193     		printk(KERN_WARNING "Warning: defective CD-ROM.  "
1194     		       "Enabling \"cruft\" mount option.\n");
1195     		inode->i_sb->u.isofs_sb.s_cruft = 'y';
1196     	}
1197     
1198     	/*
1199     	 * Some dipshit decided to store some other bit of information
1200     	 * in the high byte of the file length.  Catch this and holler.
1201     	 * WARNING: this will make it impossible for a file to be > 16MB
1202     	 * on the CDROM.
1203     	 */
1204     
1205     	if (inode->i_sb->u.isofs_sb.s_cruft == 'y' &&
1206     	    inode->i_size & 0xff000000) {
1207     		inode->i_size &= 0x00ffffff;
1208     	}
1209     
1210     	if (de->interleave[0]) {
1211     		printk("Interleaved files not (yet) supported.\n");
1212     		inode->i_size = 0;
1213     	}
1214     
1215     	/* I have no idea what file_unit_size is used for, so
1216     	   we will flag it for now */
1217     	if (de->file_unit_size[0] != 0) {
1218     		printk("File unit size != 0 for ISO file (%ld).\n",
1219     		       inode->i_ino);
1220     	}
1221     
1222     	/* I have no idea what other flag bits are used for, so
1223     	   we will flag it for now */
1224     #ifdef DEBUG
1225     	if((de->flags[-high_sierra] & ~2)!= 0){
1226     		printk("Unusual flag settings for ISO file (%ld %x).\n",
1227     		       inode->i_ino, de->flags[-high_sierra]);
1228     	}
1229     #endif
1230     
1231     	inode->i_mtime = inode->i_atime = inode->i_ctime =
1232     		iso_date(de->date, high_sierra);
1233     
1234     	inode->u.isofs_i.i_first_extent = (isonum_733 (de->extent) +
1235     					   isonum_711 (de->ext_attr_length));
1236     
1237     	/*
1238     	 * Now test for possible Rock Ridge extensions which will override
1239     	 * some of these numbers in the inode structure.
1240     	 */
1241     
1242     	if (!high_sierra) {
1243     		parse_rock_ridge_inode(de, inode);
1244     		/* if we want uid/gid set, override the rock ridge setting */
1245     		test_and_set_uid(&inode->i_uid, inode->i_sb->u.isofs_sb.s_uid);
1246     		test_and_set_gid(&inode->i_gid, inode->i_sb->u.isofs_sb.s_gid);
1247     	}
1248     
1249     	/* get the volume sequence number */
1250     	volume_seq_no = isonum_723 (de->volume_sequence_number) ;
1251     
1252     	/*
1253     	 * Disable checking if we see any volume number other than 0 or 1.
1254     	 * We could use the cruft option, but that has multiple purposes, one
1255     	 * of which is limiting the file size to 16Mb.  Thus we silently allow
1256     	 * volume numbers of 0 to go through without complaining.
1257     	 */
1258     	if (inode->i_sb->u.isofs_sb.s_cruft == 'n' &&
1259     	    (volume_seq_no != 0) && (volume_seq_no != 1)) {
1260     		printk(KERN_WARNING "Warning: defective CD-ROM "
1261     		       "(volume sequence number %d). "
1262     		       "Enabling \"cruft\" mount option.\n", volume_seq_no);
1263     		inode->i_sb->u.isofs_sb.s_cruft = 'y';
1264     	}
1265     
1266     	/* Install the inode operations vector */
1267     #ifndef IGNORE_WRONG_MULTI_VOLUME_SPECS
1268     	if (inode->i_sb->u.isofs_sb.s_cruft != 'y' &&
1269     	    (volume_seq_no != 0) && (volume_seq_no != 1)) {
1270     		printk(KERN_WARNING "Multi-volume CD somehow got mounted.\n");
1271     	} else
1272     #endif /*IGNORE_WRONG_MULTI_VOLUME_SPECS */
1273     	{
1274     		if (S_ISREG(inode->i_mode)) {
1275     			inode->i_fop = &generic_ro_fops;
1276     			inode->i_data.a_ops = &isofs_aops;
1277     		} else if (S_ISDIR(inode->i_mode)) {
1278     			inode->i_op = &isofs_dir_inode_operations;
1279     			inode->i_fop = &isofs_dir_operations;
1280     		} else if (S_ISLNK(inode->i_mode)) {
1281     			inode->i_op = &page_symlink_inode_operations;
1282     			inode->i_data.a_ops = &isofs_symlink_aops;
1283     		} else
1284     			/* XXX - parse_rock_ridge_inode() had already set i_rdev. */
1285     			init_special_inode(inode, inode->i_mode,
1286     					   kdev_t_to_nr(inode->i_rdev));
1287     	}
1288      out:
1289     	if (tmpde)
1290     		kfree(tmpde);
1291     	if (bh)
1292     		brelse(bh);
1293     	return;
1294     
1295      out_badread:
1296     	printk(KERN_WARNING "ISOFS: unable to read i-node block\n");
1297      fail:
1298     	make_bad_inode(inode);
1299     	goto out;
1300     }
1301     
1302     #ifdef LEAK_CHECK
1303     #undef malloc
1304     #undef free_s
1305     #undef bread
1306     #undef brelse
1307     
1308     void * leak_check_malloc(unsigned int size){
1309       void * tmp;
1310       check_malloc++;
1311       tmp = kmalloc(size, GFP_KERNEL);
1312       return tmp;
1313     }
1314     
1315     void leak_check_free_s(void * obj, int size){
1316       check_malloc--;
1317       return kfree(obj);
1318     }
1319     
1320     struct buffer_head * leak_check_bread(int dev, int block, int size){
1321       check_bread++;
1322       return bread(dev, block, size);
1323     }
1324     
1325     void leak_check_brelse(struct buffer_head * bh){
1326       check_bread--;
1327       return brelse(bh);
1328     }
1329     
1330     #endif
1331     
1332     static DECLARE_FSTYPE_DEV(iso9660_fs_type, "iso9660", isofs_read_super);
1333     
1334     static int __init init_iso9660_fs(void)
1335     {
1336             return register_filesystem(&iso9660_fs_type);
1337     }
1338     
1339     static void __exit exit_iso9660_fs(void)
1340     {
1341             unregister_filesystem(&iso9660_fs_type);
1342     }
1343     
1344     EXPORT_NO_SYMBOLS;
1345     
1346     module_init(init_iso9660_fs)
1347     module_exit(exit_iso9660_fs)
1348