Commit 87bc730c authored by Marcin Slusarz's avatar Marcin Slusarz Committed by Jan Kara

udf: fix default mode and dmode options handling

On x86 (and several other archs) mode_t is defined as "unsigned short"
and comparing unsigned shorts to negative ints is broken (because short
is promoted to int and then compared). Fix it.
Reported-and-tested-by: default avatarLaurent Riffard <laurent.riffard@free.fr>
Signed-off-by: default avatarMarcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent e650b94a
...@@ -1223,10 +1223,10 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) ...@@ -1223,10 +1223,10 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
iinfo->i_lenExtents = inode->i_size; iinfo->i_lenExtents = inode->i_size;
if (fe->icbTag.fileType != ICBTAG_FILE_TYPE_DIRECTORY && if (fe->icbTag.fileType != ICBTAG_FILE_TYPE_DIRECTORY &&
sbi->s_fmode != -1) sbi->s_fmode != UDF_INVALID_MODE)
inode->i_mode = sbi->s_fmode; inode->i_mode = sbi->s_fmode;
else if (fe->icbTag.fileType == ICBTAG_FILE_TYPE_DIRECTORY && else if (fe->icbTag.fileType == ICBTAG_FILE_TYPE_DIRECTORY &&
sbi->s_dmode != -1) sbi->s_dmode != UDF_INVALID_MODE)
inode->i_mode = sbi->s_dmode; inode->i_mode = sbi->s_dmode;
else else
inode->i_mode = udf_convert_permissions(fe); inode->i_mode = udf_convert_permissions(fe);
......
...@@ -284,9 +284,9 @@ static int udf_show_options(struct seq_file *seq, struct vfsmount *mnt) ...@@ -284,9 +284,9 @@ static int udf_show_options(struct seq_file *seq, struct vfsmount *mnt)
seq_printf(seq, ",gid=%u", sbi->s_gid); seq_printf(seq, ",gid=%u", sbi->s_gid);
if (sbi->s_umask != 0) if (sbi->s_umask != 0)
seq_printf(seq, ",umask=%o", sbi->s_umask); seq_printf(seq, ",umask=%o", sbi->s_umask);
if (sbi->s_fmode != -1) if (sbi->s_fmode != UDF_INVALID_MODE)
seq_printf(seq, ",mode=%o", sbi->s_fmode); seq_printf(seq, ",mode=%o", sbi->s_fmode);
if (sbi->s_dmode != -1) if (sbi->s_dmode != UDF_INVALID_MODE)
seq_printf(seq, ",dmode=%o", sbi->s_dmode); seq_printf(seq, ",dmode=%o", sbi->s_dmode);
if (UDF_QUERY_FLAG(sb, UDF_FLAG_SESSION_SET)) if (UDF_QUERY_FLAG(sb, UDF_FLAG_SESSION_SET))
seq_printf(seq, ",session=%u", sbi->s_session); seq_printf(seq, ",session=%u", sbi->s_session);
...@@ -1892,8 +1892,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) ...@@ -1892,8 +1892,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
uopt.uid = -1; uopt.uid = -1;
uopt.gid = -1; uopt.gid = -1;
uopt.umask = 0; uopt.umask = 0;
uopt.fmode = -1; uopt.fmode = UDF_INVALID_MODE;
uopt.dmode = -1; uopt.dmode = UDF_INVALID_MODE;
sbi = kzalloc(sizeof(struct udf_sb_info), GFP_KERNEL); sbi = kzalloc(sizeof(struct udf_sb_info), GFP_KERNEL);
if (!sbi) if (!sbi)
......
...@@ -48,6 +48,8 @@ ...@@ -48,6 +48,8 @@
#define UDF_SPARABLE_MAP15 0x1522U #define UDF_SPARABLE_MAP15 0x1522U
#define UDF_METADATA_MAP25 0x2511U #define UDF_METADATA_MAP25 0x2511U
#define UDF_INVALID_MODE ((mode_t)-1)
#pragma pack(1) /* XXX(hch): Why? This file just defines in-core structures */ #pragma pack(1) /* XXX(hch): Why? This file just defines in-core structures */
struct udf_meta_data { struct udf_meta_data {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment