aboutsummaryrefslogtreecommitdiffstats
path: root/fs/isofs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/isofs/inode.c')
-rw-r--r--fs/isofs/inode.c128
1 files changed, 46 insertions, 82 deletions
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index abd7b12eeca..1652de1b6cb 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -28,11 +28,6 @@
28 28
29#define BEQUIET 29#define BEQUIET
30 30
31#ifdef LEAK_CHECK
32static int check_malloc;
33static int check_bread;
34#endif
35
36static int isofs_hashi(struct dentry *parent, struct qstr *qstr); 31static int isofs_hashi(struct dentry *parent, struct qstr *qstr);
37static int isofs_hash(struct dentry *parent, struct qstr *qstr); 32static int isofs_hash(struct dentry *parent, struct qstr *qstr);
38static int isofs_dentry_cmpi(struct dentry *dentry, struct qstr *a, struct qstr *b); 33static int isofs_dentry_cmpi(struct dentry *dentry, struct qstr *a, struct qstr *b);
@@ -55,11 +50,6 @@ static void isofs_put_super(struct super_block *sb)
55 } 50 }
56#endif 51#endif
57 52
58#ifdef LEAK_CHECK
59 printk("Outstanding mallocs:%d, outstanding buffers: %d\n",
60 check_malloc, check_bread);
61#endif
62
63 kfree(sbi); 53 kfree(sbi);
64 sb->s_fs_info = NULL; 54 sb->s_fs_info = NULL;
65 return; 55 return;
@@ -73,7 +63,7 @@ static kmem_cache_t *isofs_inode_cachep;
73static struct inode *isofs_alloc_inode(struct super_block *sb) 63static struct inode *isofs_alloc_inode(struct super_block *sb)
74{ 64{
75 struct iso_inode_info *ei; 65 struct iso_inode_info *ei;
76 ei = (struct iso_inode_info *)kmem_cache_alloc(isofs_inode_cachep, SLAB_KERNEL); 66 ei = kmem_cache_alloc(isofs_inode_cachep, SLAB_KERNEL);
77 if (!ei) 67 if (!ei)
78 return NULL; 68 return NULL;
79 return &ei->vfs_inode; 69 return &ei->vfs_inode;
@@ -84,9 +74,9 @@ static void isofs_destroy_inode(struct inode *inode)
84 kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode)); 74 kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode));
85} 75}
86 76
87static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 77static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags)
88{ 78{
89 struct iso_inode_info *ei = (struct iso_inode_info *) foo; 79 struct iso_inode_info *ei = foo;
90 80
91 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == 81 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
92 SLAB_CTOR_CONSTRUCTOR) 82 SLAB_CTOR_CONSTRUCTOR)
@@ -107,7 +97,8 @@ static int init_inodecache(void)
107static void destroy_inodecache(void) 97static void destroy_inodecache(void)
108{ 98{
109 if (kmem_cache_destroy(isofs_inode_cachep)) 99 if (kmem_cache_destroy(isofs_inode_cachep))
110 printk(KERN_INFO "iso_inode_cache: not all structures were freed\n"); 100 printk(KERN_INFO "iso_inode_cache: not all structures were "
101 "freed\n");
111} 102}
112 103
113static int isofs_remount(struct super_block *sb, int *flags, char *data) 104static int isofs_remount(struct super_block *sb, int *flags, char *data)
@@ -144,7 +135,7 @@ static struct dentry_operations isofs_dentry_ops[] = {
144 { 135 {
145 .d_hash = isofs_hashi_ms, 136 .d_hash = isofs_hashi_ms,
146 .d_compare = isofs_dentry_cmpi_ms, 137 .d_compare = isofs_dentry_cmpi_ms,
147 } 138 },
148#endif 139#endif
149}; 140};
150 141
@@ -153,7 +144,8 @@ struct iso9660_options{
153 char rock; 144 char rock;
154 char joliet; 145 char joliet;
155 char cruft; 146 char cruft;
156 char unhide; 147 char hide;
148 char showassoc;
157 char nocompress; 149 char nocompress;
158 unsigned char check; 150 unsigned char check;
159 unsigned int blocksize; 151 unsigned int blocksize;
@@ -219,8 +211,8 @@ isofs_hashi_common(struct dentry *dentry, struct qstr *qstr, int ms)
219/* 211/*
220 * Case insensitive compare of two isofs names. 212 * Case insensitive compare of two isofs names.
221 */ 213 */
222static int 214static int isofs_dentry_cmpi_common(struct dentry *dentry, struct qstr *a,
223isofs_dentry_cmpi_common(struct dentry *dentry,struct qstr *a,struct qstr *b,int ms) 215 struct qstr *b, int ms)
224{ 216{
225 int alen, blen; 217 int alen, blen;
226 218
@@ -243,8 +235,8 @@ isofs_dentry_cmpi_common(struct dentry *dentry,struct qstr *a,struct qstr *b,int
243/* 235/*
244 * Case sensitive compare of two isofs names. 236 * Case sensitive compare of two isofs names.
245 */ 237 */
246static int 238static int isofs_dentry_cmp_common(struct dentry *dentry, struct qstr *a,
247isofs_dentry_cmp_common(struct dentry *dentry,struct qstr *a,struct qstr *b,int ms) 239 struct qstr *b, int ms)
248{ 240{
249 int alen, blen; 241 int alen, blen;
250 242
@@ -318,13 +310,15 @@ enum {
318 Opt_block, Opt_check_r, Opt_check_s, Opt_cruft, Opt_gid, Opt_ignore, 310 Opt_block, Opt_check_r, Opt_check_s, Opt_cruft, Opt_gid, Opt_ignore,
319 Opt_iocharset, Opt_map_a, Opt_map_n, Opt_map_o, Opt_mode, Opt_nojoliet, 311 Opt_iocharset, Opt_map_a, Opt_map_n, Opt_map_o, Opt_mode, Opt_nojoliet,
320 Opt_norock, Opt_sb, Opt_session, Opt_uid, Opt_unhide, Opt_utf8, Opt_err, 312 Opt_norock, Opt_sb, Opt_session, Opt_uid, Opt_unhide, Opt_utf8, Opt_err,
321 Opt_nocompress, 313 Opt_nocompress, Opt_hide, Opt_showassoc,
322}; 314};
323 315
324static match_table_t tokens = { 316static match_table_t tokens = {
325 {Opt_norock, "norock"}, 317 {Opt_norock, "norock"},
326 {Opt_nojoliet, "nojoliet"}, 318 {Opt_nojoliet, "nojoliet"},
327 {Opt_unhide, "unhide"}, 319 {Opt_unhide, "unhide"},
320 {Opt_hide, "hide"},
321 {Opt_showassoc, "showassoc"},
328 {Opt_cruft, "cruft"}, 322 {Opt_cruft, "cruft"},
329 {Opt_utf8, "utf8"}, 323 {Opt_utf8, "utf8"},
330 {Opt_iocharset, "iocharset=%s"}, 324 {Opt_iocharset, "iocharset=%s"},
@@ -356,7 +350,7 @@ static match_table_t tokens = {
356 {Opt_err, NULL} 350 {Opt_err, NULL}
357}; 351};
358 352
359static int parse_options(char *options, struct iso9660_options * popt) 353static int parse_options(char *options, struct iso9660_options *popt)
360{ 354{
361 char *p; 355 char *p;
362 int option; 356 int option;
@@ -365,7 +359,8 @@ static int parse_options(char *options, struct iso9660_options * popt)
365 popt->rock = 'y'; 359 popt->rock = 'y';
366 popt->joliet = 'y'; 360 popt->joliet = 'y';
367 popt->cruft = 'n'; 361 popt->cruft = 'n';
368 popt->unhide = 'n'; 362 popt->hide = 'n';
363 popt->showassoc = 'n';
369 popt->check = 'u'; /* unset */ 364 popt->check = 'u'; /* unset */
370 popt->nocompress = 0; 365 popt->nocompress = 0;
371 popt->blocksize = 1024; 366 popt->blocksize = 1024;
@@ -398,8 +393,12 @@ static int parse_options(char *options, struct iso9660_options * popt)
398 case Opt_nojoliet: 393 case Opt_nojoliet:
399 popt->joliet = 'n'; 394 popt->joliet = 'n';
400 break; 395 break;
396 case Opt_hide:
397 popt->hide = 'y';
398 break;
401 case Opt_unhide: 399 case Opt_unhide:
402 popt->unhide = 'y'; 400 case Opt_showassoc:
401 popt->showassoc = 'y';
403 break; 402 break;
404 case Opt_cruft: 403 case Opt_cruft:
405 popt->cruft = 'y'; 404 popt->cruft = 'y';
@@ -493,7 +492,7 @@ static int parse_options(char *options, struct iso9660_options * popt)
493 */ 492 */
494#define WE_OBEY_THE_WRITTEN_STANDARDS 1 493#define WE_OBEY_THE_WRITTEN_STANDARDS 1
495 494
496static unsigned int isofs_get_last_session(struct super_block *sb,s32 session ) 495static unsigned int isofs_get_last_session(struct super_block *sb, s32 session)
497{ 496{
498 struct cdrom_multisession ms_info; 497 struct cdrom_multisession ms_info;
499 unsigned int vol_desc_start; 498 unsigned int vol_desc_start;
@@ -518,7 +517,8 @@ static unsigned int isofs_get_last_session(struct super_block *sb,s32 session )
518 printk(KERN_ERR "Invalid session number or type of track\n"); 517 printk(KERN_ERR "Invalid session number or type of track\n");
519 } 518 }
520 i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long) &ms_info); 519 i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long) &ms_info);
521 if(session > 0) printk(KERN_ERR "Invalid session number\n"); 520 if (session > 0)
521 printk(KERN_ERR "Invalid session number\n");
522#if 0 522#if 0
523 printk("isofs.inode: CDROMMULTISESSION: rc=%d\n",i); 523 printk("isofs.inode: CDROMMULTISESSION: rc=%d\n",i);
524 if (i==0) { 524 if (i==0) {
@@ -557,13 +557,13 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
557 struct iso9660_options opt; 557 struct iso9660_options opt;
558 struct isofs_sb_info * sbi; 558 struct isofs_sb_info * sbi;
559 559
560 sbi = kmalloc(sizeof(struct isofs_sb_info), GFP_KERNEL); 560 sbi = kmalloc(sizeof(*sbi), GFP_KERNEL);
561 if (!sbi) 561 if (!sbi)
562 return -ENOMEM; 562 return -ENOMEM;
563 s->s_fs_info = sbi; 563 s->s_fs_info = sbi;
564 memset(sbi, 0, sizeof(struct isofs_sb_info)); 564 memset(sbi, 0, sizeof(*sbi));
565 565
566 if (!parse_options((char *) data, &opt)) 566 if (!parse_options((char *)data, &opt))
567 goto out_freesbi; 567 goto out_freesbi;
568 568
569 /* 569 /*
@@ -792,7 +792,8 @@ root_found:
792 sbi->s_rock = (opt.rock == 'y' ? 2 : 0); 792 sbi->s_rock = (opt.rock == 'y' ? 2 : 0);
793 sbi->s_rock_offset = -1; /* initial offset, will guess until SP is found*/ 793 sbi->s_rock_offset = -1; /* initial offset, will guess until SP is found*/
794 sbi->s_cruft = opt.cruft; 794 sbi->s_cruft = opt.cruft;
795 sbi->s_unhide = opt.unhide; 795 sbi->s_hide = opt.hide;
796 sbi->s_showassoc = opt.showassoc;
796 sbi->s_uid = opt.uid; 797 sbi->s_uid = opt.uid;
797 sbi->s_gid = opt.gid; 798 sbi->s_gid = opt.gid;
798 sbi->s_utf8 = opt.utf8; 799 sbi->s_utf8 = opt.utf8;
@@ -1002,7 +1003,6 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s,
1002 rv++; 1003 rv++;
1003 } 1004 }
1004 1005
1005
1006abort: 1006abort:
1007 unlock_kernel(); 1007 unlock_kernel();
1008 return rv; 1008 return rv;
@@ -1014,7 +1014,7 @@ abort:
1014static int isofs_get_block(struct inode *inode, sector_t iblock, 1014static int isofs_get_block(struct inode *inode, sector_t iblock,
1015 struct buffer_head *bh_result, int create) 1015 struct buffer_head *bh_result, int create)
1016{ 1016{
1017 if ( create ) { 1017 if (create) {
1018 printk("isofs_get_block: Kernel tries to allocate a block\n"); 1018 printk("isofs_get_block: Kernel tries to allocate a block\n");
1019 return -EROFS; 1019 return -EROFS;
1020 } 1020 }
@@ -1061,19 +1061,17 @@ static struct address_space_operations isofs_aops = {
1061 1061
1062static inline void test_and_set_uid(uid_t *p, uid_t value) 1062static inline void test_and_set_uid(uid_t *p, uid_t value)
1063{ 1063{
1064 if(value) { 1064 if (value)
1065 *p = value; 1065 *p = value;
1066 }
1067} 1066}
1068 1067
1069static inline void test_and_set_gid(gid_t *p, gid_t value) 1068static inline void test_and_set_gid(gid_t *p, gid_t value)
1070{ 1069{
1071 if(value) { 1070 if (value)
1072 *p = value; 1071 *p = value;
1073 }
1074} 1072}
1075 1073
1076static int isofs_read_level3_size(struct inode * inode) 1074static int isofs_read_level3_size(struct inode *inode)
1077{ 1075{
1078 unsigned long bufsize = ISOFS_BUFFER_SIZE(inode); 1076 unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
1079 int high_sierra = ISOFS_SB(inode->i_sb)->s_high_sierra; 1077 int high_sierra = ISOFS_SB(inode->i_sb)->s_high_sierra;
@@ -1136,7 +1134,7 @@ static int isofs_read_level3_size(struct inode * inode)
1136 bh = sb_bread(inode->i_sb, block); 1134 bh = sb_bread(inode->i_sb, block);
1137 if (!bh) 1135 if (!bh)
1138 goto out_noread; 1136 goto out_noread;
1139 memcpy((void *) tmpde + slop, bh->b_data, offset); 1137 memcpy((void *)tmpde+slop, bh->b_data, offset);
1140 } 1138 }
1141 de = tmpde; 1139 de = tmpde;
1142 } 1140 }
@@ -1150,12 +1148,11 @@ static int isofs_read_level3_size(struct inode * inode)
1150 more_entries = de->flags[-high_sierra] & 0x80; 1148 more_entries = de->flags[-high_sierra] & 0x80;
1151 1149
1152 i++; 1150 i++;
1153 if(i > 100) 1151 if (i > 100)
1154 goto out_toomany; 1152 goto out_toomany;
1155 } while(more_entries); 1153 } while (more_entries);
1156out: 1154out:
1157 if (tmpde) 1155 kfree(tmpde);
1158 kfree(tmpde);
1159 if (bh) 1156 if (bh)
1160 brelse(bh); 1157 brelse(bh);
1161 return 0; 1158 return 0;
@@ -1179,7 +1176,7 @@ out_toomany:
1179 goto out; 1176 goto out;
1180} 1177}
1181 1178
1182static void isofs_read_inode(struct inode * inode) 1179static void isofs_read_inode(struct inode *inode)
1183{ 1180{
1184 struct super_block *sb = inode->i_sb; 1181 struct super_block *sb = inode->i_sb;
1185 struct isofs_sb_info *sbi = ISOFS_SB(sb); 1182 struct isofs_sb_info *sbi = ISOFS_SB(sb);
@@ -1249,7 +1246,7 @@ static void isofs_read_inode(struct inode * inode)
1249 ei->i_format_parm[2] = 0; 1246 ei->i_format_parm[2] = 0;
1250 1247
1251 ei->i_section_size = isonum_733 (de->size); 1248 ei->i_section_size = isonum_733 (de->size);
1252 if(de->flags[-high_sierra] & 0x80) { 1249 if (de->flags[-high_sierra] & 0x80) {
1253 if(isofs_read_level3_size(inode)) goto fail; 1250 if(isofs_read_level3_size(inode)) goto fail;
1254 } else { 1251 } else {
1255 ei->i_next_section_block = 0; 1252 ei->i_next_section_block = 0;
@@ -1336,16 +1333,16 @@ static void isofs_read_inode(struct inode * inode)
1336 /* XXX - parse_rock_ridge_inode() had already set i_rdev. */ 1333 /* XXX - parse_rock_ridge_inode() had already set i_rdev. */
1337 init_special_inode(inode, inode->i_mode, inode->i_rdev); 1334 init_special_inode(inode, inode->i_mode, inode->i_rdev);
1338 1335
1339 out: 1336out:
1340 if (tmpde) 1337 if (tmpde)
1341 kfree(tmpde); 1338 kfree(tmpde);
1342 if (bh) 1339 if (bh)
1343 brelse(bh); 1340 brelse(bh);
1344 return; 1341 return;
1345 1342
1346 out_badread: 1343out_badread:
1347 printk(KERN_WARNING "ISOFS: unable to read i-node block\n"); 1344 printk(KERN_WARNING "ISOFS: unable to read i-node block\n");
1348 fail: 1345fail:
1349 make_bad_inode(inode); 1346 make_bad_inode(inode);
1350 goto out; 1347 goto out;
1351} 1348}
@@ -1394,11 +1391,8 @@ struct inode *isofs_iget(struct super_block *sb,
1394 1391
1395 hashval = (block << sb->s_blocksize_bits) | offset; 1392 hashval = (block << sb->s_blocksize_bits) | offset;
1396 1393
1397 inode = iget5_locked(sb, 1394 inode = iget5_locked(sb, hashval, &isofs_iget5_test,
1398 hashval, 1395 &isofs_iget5_set, &data);
1399 &isofs_iget5_test,
1400 &isofs_iget5_set,
1401 &data);
1402 1396
1403 if (inode && (inode->i_state & I_NEW)) { 1397 if (inode && (inode->i_state & I_NEW)) {
1404 sb->s_op->read_inode(inode); 1398 sb->s_op->read_inode(inode);
@@ -1408,36 +1402,6 @@ struct inode *isofs_iget(struct super_block *sb,
1408 return inode; 1402 return inode;
1409} 1403}
1410 1404
1411#ifdef LEAK_CHECK
1412#undef malloc
1413#undef free_s
1414#undef sb_bread
1415#undef brelse
1416
1417void * leak_check_malloc(unsigned int size){
1418 void * tmp;
1419 check_malloc++;
1420 tmp = kmalloc(size, GFP_KERNEL);
1421 return tmp;
1422}
1423
1424void leak_check_free_s(void * obj, int size){
1425 check_malloc--;
1426 return kfree(obj);
1427}
1428
1429struct buffer_head * leak_check_bread(struct super_block *sb, int block){
1430 check_bread++;
1431 return sb_bread(sb, block);
1432}
1433
1434void leak_check_brelse(struct buffer_head * bh){
1435 check_bread--;
1436 return brelse(bh);
1437}
1438
1439#endif
1440
1441static struct super_block *isofs_get_sb(struct file_system_type *fs_type, 1405static struct super_block *isofs_get_sb(struct file_system_type *fs_type,
1442 int flags, const char *dev_name, void *data) 1406 int flags, const char *dev_name, void *data)
1443{ 1407{