This makes umask behaviour more consistent, so it's now also used for new 
files and the mount options behave like other umask users.
(Problem reported by [EMAIL PROTECTED])

Signed-off-by: Roman Zippel <[EMAIL PROTECTED]>

---

 inode.c |   14 ++++++++++----
 super.c |    6 +++---
 2 files changed, 13 insertions(+), 7 deletions(-)

Index: linux-2.6.11/fs/hfs/inode.c
===================================================================
--- linux-2.6.11.orig/fs/hfs/inode.c    2005-03-19 02:45:46.505988416 +0100
+++ linux-2.6.11/fs/hfs/inode.c 2005-03-19 02:45:47.786768778 +0100
@@ -168,14 +168,16 @@ struct inode *hfs_new_inode(struct inode
        HFS_I(inode)->flags = 0;
        HFS_I(inode)->rsrc_inode = NULL;
        HFS_I(inode)->fs_blocks = 0;
-       if (S_ISDIR(inode->i_mode)) {
+       if (S_ISDIR(mode)) {
                inode->i_size = 2;
                HFS_SB(sb)->folder_count++;
                if (dir->i_ino == HFS_ROOT_CNID)
                        HFS_SB(sb)->root_dirs++;
                inode->i_op = &hfs_dir_inode_operations;
                inode->i_fop = &hfs_dir_operations;
-       } else if (S_ISREG(inode->i_mode)) {
+               inode->i_mode |= S_IRWXUGO;
+               inode->i_mode &= ~HFS_SB(inode->i_sb)->s_dir_umask;
+       } else if (S_ISREG(mode)) {
                HFS_I(inode)->clump_blocks = HFS_SB(sb)->clumpablks;
                HFS_SB(sb)->file_count++;
                if (dir->i_ino == HFS_ROOT_CNID)
@@ -183,6 +185,10 @@ struct inode *hfs_new_inode(struct inode
                inode->i_op = &hfs_file_inode_operations;
                inode->i_fop = &hfs_file_operations;
                inode->i_mapping->a_ops = &hfs_aops;
+               inode->i_mode |= S_IRUGO|S_IXUGO;
+               if (mode & S_IWUSR)
+                       inode->i_mode |= S_IWUGO;
+               inode->i_mode &= ~HFS_SB(inode->i_sb)->s_file_umask;
                HFS_I(inode)->phys_size = 0;
                HFS_I(inode)->alloc_blocks = 0;
                HFS_I(inode)->first_blocks = 0;
@@ -311,7 +317,7 @@ int hfs_read_inode(struct inode *inode, 
                inode->i_mode = S_IRUGO | S_IXUGO;
                if (!(rec->file.Flags & HFS_FIL_LOCK))
                        inode->i_mode |= S_IWUGO;
-               inode->i_mode &= hsb->s_file_umask;
+               inode->i_mode &= ~hsb->s_file_umask;
                inode->i_mode |= S_IFREG;
                inode->i_ctime = inode->i_atime = inode->i_mtime =
                                hfs_m_to_utime(rec->file.MdDat);
@@ -323,7 +329,7 @@ int hfs_read_inode(struct inode *inode, 
                inode->i_ino = be32_to_cpu(rec->dir.DirID);
                inode->i_size = be16_to_cpu(rec->dir.Val) + 2;
                HFS_I(inode)->fs_blocks = 0;
-               inode->i_mode = S_IFDIR | (S_IRWXUGO & hsb->s_dir_umask);
+               inode->i_mode = S_IFDIR | (S_IRWXUGO & ~hsb->s_dir_umask);
                inode->i_ctime = inode->i_atime = inode->i_mtime =
                                hfs_m_to_utime(rec->dir.MdDat);
                inode->i_op = &hfs_dir_inode_operations;
Index: linux-2.6.11/fs/hfs/super.c
===================================================================
--- linux-2.6.11.orig/fs/hfs/super.c    2005-03-19 02:45:40.294053685 +0100
+++ linux-2.6.11/fs/hfs/super.c 2005-03-19 02:45:47.786768778 +0100
@@ -149,8 +149,8 @@ static int parse_options(char *options, 
        /* initialize the sb with defaults */
        hsb->s_uid = current->uid;
        hsb->s_gid = current->gid;
-       hsb->s_file_umask = 0644;
-       hsb->s_dir_umask = 0755;
+       hsb->s_file_umask = 0133;
+       hsb->s_dir_umask = 0022;
        hsb->s_type = hsb->s_creator = cpu_to_be32(0x3f3f3f3f); /* == '????' */
        hsb->s_quiet = 0;
        hsb->part = -1;
@@ -229,7 +229,7 @@ static int parse_options(char *options, 
        }
 
        hsb->s_dir_umask &= 0777;
-       hsb->s_file_umask &= 0777;
+       hsb->s_file_umask &= 0577;
 
        return 1;
 }
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to