Add a '-M mask' option so that users can have different

masks for files and directories.  This should make some
of the Midnight Commander users happy.

Remove an extra ')' in the manual page.

PR:		35699
Submitted by:	Eugene Grosbein <eugen@grosbein.pp.ru> (original version)
Tested by:	simon
This commit is contained in:
Tom Rhodes 2003-08-12 20:06:56 +00:00
parent 22088599d2
commit c98a31cad3
5 changed files with 44 additions and 9 deletions

View File

@ -42,6 +42,7 @@
.Op Fl u Ar uid
.Op Fl g Ar gid
.Op Fl m Ar mask
.Op Fl M Ar mask
.Op Fl s
.Op Fl l
.Op Fl 9
@ -104,14 +105,28 @@ read, write, and execute permissions for files, but
others should only have read and execute permissions.
See
.Xr chmod 1
for more information about octal file modes.)
for more information about octal file modes.
Only the nine low-order bits of
.Ar mask
are used.
The value of
.Ar -M
is used if it is supplied and
.Ar -m
is omitted.
The default
.Ar mask
is taken from the
directory on which the file system is being mounted.
.It Fl M Ar mask
Specify the maximum file permissions for directories
in the file system.
The value of
.Ar -m
is used if it is supplied and
.Ar -M
is omitted.
See the previous option's description for details.
.It Fl s
Force behaviour to
ignore and not generate Win'95 long filenames.

View File

@ -88,14 +88,14 @@ main(argc, argv)
{
struct msdosfs_args args;
struct stat sb;
int c, mntflags, set_gid, set_uid, set_mask;
int c, mntflags, set_gid, set_uid, set_mask, set_dirmask;
char *dev, *dir, mntpath[MAXPATHLEN];
mntflags = set_gid = set_uid = set_mask = 0;
mntflags = set_gid = set_uid = set_mask = set_dirmask = 0;
(void)memset(&args, '\0', sizeof(args));
args.magic = MSDOSFS_ARGSMAGIC;
while ((c = getopt(argc, argv, "sl9u:g:m:o:L:W:")) != -1) {
while ((c = getopt(argc, argv, "sl9u:g:m:M:o:L:W:")) != -1) {
switch (c) {
#ifdef MSDOSFSMNT_GEMDOSFS
case 'G':
@ -123,6 +123,10 @@ main(argc, argv)
args.mask = a_mask(optarg);
set_mask = 1;
break;
case 'M':
args.dirmask = a_mask(optarg);
set_dirmask = 1;
break;
case 'L':
load_ultable(&args, optarg);
args.flags |= MSDOSFSMNT_ULTABLE;
@ -144,6 +148,15 @@ main(argc, argv)
if (optind + 2 != argc)
usage();
if (set_mask && !set_dirmask) {
args.dirmask = args.mask;
set_dirmask = 1;
}
else if (set_dirmask && !set_mask) {
args.mask = args.dirmask;
set_mask = 1;
}
dev = argv[optind];
dir = argv[optind + 1];
@ -169,7 +182,8 @@ main(argc, argv)
if (!set_gid)
args.gid = sb.st_gid;
if (!set_mask)
args.mask = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
args.mask = args.dirmask =
sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
}
if (mount("msdosfs", mntpath, mntflags, &args) < 0)

View File

@ -108,6 +108,7 @@ update_mp(mp, argp)
pmp->pm_gid = argp->gid;
pmp->pm_uid = argp->uid;
pmp->pm_mask = argp->mask & ALLPERMS;
pmp->pm_dirmask = argp->dirmask & ALLPERMS;
pmp->pm_flags |= argp->flags & MSDOSFSMNT_MNTOPT;
if (pmp->pm_flags & MSDOSFSMNT_U2WTABLE) {
bcopy(argp->u2w, pmp->pm_u2w, sizeof(pmp->pm_u2w));

View File

@ -243,7 +243,7 @@ msdosfs_access(ap)
file_mode = (S_IXUSR|S_IXGRP|S_IXOTH) | (S_IRUSR|S_IRGRP|S_IROTH) |
((dep->de_Attributes & ATTR_READONLY) ? 0 : (S_IWUSR|S_IWGRP|S_IWOTH));
file_mode &= pmp->pm_mask;
file_mode &= (vp->v_type == VDIR ? pmp->pm_dirmask : pmp->pm_mask);
/*
* Disallow write attempts on read-only filesystems;
@ -307,7 +307,8 @@ msdosfs_getattr(ap)
mode = S_IRWXU|S_IRWXG|S_IRWXO;
else
mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
vap->va_mode = mode & pmp->pm_mask;
vap->va_mode = mode &
(ap->a_vp->v_type == VDIR ? pmp->pm_dirmask : pmp->pm_mask);
vap->va_uid = pmp->pm_uid;
vap->va_gid = pmp->pm_gid;
vap->va_nlink = 1;

View File

@ -65,7 +65,10 @@ struct msdosfsmount {
dev_t pm_dev; /* block special device mounted */
uid_t pm_uid; /* uid to set as owner of the files */
gid_t pm_gid; /* gid to set as owner of the files */
mode_t pm_mask; /* mask to and with file protection bits */
mode_t pm_mask; /* mask to and with file protection bits
for files */
mode_t pm_dirmask; /* mask to and with file protection bits
for directories */
struct vnode *pm_devvp; /* vnode for block device mntd */
struct bpb50 pm_bpb; /* BIOS parameter blk for this fs */
u_long pm_BlkPerSec; /* How many DEV_BSIZE blocks fit inside a physical sector */
@ -210,7 +213,8 @@ struct msdosfs_args {
struct export_args export; /* network export information */
uid_t uid; /* uid that owns msdosfs files */
gid_t gid; /* gid that owns msdosfs files */
mode_t mask; /* mask to be applied for msdosfs perms */
mode_t mask; /* file mask to be applied for msdosfs perms */
mode_t dirmask; /* dir mask to be applied for msdosfs perms */
int flags; /* see below */
int magic; /* version number */
u_int16_t u2w[128]; /* Local->Unicode table */