Commit 67a1b292 authored by Hirofumi Ogawa's avatar Hirofumi Ogawa Committed by Linus Torvalds

[PATCH] adds dmask option to fat (5/5)

This adds the dmask option. Yes, the dmask option is the permission
bitmask for directory.
parent 8a763142
...@@ -8,6 +8,10 @@ if you want to format from within Linux. ...@@ -8,6 +8,10 @@ if you want to format from within Linux.
VFAT MOUNT OPTIONS VFAT MOUNT OPTIONS
---------------------------------------------------------------------- ----------------------------------------------------------------------
umask=### -- The permission mask (see umask(1)) for the regulare file.
The default is the umask of current process.
dmask=### -- The permission mask for the directory.
The default is the umask of current process.
codepage=### -- Sets the codepage for converting to shortname characters codepage=### -- Sets the codepage for converting to shortname characters
on FAT and VFAT filesystems. By default, codepage 437 on FAT and VFAT filesystems. By default, codepage 437
is used. This is the default for the U.S. and some is used. This is the default for the U.S. and some
......
...@@ -227,6 +227,7 @@ static int fat_show_options(struct seq_file *m, struct vfsmount *mnt) ...@@ -227,6 +227,7 @@ static int fat_show_options(struct seq_file *m, struct vfsmount *mnt)
if (opts->fs_gid != 0) if (opts->fs_gid != 0)
seq_printf(m, ",gid=%d", opts->fs_gid); seq_printf(m, ",gid=%d", opts->fs_gid);
seq_printf(m, ",umask=%04o", opts->fs_umask); seq_printf(m, ",umask=%04o", opts->fs_umask);
seq_printf(m, ",dmask=%04o", opts->fs_dmask);
if (sbi->nls_disk) if (sbi->nls_disk)
seq_printf(m, ",codepage=%s", sbi->nls_disk->charset); seq_printf(m, ",codepage=%s", sbi->nls_disk->charset);
if (isvfat) { if (isvfat) {
...@@ -290,7 +291,7 @@ static int parse_options(char *options, int is_vfat, int *debug, ...@@ -290,7 +291,7 @@ static int parse_options(char *options, int is_vfat, int *debug,
opts->fs_uid = current->uid; opts->fs_uid = current->uid;
opts->fs_gid = current->gid; opts->fs_gid = current->gid;
opts->fs_umask = current->fs->umask; opts->fs_umask = opts->fs_dmask = current->fs->umask;
opts->codepage = 0; opts->codepage = 0;
opts->iocharset = NULL; opts->iocharset = NULL;
if (is_vfat) if (is_vfat)
...@@ -368,6 +369,13 @@ static int parse_options(char *options, int is_vfat, int *debug, ...@@ -368,6 +369,13 @@ static int parse_options(char *options, int is_vfat, int *debug,
if (*value) ret = 0; if (*value) ret = 0;
} }
} }
else if (!strcmp(this_char,"dmask")) {
if (!value || !*value) ret = 0;
else {
opts->fs_dmask = simple_strtoul(value,&value,8);
if (*value) ret = 0;
}
}
else if (!strcmp(this_char,"debug")) { else if (!strcmp(this_char,"debug")) {
if (value) ret = 0; if (value) ret = 0;
else *debug = 1; else *debug = 1;
...@@ -530,7 +538,7 @@ static int fat_read_root(struct inode *inode) ...@@ -530,7 +538,7 @@ static int fat_read_root(struct inode *inode)
inode->i_gid = sbi->options.fs_gid; inode->i_gid = sbi->options.fs_gid;
inode->i_version++; inode->i_version++;
inode->i_generation = 0; 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_op = sbi->dir_ops;
inode->i_fop = &fat_dir_operations; inode->i_fop = &fat_dir_operations;
if (sbi->fat_bits == 32) { if (sbi->fat_bits == 32) {
...@@ -1157,8 +1165,8 @@ static int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de) ...@@ -1157,8 +1165,8 @@ static int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
if ((de->attr & ATTR_DIR) && !IS_FREE(de->name)) { if ((de->attr & ATTR_DIR) && !IS_FREE(de->name)) {
inode->i_generation &= ~1; inode->i_generation &= ~1;
inode->i_mode = MSDOS_MKMODE(de->attr,S_IRWXUGO & inode->i_mode = MSDOS_MKMODE(de->attr,
~sbi->options.fs_umask) | S_IFDIR; S_IRWXUGO & ~sbi->options.fs_dmask) | S_IFDIR;
inode->i_op = sbi->dir_ops; inode->i_op = sbi->dir_ops;
inode->i_fop = &fat_dir_operations; inode->i_fop = &fat_dir_operations;
...@@ -1278,9 +1286,9 @@ void fat_write_inode(struct inode *inode, int wait) ...@@ -1278,9 +1286,9 @@ void fat_write_inode(struct inode *inode, int wait)
int fat_notify_change(struct dentry * dentry, struct iattr * attr) 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; struct inode *inode = dentry->d_inode;
int error = 0; int mask, error = 0;
lock_kernel(); lock_kernel();
...@@ -1294,21 +1302,21 @@ int fat_notify_change(struct dentry * dentry, struct iattr * attr) ...@@ -1294,21 +1302,21 @@ int fat_notify_change(struct dentry * dentry, struct iattr * attr)
error = inode_change_ok(inode, attr); error = inode_change_ok(inode, attr);
if (error) { if (error) {
if( MSDOS_SB(sb)->options.quiet ) if (sbi->options.quiet)
error = 0; error = 0;
goto out; goto out;
} }
if (((attr->ia_valid & ATTR_UID) && 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_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_valid & ATTR_MODE) &&
(attr->ia_mode & ~MSDOS_VALID_MODE))) (attr->ia_mode & ~MSDOS_VALID_MODE)))
error = -EPERM; error = -EPERM;
if (error) { if (error) {
if( MSDOS_SB(sb)->options.quiet ) if (sbi->options.quiet)
error = 0; error = 0;
goto out; goto out;
} }
...@@ -1317,11 +1325,10 @@ int fat_notify_change(struct dentry * dentry, struct iattr * attr) ...@@ -1317,11 +1325,10 @@ int fat_notify_change(struct dentry * dentry, struct iattr * attr)
goto out; goto out;
if (S_ISDIR(inode->i_mode)) if (S_ISDIR(inode->i_mode))
inode->i_mode |= S_IXUGO; mask = sbi->options.fs_dmask;
else
inode->i_mode = ((inode->i_mode & S_IFMT) | ((((inode->i_mode & S_IRWXU mask = sbi->options.fs_umask;
& ~MSDOS_SB(sb)->options.fs_umask) | S_IRUSR) >> 6)*S_IXUGO)) & inode->i_mode &= S_IFMT | (S_IRWXUGO & ~mask);
~MSDOS_SB(sb)->options.fs_umask;
out: out:
unlock_kernel(); unlock_kernel();
return error; return error;
......
...@@ -10,6 +10,7 @@ struct fat_mount_options { ...@@ -10,6 +10,7 @@ struct fat_mount_options {
uid_t fs_uid; uid_t fs_uid;
gid_t fs_gid; gid_t fs_gid;
unsigned short fs_umask; unsigned short fs_umask;
unsigned short fs_dmask;
unsigned short codepage; /* Codepage for shortname conversions */ unsigned short codepage; /* Codepage for shortname conversions */
char *iocharset; /* Charset used for filename input/display */ char *iocharset; /* Charset used for filename input/display */
unsigned short shortname; /* flags for shortname display/create rule */ unsigned short shortname; /* flags for shortname display/create rule */
......
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