diff options
author | Phillip Susi <psusi@cfl.rr.com> | 2006-03-08 00:55:24 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-08 17:14:00 -0500 |
commit | 4d6660eb3665f22d16aff466eb9d45df6102b254 (patch) | |
tree | d70e689d8c23c92164f601fa6f8589ed7a5e394b /fs | |
parent | 7f709ed0e3ccd3e88e0632b69f00174e83f8d98b (diff) |
[PATCH] udf: fix uid/gid options and add uid/gid=ignore and forget options
Fix a bug in udf where it would write uid/gid = 0 to the disk for files
owned by the id given with the uid=/gid= mount options. It also adds 4 new
mount options: uid/gid=forget and uid/gid=ignore. Without any options the
id in core and on disk always match. Giving uid/gid=nnn specifies a
default ID to be used in core when the on disk ID is -1. uid/gid=ignore
forces the in core ID to allways be used no matter what the on disk ID is.
uid/gid=forget forces the on disk ID to always be written out as -1.
The use of these options allows you to override ownerships on a disk or
disable ownwership information from being written, allowing the media to be
used portably between different computers and possibly different users
without permissions issues that would require root to correct.
Signed-off-by: Phillip Susi <psusi@cfl.rr.com>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/udf/inode.c | 16 | ||||
-rw-r--r-- | fs/udf/super.c | 18 | ||||
-rw-r--r-- | fs/udf/udf_sb.h | 4 |
3 files changed, 33 insertions, 5 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 395e582ee542..d04cff2273b6 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c | |||
@@ -1045,10 +1045,14 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | inode->i_uid = le32_to_cpu(fe->uid); | 1047 | inode->i_uid = le32_to_cpu(fe->uid); |
1048 | if ( inode->i_uid == -1 ) inode->i_uid = UDF_SB(inode->i_sb)->s_uid; | 1048 | if (inode->i_uid == -1 || UDF_QUERY_FLAG(inode->i_sb, |
1049 | UDF_FLAG_UID_IGNORE)) | ||
1050 | inode->i_uid = UDF_SB(inode->i_sb)->s_uid; | ||
1049 | 1051 | ||
1050 | inode->i_gid = le32_to_cpu(fe->gid); | 1052 | inode->i_gid = le32_to_cpu(fe->gid); |
1051 | if ( inode->i_gid == -1 ) inode->i_gid = UDF_SB(inode->i_sb)->s_gid; | 1053 | if (inode->i_gid == -1 || UDF_QUERY_FLAG(inode->i_sb, |
1054 | UDF_FLAG_GID_IGNORE)) | ||
1055 | inode->i_gid = UDF_SB(inode->i_sb)->s_gid; | ||
1052 | 1056 | ||
1053 | inode->i_nlink = le16_to_cpu(fe->fileLinkCount); | 1057 | inode->i_nlink = le16_to_cpu(fe->fileLinkCount); |
1054 | if (!inode->i_nlink) | 1058 | if (!inode->i_nlink) |
@@ -1335,10 +1339,14 @@ udf_update_inode(struct inode *inode, int do_sync) | |||
1335 | return err; | 1339 | return err; |
1336 | } | 1340 | } |
1337 | 1341 | ||
1338 | if (inode->i_uid != UDF_SB(inode->i_sb)->s_uid) | 1342 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_FORGET)) |
1343 | fe->uid = cpu_to_le32(-1); | ||
1344 | else if (inode->i_uid != UDF_SB(inode->i_sb)->s_uid) | ||
1339 | fe->uid = cpu_to_le32(inode->i_uid); | 1345 | fe->uid = cpu_to_le32(inode->i_uid); |
1340 | 1346 | ||
1341 | if (inode->i_gid != UDF_SB(inode->i_sb)->s_gid) | 1347 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_FORGET)) |
1348 | fe->gid = cpu_to_le32(-1); | ||
1349 | else if (inode->i_gid != UDF_SB(inode->i_sb)->s_gid) | ||
1342 | fe->gid = cpu_to_le32(inode->i_gid); | 1350 | fe->gid = cpu_to_le32(inode->i_gid); |
1343 | 1351 | ||
1344 | udfperms = ((inode->i_mode & S_IRWXO) ) | | 1352 | udfperms = ((inode->i_mode & S_IRWXO) ) | |
diff --git a/fs/udf/super.c b/fs/udf/super.c index 4a6f49adc609..368d8f81fe54 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
@@ -269,7 +269,7 @@ enum { | |||
269 | Opt_gid, Opt_uid, Opt_umask, Opt_session, Opt_lastblock, | 269 | Opt_gid, Opt_uid, Opt_umask, Opt_session, Opt_lastblock, |
270 | Opt_anchor, Opt_volume, Opt_partition, Opt_fileset, | 270 | Opt_anchor, Opt_volume, Opt_partition, Opt_fileset, |
271 | Opt_rootdir, Opt_utf8, Opt_iocharset, | 271 | Opt_rootdir, Opt_utf8, Opt_iocharset, |
272 | Opt_err | 272 | Opt_err, Opt_uforget, Opt_uignore, Opt_gforget, Opt_gignore |
273 | }; | 273 | }; |
274 | 274 | ||
275 | static match_table_t tokens = { | 275 | static match_table_t tokens = { |
@@ -282,6 +282,10 @@ static match_table_t tokens = { | |||
282 | {Opt_adinicb, "adinicb"}, | 282 | {Opt_adinicb, "adinicb"}, |
283 | {Opt_shortad, "shortad"}, | 283 | {Opt_shortad, "shortad"}, |
284 | {Opt_longad, "longad"}, | 284 | {Opt_longad, "longad"}, |
285 | {Opt_uforget, "uid=forget"}, | ||
286 | {Opt_uignore, "uid=ignore"}, | ||
287 | {Opt_gforget, "gid=forget"}, | ||
288 | {Opt_gignore, "gid=ignore"}, | ||
285 | {Opt_gid, "gid=%u"}, | 289 | {Opt_gid, "gid=%u"}, |
286 | {Opt_uid, "uid=%u"}, | 290 | {Opt_uid, "uid=%u"}, |
287 | {Opt_umask, "umask=%o"}, | 291 | {Opt_umask, "umask=%o"}, |
@@ -414,6 +418,18 @@ udf_parse_options(char *options, struct udf_options *uopt) | |||
414 | uopt->flags |= (1 << UDF_FLAG_NLS_MAP); | 418 | uopt->flags |= (1 << UDF_FLAG_NLS_MAP); |
415 | break; | 419 | break; |
416 | #endif | 420 | #endif |
421 | case Opt_uignore: | ||
422 | uopt->flags |= (1 << UDF_FLAG_UID_IGNORE); | ||
423 | break; | ||
424 | case Opt_uforget: | ||
425 | uopt->flags |= (1 << UDF_FLAG_UID_FORGET); | ||
426 | break; | ||
427 | case Opt_gignore: | ||
428 | uopt->flags |= (1 << UDF_FLAG_GID_IGNORE); | ||
429 | break; | ||
430 | case Opt_gforget: | ||
431 | uopt->flags |= (1 << UDF_FLAG_GID_FORGET); | ||
432 | break; | ||
417 | default: | 433 | default: |
418 | printk(KERN_ERR "udf: bad mount option \"%s\" " | 434 | printk(KERN_ERR "udf: bad mount option \"%s\" " |
419 | "or missing value\n", p); | 435 | "or missing value\n", p); |
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h index 663669810be6..110f8d62616f 100644 --- a/fs/udf/udf_sb.h +++ b/fs/udf/udf_sb.h | |||
@@ -20,6 +20,10 @@ | |||
20 | #define UDF_FLAG_VARCONV 8 | 20 | #define UDF_FLAG_VARCONV 8 |
21 | #define UDF_FLAG_NLS_MAP 9 | 21 | #define UDF_FLAG_NLS_MAP 9 |
22 | #define UDF_FLAG_UTF8 10 | 22 | #define UDF_FLAG_UTF8 10 |
23 | #define UDF_FLAG_UID_FORGET 11 /* save -1 for uid to disk */ | ||
24 | #define UDF_FLAG_UID_IGNORE 12 /* use sb uid instead of on disk uid */ | ||
25 | #define UDF_FLAG_GID_FORGET 13 | ||
26 | #define UDF_FLAG_GID_IGNORE 14 | ||
23 | 27 | ||
24 | #define UDF_PART_FLAG_UNALLOC_BITMAP 0x0001 | 28 | #define UDF_PART_FLAG_UNALLOC_BITMAP 0x0001 |
25 | #define UDF_PART_FLAG_UNALLOC_TABLE 0x0002 | 29 | #define UDF_PART_FLAG_UNALLOC_TABLE 0x0002 |