lkml.org 
[lkml]   [2002]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] Add dmask option to fatfs (4/4)
From
Date
This patch separate the umask for directory and file. And added the
new dmask option to be able to specify umask of a directory.

Please apply.
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

diff -urN fat_parse_opt-2.5.18/fs/fat/inode.c fat_dmask-2.5.18/fs/fat/inode.c
--- fat_parse_opt-2.5.18/fs/fat/inode.c Sat May 25 17:19:33 2002
+++ fat_dmask-2.5.18/fs/fat/inode.c Sat May 25 17:24:08 2002
@@ -271,7 +271,7 @@

opts->fs_uid = current->uid;
opts->fs_gid = current->gid;
- opts->fs_umask = current->fs->umask;
+ opts->fs_umask = opts->fs_dmask = current->fs->umask;
opts->codepage = 0;
opts->iocharset = NULL;
opts->shortname = 0;
@@ -311,6 +311,11 @@
goto error;
opts->fs_umask = val & S_IRWXUGO;
}
+ else if (!strcmp(this_char, "dmask")) {
+ if (want_oct(value, "dmask", &val))
+ goto error;
+ opts->fs_dmask = val & S_IRWXUGO;
+ }
else if (!strcmp(this_char, "codepage")) {
if (want_numeric(value, "codepage", &val))
goto error;
@@ -496,7 +501,7 @@
inode->i_gid = sbi->options.fs_gid;
inode->i_version++;
inode->i_generation = 0;
- inode->i_mode = (S_IRWXUGO & ~sbi->options.fs_umask) | S_IFDIR;
+ inode->i_mode = (S_IRWXUGO & ~sbi->options.fs_dmask) | S_IFDIR;
inode->i_op = sbi->dir_ops;
inode->i_fop = &fat_dir_operations;
if (sbi->fat_bits == 32) {
@@ -1111,8 +1116,8 @@

if ((de->attr & ATTR_DIR) && !IS_FREE(de->name)) {
inode->i_generation &= ~1;
- inode->i_mode = MSDOS_MKMODE(de->attr,S_IRWXUGO &
- ~sbi->options.fs_umask) | S_IFDIR;
+ inode->i_mode = MSDOS_MKMODE(de->attr,
+ S_IRWXUGO & ~sbi->options.fs_dmask) | S_IFDIR;
inode->i_op = sbi->dir_ops;
inode->i_fop = &fat_dir_operations;

@@ -1232,9 +1237,9 @@

int fat_notify_change(struct dentry * dentry, struct iattr * attr)
{
- struct super_block *sb = dentry->d_sb;
+ struct msdos_sb_info *sbi = MSDOS_SB(dentry->d_sb);
struct inode *inode = dentry->d_inode;
- int error = 0;
+ int mask, error = 0;

lock_kernel();

@@ -1248,21 +1253,21 @@

error = inode_change_ok(inode, attr);
if (error) {
- if( MSDOS_SB(sb)->options.quiet )
- error = 0;
+ if (sbi->options.quiet)
+ error = 0;
goto out;
}

if (((attr->ia_valid & ATTR_UID) &&
- (attr->ia_uid != MSDOS_SB(sb)->options.fs_uid)) ||
+ (attr->ia_uid != sbi->options.fs_uid)) ||
((attr->ia_valid & ATTR_GID) &&
- (attr->ia_gid != MSDOS_SB(sb)->options.fs_gid)) ||
+ (attr->ia_gid != sbi->options.fs_gid)) ||
((attr->ia_valid & ATTR_MODE) &&
(attr->ia_mode & ~MSDOS_VALID_MODE)))
error = -EPERM;

if (error) {
- if( MSDOS_SB(sb)->options.quiet )
+ if (sbi->options.quiet)
error = 0;
goto out;
}
@@ -1271,11 +1276,10 @@
goto out;

if (S_ISDIR(inode->i_mode))
- inode->i_mode |= S_IXUGO;
-
- inode->i_mode = ((inode->i_mode & S_IFMT) | ((((inode->i_mode & S_IRWXU
- & ~MSDOS_SB(sb)->options.fs_umask) | S_IRUSR) >> 6)*S_IXUGO)) &
- ~MSDOS_SB(sb)->options.fs_umask;
+ mask = sbi->options.fs_dmask;
+ else
+ mask = sbi->options.fs_umask;
+ inode->i_mode &= S_IFMT | (S_IRWXUGO & ~mask);
out:
unlock_kernel();
return error;
diff -urN fat_parse_opt-2.5.18/include/linux/msdos_fs_sb.h fat_dmask-2.5.18/include/linux/msdos_fs_sb.h
--- fat_parse_opt-2.5.18/include/linux/msdos_fs_sb.h Sat May 25 16:52:43 2002
+++ fat_dmask-2.5.18/include/linux/msdos_fs_sb.h Sat May 25 17:24:08 2002
@@ -10,6 +10,7 @@
uid_t fs_uid;
gid_t fs_gid;
unsigned short fs_umask;
+ unsigned short fs_dmask;
unsigned short codepage; /* Codepage for shortname conversions */
char *iocharset; /* Charset used for filename input/display */
unsigned short shortname; /* flags for shortname display/create rule */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 13:26    [W:0.059 / U:0.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site