udf: implement mode and dmode mounting options
Subsystems (2)
PATCH 1/1 udf: implement mode and dmode mounting options
"dmode" allows overriding permissions of directories and "mode" allows overriding permissions of files.
--- Documentation/filesystems/udf.txt | 2 ++ fs/udf/inode.c | 11 +++++++++-- fs/udf/super.c | 31 ++++++++++++++++++++++++++++++- fs/udf/udf_sb.h | 2 ++ 4 files changed, 43 insertions(+), 3 deletions(-)
Documentation/filesystems/udf.txt +2 -0
@@ -24,6 +24,8 @@ The following mount options are supported: gid= Set the default group. umask= Set the default umask. + mode= Set the default file permissions. + dmode= Set the default directory permissions. uid= Set the default user. bs= Set the block size. unhide Show otherwise hidden files.
fs/udf/inode.c +9 -2
@@ -1221,8 +1221,15 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) inode->i_size =le64_to_cpu (fe->informationLength); iinfo->i_lenExtents = inode->i_size; - inode->i_mode =udf_convert_permissions (fe); - inode->i_mode &= ~UDF_SB (inode->i_sb)->s_umask; +if (fe->icbTag.fileType !=ICBTAG_FILE_TYPE_DIRECTORY && + sbi->s_fmode !=-1 ) + inode->i_mode = sbi->s_fmode; +else if (fe->icbTag.fileType ==ICBTAG_FILE_TYPE_DIRECTORY && + sbi->s_dmode !=-1 ) + inode->i_mode = sbi->s_dmode; +else + inode->i_mode =udf_convert_permissions (fe); + inode->i_mode &= ~sbi->s_umask;if (iinfo->i_efe ==0 ) { inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) <<
fs/udf/super.c +30 -1
@@ -201,6 +201,8 @@ struct udf_options {mode_t umask;gid_t gid;uid_t uid; +mode_t fmode; +mode_t dmode;struct nls_table *nls_map; };
@@ -282,6 +284,10 @@ static int udf_show_options(struct seq_file *seq, struct vfsmount *mnt)seq_printf (seq,",gid=%u" , sbi->s_gid);if (sbi->s_umask !=0 )seq_printf (seq,",umask=%o" , sbi->s_umask); +if (sbi->s_fmode !=-1 ) +seq_printf (seq,",mode=%o" , sbi->s_fmode); +if (sbi->s_dmode !=-1 ) +seq_printf (seq,",dmode=%o" , sbi->s_dmode);if (UDF_QUERY_FLAG (sb,UDF_FLAG_SESSION_SET ))seq_printf (seq,",session=%u" , sbi->s_session);if (UDF_QUERY_FLAG (sb,UDF_FLAG_LASTBLOCK_SET ))
@@ -317,6 +323,8 @@ static int udf_show_options(struct seq_file *seq, struct vfsmount *mnt)* * gid= Set the default group. * umask= Set the default umask. +* mode= Set the default file permissions. +* dmode= Set the default directory permissions. * uid= Set the default user. * bs= Set the block size. * unhide Show otherwise hidden files.
@@ -366,7 +374,8 @@ enum { Opt_gid, Opt_uid, Opt_umask, Opt_session, Opt_lastblock, Opt_anchor, Opt_volume, Opt_partition, Opt_fileset, Opt_rootdir, Opt_utf8, Opt_iocharset, - Opt_err, Opt_uforget, Opt_uignore, Opt_gforget, Opt_gignore + Opt_err, Opt_uforget, Opt_uignore, Opt_gforget, Opt_gignore, + Opt_fmode, Opt_dmode }; static const match_table_t tokens = {
@@ -395,6 +404,8 @@ static const match_table_t tokens = { {Opt_rootdir, "rootdir=%u"}, {Opt_utf8, "utf8"}, {Opt_iocharset, "iocharset=%s"}, + {Opt_fmode, "mode=%o"}, + {Opt_dmode, "dmode=%o"}, {Opt_err, NULL} };
@@ -531,6 +542,16 @@ static int udf_parse_options(char *options, struct udf_options *uopt,case Opt_gforget: uopt->flags |= (1 <<UDF_FLAG_GID_FORGET );break ; +case Opt_fmode: +if (match_octal (args, &option)) +return 0 ; + uopt->fmode = option &0777 ; +break ; +case Opt_dmode: +if (match_octal (args, &option)) +return 0 ; + uopt->dmode = option &0777 ; +break ;default :printk (KERN_ERR "udf: bad mount option \"%s\" " "or missing value\n" , p);
@@ -560,6 +581,8 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options) uopt.uid = sbi->s_uid; uopt.gid = sbi->s_gid; uopt.umask = sbi->s_umask; + uopt.fmode = sbi->s_fmode; + uopt.dmode = sbi->s_dmode;if (!udf_parse_options (options, &uopt, true))return -EINVAL ;
@@ -568,6 +591,8 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options) sbi->s_uid = uopt.uid; sbi->s_gid = uopt.gid; sbi->s_umask = uopt.umask; + sbi->s_fmode = uopt.fmode; + sbi->s_dmode = uopt.dmode;if (sbi->s_lvid_bh) {int write_rev =le16_to_cpu (udf_sb_lvidiu (sbi)->minUDFWriteRev);
@@ -1869,6 +1894,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) uopt.uid =-1 ; uopt.gid =-1 ; uopt.umask =0 ; + uopt.fmode =-1 ; + uopt.dmode =-1 ; sbi =kzalloc (sizeof (struct udf_sb_info ),GFP_KERNEL );if (!sbi)
@@ -1906,6 +1933,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) sbi->s_uid = uopt.uid; sbi->s_gid = uopt.gid; sbi->s_umask = uopt.umask; + sbi->s_fmode = uopt.fmode; + sbi->s_dmode = uopt.dmode; sbi->s_nls_map = uopt.nls_map;/* Set the block size for all transfers */
fs/udf/udf_sb.h +2 -0
@@ -123,6 +123,8 @@ struct udf_sb_info {mode_t s_umask;gid_t s_gid;uid_t s_uid; +mode_t s_fmode; +mode_t s_dmode;/* Root Info */ struct timespec s_record_time;
Signature · 1 line
1.5.6.4
Quoted 17 lines · On Sun, 16 Nov 2008 20:52:19 +0100 Marcin Slusarz <[email protected]>…
"dmode" allows overriding permissions of directories and "mode" allows overriding permissions of files.
Signed-off-by Marcin Slusarz <[email protected]>Cc Jan Kara <[email protected]>--- Documentation/filesystems/udf.txt | 2 ++ fs/udf/inode.c | 11 +++++++++-- fs/udf/super.c | 31 ++++++++++++++++++++++++++++++- fs/udf/udf_sb.h | 2 ++ 4 files changed, 43 insertions(+), 3 deletions(-)Documentation/filesystems/udf.txt +0
-0
Documentation/filesystems/udf.txt The following mount options are supported: · line 28
Quoted 5 lines
Documentation/filesystems/udf.txt +2
-0@@ -24,6 +24,8 @@ The following mount options are supported: gid= Set the default group. umask= Set the default umask. + mode= Set the default file permissions. + dmode= Set the default directory permissions.
Can we give these the same names and usage as their fatfs equivalents?
Quoted 21 lines · Andrew Morton
Quoted 18 lines · On Sun, 16 Nov 2008 20:52:19 +0100 Marcin Slusarz <[email protected]>…
"dmode" allows overriding permissions of directories and "mode" allows overriding permissions of files.
Signed-off-by Marcin Slusarz <[email protected]>Cc Jan Kara <[email protected]>--- Documentation/filesystems/udf.txt | 2 ++ fs/udf/inode.c | 11 +++++++++-- fs/udf/super.c | 31 ++++++++++++++++++++++++++++++- fs/udf/udf_sb.h | 2 ++ 4 files changed, 43 insertions(+), 3 deletions(-)Documentation/filesystems/udf.txt +0
-0@@ -24,6 +24,8 @@ The following mount options are supported:
Quoted 6 lines
Documentation/filesystems/udf.txt The following mount options are supported: · line 28
Quoted 4 lines
Documentation/filesystems/udf.txt +2
-0gid= Set the default group. umask= Set the default umask. + mode= Set the default file permissions. + dmode= Set the default directory permissions.Can we give these the same names and usage as their fatfs equivalents?
Yes, making these options dmask and fmask would be more consistent I
think. Martin?
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 22 lines · Jan Kara
Quoted 21 lines · Andrew Morton
Quoted 18 lines · On Sun, 16 Nov 2008 20:52:19 +0100 Marcin Slusarz <[email protected]>…
"dmode" allows overriding permissions of directories and "mode" allows overriding permissions of files.
Signed-off-by Marcin Slusarz <[email protected]>Cc Jan Kara <[email protected]>--- Documentation/filesystems/udf.txt | 2 ++ fs/udf/inode.c | 11 +++++++++-- fs/udf/super.c | 31 ++++++++++++++++++++++++++++++- fs/udf/udf_sb.h | 2 ++ 4 files changed, 43 insertions(+), 3 deletions(-)Documentation/filesystems/udf.txt +0
-0@@ -24,6 +24,8 @@ The following mount options are supported:
Quoted 8 lines
Quoted 6 lines
Documentation/filesystems/udf.txt The following mount options are supported: · line 28
Quoted 4 lines
Documentation/filesystems/udf.txt +2
-0gid= Set the default group. umask= Set the default umask. + mode= Set the default file permissions. + dmode= Set the default directory permissions.Can we give these the same names and usage as their fatfs equivalents?
Yes, making these options dmask and fmask would be more consistent I
think. Martin?
You can't add permissions by umask/fmask/dmask. I have one DVD with top level dir permissions set to 0000 and there's no way to read it now (as an user) and adding mask options wouldn't change it.
I should mention in a changelog that the names and semantics of these options are copied from isofs.
I can create a second patch which adds mask options but I think modes are needed too. What do you think?
Marcin
Quoted 36 lines · Marcin Slusarz
Quoted 22 lines · Jan Kara
Quoted 21 lines · Andrew Morton
Quoted 18 lines · On Sun, 16 Nov 2008 20:52:19 +0100 Marcin Slusarz <[email protected]>…
"dmode" allows overriding permissions of directories and "mode" allows overriding permissions of files.
Signed-off-by Marcin Slusarz <[email protected]>Cc Jan Kara <[email protected]>--- Documentation/filesystems/udf.txt | 2 ++ fs/udf/inode.c | 11 +++++++++-- fs/udf/super.c | 31 ++++++++++++++++++++++++++++++- fs/udf/udf_sb.h | 2 ++ 4 files changed, 43 insertions(+), 3 deletions(-)Documentation/filesystems/udf.txt +0
-0@@ -24,6 +24,8 @@ The following mount options are supported:Quoted 8 lines
Quoted 6 lines
Documentation/filesystems/udf.txt The following mount options are supported: · line 28
Quoted 4 lines
Documentation/filesystems/udf.txt +2
-0gid= Set the default group. umask= Set the default umask. + mode= Set the default file permissions. + dmode= Set the default directory permissions.Can we give these the same names and usage as their fatfs equivalents?
Yes, making these options dmask and fmask would be more consistent I
think. Martin?You can't add permissions by umask/fmask/dmask. I have one DVD with top level dir permissions set to 0000 and there's no way to read it now (as an user) and adding mask options wouldn't change it.
Quoted 5 lines
I should mention in a changelog that the names and semantics of these options are copied from isofs.
I can create a second patch which adds mask options but I think modes are needed too. What do you think?
Ah, ok. That makes sence (although such DVD's seem to be really broken).
I'll merge the patch.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR