Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Allow separate masks for files and directories. Useful e.g. ...
details: https://anonhg.NetBSD.org/src/rev/d7b06de0368e
branches: trunk
changeset: 550227:d7b06de0368e
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Sat Aug 02 11:41:19 2003 +0000
description:
Allow separate masks for files and directories. Useful e.g. to turn
the execute bit off for files, but keep search permission for directories.
Change contributed in PR kern/21538 by Pavel Arnost, based on some FreeBSD
patches.
Further manpage changes, and backward-compatibility adjustments done by me.
Also fixes PR kern/16778 by Johan Danielsson, and PR kern/3400 by Rick Byers
diffstat:
sbin/mount_msdos/mount_msdos.8 | 23 +++++++++++++++++++++--
sbin/mount_msdos/mount_msdos.c | 38 +++++++++++++++++++++++++++-----------
sys/fs/msdosfs/msdosfs_vfsops.c | 21 ++++++++++++++++++---
sys/fs/msdosfs/msdosfs_vnops.c | 10 ++++++----
sys/fs/msdosfs/msdosfsmount.h | 18 ++++++++++++++----
5 files changed, 86 insertions(+), 24 deletions(-)
diffs (truncated from 316 to 300 lines):
diff -r e8c7c950e0b3 -r d7b06de0368e sbin/mount_msdos/mount_msdos.8
--- a/sbin/mount_msdos/mount_msdos.8 Sat Aug 02 10:11:47 2003 +0000
+++ b/sbin/mount_msdos/mount_msdos.8 Sat Aug 02 11:41:19 2003 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: mount_msdos.8,v 1.25 2003/02/25 10:35:02 wiz Exp $
+.\" $NetBSD: mount_msdos.8,v 1.26 2003/08/02 11:41:19 jdolecek Exp $
.\"
.\" Copyright (c) 1993, 1994 Christopher G. Demetriou
.\" All rights reserved.
@@ -44,6 +44,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
@@ -98,9 +99,20 @@
for more information about octal file modes.)
Only the nine low-order bits of
.Ar mask
-are used.
+are used. The value of
+.Fl M
+is used if it is supplied and
+.Fl m
+is omitted.
The default 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
+.Fl m
+is used if it is supplied and
+.Fl M
+is omitted. See description of previous option for details.
.It Fl s
Force behaviour to
ignore and not generate Win'95 long filenames.
@@ -136,6 +148,13 @@
This option enforces
.Fl s .
.El
+.Sh EXAMPLES
+To remove the 'execute' permission bit for all files, but still keep
+directories searchable, use:
+.Bl -item -offset indent
+.It
+mount_msdos -m 0644 -M 0755 /dev/wd0e /msdos
+.El
.Sh SEE ALSO
.Xr mount 2 ,
.Xr unmount 2 ,
diff -r e8c7c950e0b3 -r d7b06de0368e sbin/mount_msdos/mount_msdos.c
--- a/sbin/mount_msdos/mount_msdos.c Sat Aug 02 10:11:47 2003 +0000
+++ b/sbin/mount_msdos/mount_msdos.c Sat Aug 02 11:41:19 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mount_msdos.c,v 1.28 2003/05/03 15:37:08 christos Exp $ */
+/* $NetBSD: mount_msdos.c,v 1.29 2003/08/02 11:41:20 jdolecek Exp $ */
/*
* Copyright (c) 1994 Christopher G. Demetriou
@@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: mount_msdos.c,v 1.28 2003/05/03 15:37:08 christos Exp $");
+__RCSID("$NetBSD: mount_msdos.c,v 1.29 2003/08/02 11:41:20 jdolecek Exp $");
#endif /* not lint */
#include <sys/cdefs.h>
@@ -67,7 +67,7 @@
int main __P((int, char *[]));
int mount_msdos __P((int argc, char **argv));
-static void usage __P((void));
+static void usage __P((void)) __attribute__((__noreturn__));
#ifndef MOUNT_NOMAIN
int
@@ -86,13 +86,13 @@
{
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, ndir[MAXPATHLEN+1];
- mntflags = set_gid = set_uid = set_mask = 0;
+ mntflags = set_gid = set_uid = set_mask = set_dirmask = 0;
(void)memset(&args, '\0', sizeof(args));
- while ((c = getopt(argc, argv, "Gsl9u:g:m:o:")) != -1) {
+ while ((c = getopt(argc, argv, "Gsl9u:g:m:M:o:")) != -1) {
switch (c) {
case 'G':
args.flags |= MSDOSFSMNT_GEMDOSFS;
@@ -118,6 +118,10 @@
args.mask = a_mask(optarg);
set_mask = 1;
break;
+ case 'M':
+ args.dirmask = a_mask(optarg);
+ set_dirmask = 1;
+ break;
case 'o':
getmntopts(optarg, mopts, &mntflags, 0);
break;
@@ -131,6 +135,14 @@
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];
if (dir[0] != '/') {
@@ -157,9 +169,13 @@
args.uid = sb.st_uid;
if (!set_gid)
args.gid = sb.st_gid;
- if (!set_mask)
- args.mask = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
+ if (!set_mask) {
+ args.mask = args.dirmask =
+ sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
+ }
}
+ args.flags |= MSDOSFSMNT_VERSIONED;
+ args.version = MSDOSFSMNT_VERSION;
if (mount(MOUNT_MSDOS, dir, mntflags, &args) < 0)
err(1, "%s on %s", dev, dir);
@@ -167,8 +183,8 @@
if (mntflags & MNT_GETARGS) {
char buf[1024];
(void)snprintb(buf, sizeof(buf), MSDOSFSMNT_BITS, args.flags);
- printf("uid=%d, gid=%d, mask=0%o, flags=%s\n", args.uid,
- args.gid, args.mask, buf);
+ printf("uid=%d, gid=%d, mask=0%o, dirmask=0%o, flags=%s\n",
+ args.uid, args.gid, args.mask, args.dirmask, buf);
}
exit (0);
@@ -178,6 +194,6 @@
usage()
{
- fprintf(stderr, "usage: mount_msdos [-o options] [-u user] [-g group] [-m mask] bdev dir\n");
+ fprintf(stderr, "Usage:\nmount_msdos [-o options] [-u user] [-g group] [-m mask] [-M mask] [-G] bdev dir\n");
exit(1);
}
diff -r e8c7c950e0b3 -r d7b06de0368e sys/fs/msdosfs/msdosfs_vfsops.c
--- a/sys/fs/msdosfs/msdosfs_vfsops.c Sat Aug 02 10:11:47 2003 +0000
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c Sat Aug 02 11:41:19 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msdosfs_vfsops.c,v 1.7 2003/06/29 22:31:10 fvdl Exp $ */
+/* $NetBSD: msdosfs_vfsops.c,v 1.8 2003/08/02 11:41:21 jdolecek Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.7 2003/06/29 22:31:10 fvdl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.8 2003/08/02 11:41:21 jdolecek Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@@ -146,6 +146,7 @@
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;
/*
@@ -199,10 +200,12 @@
return (error);
}
- args.flags = 0;
+ args.flags = MSDOSFSMNT_VERSIONED;
args.uid = 0;
args.gid = 0;
args.mask = 0777;
+ args.version = MSDOSFSMNT_VERSION;
+ args.dirmask = 0777;
if ((error = msdosfs_mountfs(rootvp, mp, p, &args)) != 0) {
mp->mnt_op->vfs_refcount--;
@@ -257,12 +260,24 @@
args.gid = pmp->pm_gid;
args.mask = pmp->pm_mask;
args.flags = pmp->pm_flags;
+ args.version = MSDOSFSMNT_VERSION;
+ args.dirmask = pmp->pm_dirmask;
vfs_showexport(mp, &args.export, &pmp->pm_export);
return copyout(&args, data, sizeof(args));
}
error = copyin(data, &args, sizeof(struct msdosfs_args));
if (error)
return (error);
+
+ /*
+ * If not versioned (i.e. using old mount_msdos(8)), fill in
+ * the additional structure items with suitable defaults.
+ */
+ if ((args.flags & MSDOSFSMNT_VERSIONED) == 0) {
+ args.version = 1;
+ args.dirmask = args.mask;
+ }
+
/*
* If updating, check whether changing from read-only to
* read/write; if there is no device name, that's all we do.
diff -r e8c7c950e0b3 -r d7b06de0368e sys/fs/msdosfs/msdosfs_vnops.c
--- a/sys/fs/msdosfs/msdosfs_vnops.c Sat Aug 02 10:11:47 2003 +0000
+++ b/sys/fs/msdosfs/msdosfs_vnops.c Sat Aug 02 11:41:19 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msdosfs_vnops.c,v 1.5 2003/06/29 22:31:10 fvdl Exp $ */
+/* $NetBSD: msdosfs_vnops.c,v 1.6 2003/08/02 11:41:21 jdolecek Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.5 2003/06/29 22:31:10 fvdl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.6 2003/08/02 11:41:21 jdolecek Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -263,7 +263,8 @@
mode = S_IRWXU|S_IRWXG|S_IRWXO;
else
mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
- return (vaccess(ap->a_vp->v_type, mode & pmp->pm_mask,
+ return (vaccess(ap->a_vp->v_type,
+ mode & (vp->v_type == VDIR ? pmp->pm_dirmask : pmp->pm_mask),
pmp->pm_uid, pmp->pm_gid, ap->a_mode, ap->a_cred));
}
@@ -308,7 +309,8 @@
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;
diff -r e8c7c950e0b3 -r d7b06de0368e sys/fs/msdosfs/msdosfsmount.h
--- a/sys/fs/msdosfs/msdosfsmount.h Sat Aug 02 10:11:47 2003 +0000
+++ b/sys/fs/msdosfs/msdosfsmount.h Sat Aug 02 11:41:19 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msdosfsmount.h,v 1.2 2003/02/01 06:23:41 thorpej Exp $ */
+/* $NetBSD: msdosfsmount.h,v 1.3 2003/08/02 11:41:21 jdolecek Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -57,6 +57,11 @@
gid_t gid; /* gid that owns msdosfs files */
mode_t mask; /* mask to be applied for msdosfs perms */
int flags; /* see below */
+
+ /* Following items added after versioning support */
+ int version; /* version of the struct */
+#define MSDOSFSMNT_VERSION 2
+ mode_t dirmask; /* v2: mask to be applied for msdosfs perms */
};
/*
@@ -66,17 +71,19 @@
#define MSDOSFSMNT_LONGNAME 2 /* Force Win'95 long names */
#define MSDOSFSMNT_NOWIN95 4 /* Completely ignore Win95 entries */
#define MSDOSFSMNT_GEMDOSFS 8 /* This is a gemdos-flavour */
+#define MSDOSFSMNT_VERSIONED 16 /* Struct is versioned */
/* All flags above: */
#define MSDOSFSMNT_MNTOPT \
(MSDOSFSMNT_SHORTNAME|MSDOSFSMNT_LONGNAME|MSDOSFSMNT_NOWIN95 \
- |MSDOSFSMNT_GEMDOSFS)
+ |MSDOSFSMNT_GEMDOSFS|MSDOSFSMNT_VERSIONED)
+
#define MSDOSFSMNT_RONLY 0x80000000 /* mounted read-only */
#define MSDOSFSMNT_WAITONFAT 0x40000000 /* mounted synchronous */
#define MSDOSFS_FATMIRROR 0x20000000 /* FAT is mirrored */
#define MSDOSFSMNT_BITS "\177\20" \
- "b\00shortname\0b\01longname\0b\02nowin95\0bgemdosfs\0" \
Home |
Main Index |
Thread Index |
Old Index