aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Zippel <zippel@linux-m68k.org>2005-03-28 04:08:39 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-03-28 04:08:39 -0800
commit75fd58c6c5418b69ad93f40d53f65ae05dbe32e0 (patch)
treeeef8327ea4a07b38a07fafb793a18e98dad73777
parentd59b40a3e666ca6cb7b261bc8d11cdabb75a40d2 (diff)
downloadhistory-75fd58c6c5418b69ad93f40d53f65ae05dbe32e0.tar.gz
[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 <horms@verge.net.au>) Signed-off-by: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--fs/hfs/inode.c14
-rw-r--r--fs/hfs/super.c6
2 files changed, 13 insertions, 7 deletions
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index 6aa0935e26ca2..7519123260945 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -171,14 +171,16 @@ struct inode *hfs_new_inode(struct inode *dir, struct qstr *name, int mode)
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 @@ struct inode *hfs_new_inode(struct inode *dir, struct qstr *name, int mode)
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 @@ static int hfs_read_inode(struct inode *inode, void *data)
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 @@ static int hfs_read_inode(struct inode *inode, void *data)
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 --git a/fs/hfs/super.c b/fs/hfs/super.c
index f26142d833a9c..f074eb7eda452 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -147,8 +147,8 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
/* 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 @@ static int parse_options(char *options, struct hfs_sb_info *hsb)
}
hsb->s_dir_umask &= 0777;
- hsb->s_file_umask &= 0777;
+ hsb->s_file_umask &= 0577;
return 1;
}