aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2009-06-17 19:26:25 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-18 16:03:45 -0400
commit52b680c81238ea14693ab893d5d32a4d1c0a987d (patch)
tree9c3ec57c06faf001b60529d088c189f4bcb77fac /fs
parentef43618a47179b41e7203a624f2c7445e7da488c (diff)
isofs: let mode and dmode mount options override rock ridge mode setting
So far, permissions set via 'mode' and/or 'dmode' mount options were effective only if the medium had no rock ridge extensions (or was mounted without them). Add 'overriderockmode' mount option to indicate that these options should override permissions set in rock ridge extensions. Maybe this should be default but the current behavior is there since mount options were created so I think we should not change how they behave. Cc: <Hans-Joachim.Baader@cjt.de> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/isofs/inode.c50
-rw-r--r--fs/isofs/isofs.h3
2 files changed, 41 insertions, 12 deletions
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 068b34b5a107..8e6fd41eec12 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -148,6 +148,7 @@ struct iso9660_options{
148 char hide; 148 char hide;
149 char showassoc; 149 char showassoc;
150 char nocompress; 150 char nocompress;
151 char overriderockperm;
151 unsigned char check; 152 unsigned char check;
152 unsigned int blocksize; 153 unsigned int blocksize;
153 mode_t fmode; 154 mode_t fmode;
@@ -312,7 +313,7 @@ enum {
312 Opt_block, Opt_check_r, Opt_check_s, Opt_cruft, Opt_gid, Opt_ignore, 313 Opt_block, Opt_check_r, Opt_check_s, Opt_cruft, Opt_gid, Opt_ignore,
313 Opt_iocharset, Opt_map_a, Opt_map_n, Opt_map_o, Opt_mode, Opt_nojoliet, 314 Opt_iocharset, Opt_map_a, Opt_map_n, Opt_map_o, Opt_mode, Opt_nojoliet,
314 Opt_norock, Opt_sb, Opt_session, Opt_uid, Opt_unhide, Opt_utf8, Opt_err, 315 Opt_norock, Opt_sb, Opt_session, Opt_uid, Opt_unhide, Opt_utf8, Opt_err,
315 Opt_nocompress, Opt_hide, Opt_showassoc, Opt_dmode, 316 Opt_nocompress, Opt_hide, Opt_showassoc, Opt_dmode, Opt_overriderockperm,
316}; 317};
317 318
318static const match_table_t tokens = { 319static const match_table_t tokens = {
@@ -340,6 +341,7 @@ static const match_table_t tokens = {
340 {Opt_gid, "gid=%u"}, 341 {Opt_gid, "gid=%u"},
341 {Opt_mode, "mode=%u"}, 342 {Opt_mode, "mode=%u"},
342 {Opt_dmode, "dmode=%u"}, 343 {Opt_dmode, "dmode=%u"},
344 {Opt_overriderockperm, "overriderockperm"},
343 {Opt_block, "block=%u"}, 345 {Opt_block, "block=%u"},
344 {Opt_ignore, "conv=binary"}, 346 {Opt_ignore, "conv=binary"},
345 {Opt_ignore, "conv=b"}, 347 {Opt_ignore, "conv=b"},
@@ -367,16 +369,12 @@ static int parse_options(char *options, struct iso9660_options *popt)
367 popt->check = 'u'; /* unset */ 369 popt->check = 'u'; /* unset */
368 popt->nocompress = 0; 370 popt->nocompress = 0;
369 popt->blocksize = 1024; 371 popt->blocksize = 1024;
370 popt->fmode = popt->dmode = S_IRUGO | S_IXUGO; /* 372 popt->fmode = popt->dmode = ISOFS_INVALID_MODE;
371 * r-x for all. The disc could
372 * be shared with DOS machines so
373 * virtually anything could be
374 * a valid executable.
375 */
376 popt->gid = 0; 373 popt->gid = 0;
377 popt->uid = 0; 374 popt->uid = 0;
378 popt->iocharset = NULL; 375 popt->iocharset = NULL;
379 popt->utf8 = 0; 376 popt->utf8 = 0;
377 popt->overriderockperm = 0;
380 popt->session=-1; 378 popt->session=-1;
381 popt->sbsector=-1; 379 popt->sbsector=-1;
382 if (!options) 380 if (!options)
@@ -466,6 +464,9 @@ static int parse_options(char *options, struct iso9660_options *popt)
466 return 0; 464 return 0;
467 popt->dmode = option; 465 popt->dmode = option;
468 break; 466 break;
467 case Opt_overriderockperm:
468 popt->overriderockperm = 1;
469 break;
469 case Opt_block: 470 case Opt_block:
470 if (match_int(&args[0], &option)) 471 if (match_int(&args[0], &option))
471 return 0; 472 return 0;
@@ -811,13 +812,20 @@ root_found:
811 sbi->s_gid = opt.gid; 812 sbi->s_gid = opt.gid;
812 sbi->s_utf8 = opt.utf8; 813 sbi->s_utf8 = opt.utf8;
813 sbi->s_nocompress = opt.nocompress; 814 sbi->s_nocompress = opt.nocompress;
815 sbi->s_overriderockperm = opt.overriderockperm;
814 /* 816 /*
815 * It would be incredibly stupid to allow people to mark every file 817 * It would be incredibly stupid to allow people to mark every file
816 * on the disk as suid, so we merely allow them to set the default 818 * on the disk as suid, so we merely allow them to set the default
817 * permissions. 819 * permissions.
818 */ 820 */
819 sbi->s_fmode = opt.fmode & 0777; 821 if (opt.fmode != ISOFS_INVALID_MODE)
820 sbi->s_dmode = opt.dmode & 0777; 822 sbi->s_fmode = opt.fmode & 0777;
823 else
824 sbi->s_fmode = ISOFS_INVALID_MODE;
825 if (opt.dmode != ISOFS_INVALID_MODE)
826 sbi->s_dmode = opt.dmode & 0777;
827 else
828 sbi->s_dmode = ISOFS_INVALID_MODE;
821 829
822 /* 830 /*
823 * Read the root inode, which _may_ result in changing 831 * Read the root inode, which _may_ result in changing
@@ -1261,7 +1269,10 @@ static int isofs_read_inode(struct inode *inode)
1261 ei->i_file_format = isofs_file_normal; 1269 ei->i_file_format = isofs_file_normal;
1262 1270
1263 if (de->flags[-high_sierra] & 2) { 1271 if (de->flags[-high_sierra] & 2) {
1264 inode->i_mode = sbi->s_dmode | S_IFDIR; 1272 if (sbi->s_dmode != ISOFS_INVALID_MODE)
1273 inode->i_mode = S_IFDIR | sbi->s_dmode;
1274 else
1275 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
1265 inode->i_nlink = 1; /* 1276 inode->i_nlink = 1; /*
1266 * Set to 1. We know there are 2, but 1277 * Set to 1. We know there are 2, but
1267 * the find utility tries to optimize 1278 * the find utility tries to optimize
@@ -1270,8 +1281,16 @@ static int isofs_read_inode(struct inode *inode)
1270 * do it the hard way. 1281 * do it the hard way.
1271 */ 1282 */
1272 } else { 1283 } else {
1273 /* Everybody gets to read the file. */ 1284 if (sbi->s_fmode != ISOFS_INVALID_MODE) {
1274 inode->i_mode = sbi->s_fmode | S_IFREG; 1285 inode->i_mode = S_IFREG | sbi->s_fmode;
1286 } else {
1287 /*
1288 * Set default permissions: r-x for all. The disc
1289 * could be shared with DOS machines so virtually
1290 * anything could be a valid executable.
1291 */
1292 inode->i_mode = S_IFREG | S_IRUGO | S_IXUGO;
1293 }
1275 inode->i_nlink = 1; 1294 inode->i_nlink = 1;
1276 } 1295 }
1277 inode->i_uid = sbi->s_uid; 1296 inode->i_uid = sbi->s_uid;
@@ -1349,6 +1368,13 @@ static int isofs_read_inode(struct inode *inode)
1349 test_and_set_uid(&inode->i_uid, sbi->s_uid); 1368 test_and_set_uid(&inode->i_uid, sbi->s_uid);
1350 test_and_set_gid(&inode->i_gid, sbi->s_gid); 1369 test_and_set_gid(&inode->i_gid, sbi->s_gid);
1351 } 1370 }
1371 /* Now set final access rights if overriding rock ridge setting */
1372 if (S_ISDIR(inode->i_mode) && sbi->s_overriderockperm &&
1373 sbi->s_dmode != ISOFS_INVALID_MODE)
1374 inode->i_mode = S_IFDIR | sbi->s_dmode;
1375 if (S_ISREG(inode->i_mode) && sbi->s_overriderockperm &&
1376 sbi->s_fmode != ISOFS_INVALID_MODE)
1377 inode->i_mode = S_IFREG | sbi->s_fmode;
1352 1378
1353 /* Install the inode operations vector */ 1379 /* Install the inode operations vector */
1354 if (S_ISREG(inode->i_mode)) { 1380 if (S_ISREG(inode->i_mode)) {
diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h
index ccbf72faf27a..9679fbcbfc03 100644
--- a/fs/isofs/isofs.h
+++ b/fs/isofs/isofs.h
@@ -50,6 +50,7 @@ struct isofs_sb_info {
50 unsigned char s_nocompress; 50 unsigned char s_nocompress;
51 unsigned char s_hide; 51 unsigned char s_hide;
52 unsigned char s_showassoc; 52 unsigned char s_showassoc;
53 unsigned char s_overriderockperm;
53 54
54 mode_t s_fmode; 55 mode_t s_fmode;
55 mode_t s_dmode; 56 mode_t s_dmode;
@@ -58,6 +59,8 @@ struct isofs_sb_info {
58 struct nls_table *s_nls_iocharset; /* Native language support table */ 59 struct nls_table *s_nls_iocharset; /* Native language support table */
59}; 60};
60 61
62#define ISOFS_INVALID_MODE ((mode_t) -1)
63
61static inline struct isofs_sb_info *ISOFS_SB(struct super_block *sb) 64static inline struct isofs_sb_info *ISOFS_SB(struct super_block *sb)
62{ 65{
63 return sb->s_fs_info; 66 return sb->s_fs_info;