summaryrefslogtreecommitdiffstats
path: root/fs/isofs/inode.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2009-06-17 16:26:27 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-18 13:03:45 -0700
commit5c4a656b7e51503c2b5e7e7310ec326ee38a8389 (patch)
tree4493bfbd8b4e786ddb4d7e2717eb87de4da08774 /fs/isofs/inode.c
parent52b680c81238ea14693ab893d5d32a4d1c0a987d (diff)
downloadlinux-5c4a656b7e51503c2b5e7e7310ec326ee38a8389.tar.gz
linux-5c4a656b7e51503c2b5e7e7310ec326ee38a8389.tar.bz2
linux-5c4a656b7e51503c2b5e7e7310ec326ee38a8389.zip
isofs: fix setting of uid and gid to 0
isofs allows setting of default uid and gid of files but value 0 was used to indicate that user did not specify any uid/gid mount option. Since this option also overrides uid/gid set in Rock Ridge extension, it makes sense to allow forcing uid/gid 0. Fix option processing to allow this. 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/isofs/inode.c')
-rw-r--r--fs/isofs/inode.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 8e6fd41eec12..0f4f9ca77f8e 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -153,6 +153,8 @@ struct iso9660_options{
unsigned int blocksize;
mode_t fmode;
mode_t dmode;
+ char uid_set;
+ char gid_set;
gid_t gid;
uid_t uid;
char *iocharset;
@@ -370,6 +372,8 @@ static int parse_options(char *options, struct iso9660_options *popt)
popt->nocompress = 0;
popt->blocksize = 1024;
popt->fmode = popt->dmode = ISOFS_INVALID_MODE;
+ popt->uid_set = 0;
+ popt->gid_set = 0;
popt->gid = 0;
popt->uid = 0;
popt->iocharset = NULL;
@@ -448,11 +452,13 @@ static int parse_options(char *options, struct iso9660_options *popt)
if (match_int(&args[0], &option))
return 0;
popt->uid = option;
+ popt->uid_set = 1;
break;
case Opt_gid:
if (match_int(&args[0], &option))
return 0;
popt->gid = option;
+ popt->gid_set = 1;
break;
case Opt_mode:
if (match_int(&args[0], &option))
@@ -810,6 +816,8 @@ root_found:
sbi->s_showassoc = opt.showassoc;
sbi->s_uid = opt.uid;
sbi->s_gid = opt.gid;
+ sbi->s_uid_set = opt.uid_set;
+ sbi->s_gid_set = opt.gid_set;
sbi->s_utf8 = opt.utf8;
sbi->s_nocompress = opt.nocompress;
sbi->s_overriderockperm = opt.overriderockperm;
@@ -1103,18 +1111,6 @@ static const struct address_space_operations isofs_aops = {
.bmap = _isofs_bmap
};
-static inline void test_and_set_uid(uid_t *p, uid_t value)
-{
- if (value)
- *p = value;
-}
-
-static inline void test_and_set_gid(gid_t *p, gid_t value)
-{
- if (value)
- *p = value;
-}
-
static int isofs_read_level3_size(struct inode *inode)
{
unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
@@ -1365,8 +1361,10 @@ static int isofs_read_inode(struct inode *inode)
if (!high_sierra) {
parse_rock_ridge_inode(de, inode);
/* if we want uid/gid set, override the rock ridge setting */
- test_and_set_uid(&inode->i_uid, sbi->s_uid);
- test_and_set_gid(&inode->i_gid, sbi->s_gid);
+ if (sbi->s_uid_set)
+ inode->i_uid = sbi->s_uid;
+ if (sbi->s_gid_set)
+ inode->i_gid = sbi->s_gid;
}
/* Now set final access rights if overriding rock ridge setting */
if (S_ISDIR(inode->i_mode) && sbi->s_overriderockperm &&