ChangeSet 1.2231.1.188, 2005/03/28 20:08:39-08:00, [EMAIL PROTECTED]

        [PATCH] hfs: fix umask behaviour
        
        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]>
        Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
        Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>



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


diff -Nru a/fs/hfs/inode.c b/fs/hfs/inode.c
--- a/fs/hfs/inode.c    2005-03-28 21:48:05 -08:00
+++ b/fs/hfs/inode.c    2005-03-28 21:48:05 -08:00
@@ -171,14 +171,16 @@
        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)
@@ -186,6 +188,10 @@
                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;
@@ -314,7 +320,7 @@
                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);
@@ -326,7 +332,7 @@
                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;
diff -Nru a/fs/hfs/super.c b/fs/hfs/super.c
--- a/fs/hfs/super.c    2005-03-28 21:48:05 -08:00
+++ b/fs/hfs/super.c    2005-03-28 21:48:05 -08:00
@@ -147,8 +147,8 @@
        /* 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;
@@ -227,7 +227,7 @@
        }
 
        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 bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to