Reviewed by: various.

Ever since I first say the way the mount flags were used I've hated the
fact that modes, and events, internal and exported, and short-term
and long term flags are all thrown together. Finally it's annoyed me enough..
This patch to the entire FreeBSD tree adds a second mount flag word
to the mount struct. it is not exported to userspace. I have moved
some of the non exported flags over to this word. this means that we now
have 8 free bits in the mount flags. There are another two that might
well move over, but which I'm not sure about.
The only user visible change would have been in pstat -v, except
that davidg has disabled it anyhow.
I'd still like to move the state flags and the 'command' flags
apart from each other.. e.g. MNT_FORCE really doesn't have the
same semantics as MNT_RDONLY, but that's left  for another day.
This commit is contained in:
julian 1997-11-12 05:42:33 +00:00
parent ce431fd607
commit ac07cf2063
16 changed files with 59 additions and 50 deletions

View File

@ -79,6 +79,8 @@ suppress default semantics which affect filesystem access.
.It Dv MNT_RDONLY
The filesystem should be treated as read-only;
Even the super-user may not write on it.
Specifying MNT_UPDATE withut this option will upgrade
a read-only filesystem to read/write.
.It Dv MNT_NOEXEC
Do not allow files to be executed from the filesystem.
.It Dv MNT_NOSUID
@ -91,9 +93,6 @@ Do not interpret special files on the filesystem.
All I/O to the filesystem should be done synchronously.
.It Dv MNT_ASYNC
All I/O to the filesystem should be done asynchronously.
.It Dv MNT_WANTRDWR
Upgrade a mounted read-only filesystem to read-write if MNT_UPDATE
is also specified.
.It Dv MNT_FORCE
Fore a read-write mount even if the filesystem appears to be unclean.
Dangerous.

View File

@ -1,4 +1,4 @@
/* $Id: msdosfs_vfsops.c,v 1.21 1997/10/11 18:31:30 phk Exp $ */
/* $Id: msdosfs_vfsops.c,v 1.22 1997/10/12 20:25:01 phk Exp $ */
/* $NetBSD: msdosfs_vfsops.c,v 1.19 1994/08/21 18:44:10 ws Exp $ */
/*-
@ -138,7 +138,7 @@ msdosfs_mount(mp, path, data, ndp, p)
error = EINVAL;
if (error)
return error;
if (pmp->pm_ronly && (mp->mnt_flag & MNT_WANTRDWR))
if (pmp->pm_ronly && (mp->mnt_kern_flag & MNTK_WANTRDWR))
pmp->pm_ronly = 0;
if (args.fspec == 0) {
/*

View File

@ -237,7 +237,7 @@ ext2_mount(mp, path, data, ndp, p)
error = ext2_reload(mp, ndp->ni_cnd.cn_cred, p);
if (error)
return (error);
if (fs->s_rd_only && (mp->mnt_flag & MNT_WANTRDWR))
if (fs->s_rd_only && (mp->mnt_kern_flag & MNTK_WANTRDWR))
fs->s_rd_only = 0;
if (fs->s_rd_only == 0) {
/* don't say it's clean */

View File

@ -237,7 +237,7 @@ ext2_mount(mp, path, data, ndp, p)
error = ext2_reload(mp, ndp->ni_cnd.cn_cred, p);
if (error)
return (error);
if (fs->s_rd_only && (mp->mnt_flag & MNT_WANTRDWR))
if (fs->s_rd_only && (mp->mnt_kern_flag & MNTK_WANTRDWR))
fs->s_rd_only = 0;
if (fs->s_rd_only == 0) {
/* don't say it's clean */

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95
* $Id: vfs_subr.c,v 1.111 1997/10/26 20:55:07 phk Exp $
* $Id: vfs_subr.c,v 1.112 1997/11/07 08:53:11 phk Exp $
*/
/*
@ -147,10 +147,10 @@ vfs_busy(mp, flags, interlkp, p)
{
int lkflags;
if (mp->mnt_flag & MNT_UNMOUNT) {
if (mp->mnt_kern_flag & MNTK_UNMOUNT) {
if (flags & LK_NOWAIT)
return (ENOENT);
mp->mnt_flag |= MNT_MWAIT;
mp->mnt_kern_flag |= MNTK_MWAIT;
if (interlkp) {
simple_unlock(interlkp);
}

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
* $Id: vfs_syscalls.c,v 1.79 1997/10/28 10:29:55 bde Exp $
* $Id: vfs_syscalls.c,v 1.80 1997/11/06 19:29:30 phk Exp $
*/
/*
@ -110,7 +110,7 @@ mount(p, uap)
struct vnode *vp;
struct mount *mp;
struct vfsconf *vfsp;
int error, flag = 0;
int error, flag = 0, flag2 = 0;
struct vattr va;
u_long fstypenum;
struct nameidata nd;
@ -134,6 +134,7 @@ mount(p, uap)
}
mp = vp->v_mount;
flag = mp->mnt_flag;
flag2 = mp->mnt_kern_flag;
/*
* We only allow the filesystem to be reloaded if it
* is currently mounted read-only.
@ -257,7 +258,7 @@ mount(p, uap)
if (SCARG(uap, flags) & MNT_RDONLY)
mp->mnt_flag |= MNT_RDONLY;
else if (mp->mnt_flag & MNT_RDONLY)
mp->mnt_flag |= MNT_WANTRDWR;
mp->mnt_kern_flag |= MNTK_WANTRDWR;
mp->mnt_flag &=~ (MNT_NOSUID | MNT_NOEXEC | MNT_NODEV |
MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_NOATIME |
MNT_NOCLUSTERR | MNT_NOCLUSTERW);
@ -270,12 +271,13 @@ mount(p, uap)
error = VFS_MOUNT(mp, SCARG(uap, path), SCARG(uap, data), &nd, p);
if (mp->mnt_flag & MNT_UPDATE) {
vrele(vp);
if (mp->mnt_flag & MNT_WANTRDWR)
if (mp->mnt_kern_flag & MNTK_WANTRDWR)
mp->mnt_flag &= ~MNT_RDONLY;
mp->mnt_flag &=~
(MNT_UPDATE | MNT_RELOAD | MNT_FORCE | MNT_WANTRDWR);
mp->mnt_flag &=~ (MNT_UPDATE | MNT_RELOAD | MNT_FORCE);
mp->mnt_kern_flag &=~ (MNTK_WANTRDWR);
if (error)
mp->mnt_flag = flag;
mp->mnt_kern_flag = flag2;
vfs_unbusy(mp, p);
return (error);
}
@ -415,7 +417,7 @@ dounmount(mp, flags, p)
int error;
simple_lock(&mountlist_slock);
mp->mnt_flag |= MNT_UNMOUNT;
mp->mnt_kern_flag |= MNTK_UNMOUNT;
lockmgr(&mp->mnt_lock, LK_DRAIN | LK_INTERLOCK, &mountlist_slock, p);
if (mp->mnt_flag & MNT_EXPUBLIC)
@ -431,7 +433,7 @@ dounmount(mp, flags, p)
error = VFS_UNMOUNT(mp, flags, p);
simple_lock(&mountlist_slock);
if (error) {
mp->mnt_flag &= ~MNT_UNMOUNT;
mp->mnt_kern_flag &= ~MNTK_UNMOUNT;
lockmgr(&mp->mnt_lock, LK_RELEASE | LK_INTERLOCK | LK_REENABLE,
&mountlist_slock, p);
return (error);
@ -445,7 +447,7 @@ dounmount(mp, flags, p)
if (mp->mnt_vnodelist.lh_first != NULL)
panic("unmount: dangling vnode");
lockmgr(&mp->mnt_lock, LK_RELEASE | LK_INTERLOCK, &mountlist_slock, p);
if (mp->mnt_flag & MNT_MWAIT)
if (mp->mnt_kern_flag & MNTK_MWAIT)
wakeup((caddr_t)mp);
free((caddr_t)mp, M_MOUNT);
return (0);

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95
* $Id: vfs_subr.c,v 1.111 1997/10/26 20:55:07 phk Exp $
* $Id: vfs_subr.c,v 1.112 1997/11/07 08:53:11 phk Exp $
*/
/*
@ -147,10 +147,10 @@ vfs_busy(mp, flags, interlkp, p)
{
int lkflags;
if (mp->mnt_flag & MNT_UNMOUNT) {
if (mp->mnt_kern_flag & MNTK_UNMOUNT) {
if (flags & LK_NOWAIT)
return (ENOENT);
mp->mnt_flag |= MNT_MWAIT;
mp->mnt_kern_flag |= MNTK_MWAIT;
if (interlkp) {
simple_unlock(interlkp);
}

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
* $Id: vfs_syscalls.c,v 1.79 1997/10/28 10:29:55 bde Exp $
* $Id: vfs_syscalls.c,v 1.80 1997/11/06 19:29:30 phk Exp $
*/
/*
@ -110,7 +110,7 @@ mount(p, uap)
struct vnode *vp;
struct mount *mp;
struct vfsconf *vfsp;
int error, flag = 0;
int error, flag = 0, flag2 = 0;
struct vattr va;
u_long fstypenum;
struct nameidata nd;
@ -134,6 +134,7 @@ mount(p, uap)
}
mp = vp->v_mount;
flag = mp->mnt_flag;
flag2 = mp->mnt_kern_flag;
/*
* We only allow the filesystem to be reloaded if it
* is currently mounted read-only.
@ -257,7 +258,7 @@ mount(p, uap)
if (SCARG(uap, flags) & MNT_RDONLY)
mp->mnt_flag |= MNT_RDONLY;
else if (mp->mnt_flag & MNT_RDONLY)
mp->mnt_flag |= MNT_WANTRDWR;
mp->mnt_kern_flag |= MNTK_WANTRDWR;
mp->mnt_flag &=~ (MNT_NOSUID | MNT_NOEXEC | MNT_NODEV |
MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_NOATIME |
MNT_NOCLUSTERR | MNT_NOCLUSTERW);
@ -270,12 +271,13 @@ mount(p, uap)
error = VFS_MOUNT(mp, SCARG(uap, path), SCARG(uap, data), &nd, p);
if (mp->mnt_flag & MNT_UPDATE) {
vrele(vp);
if (mp->mnt_flag & MNT_WANTRDWR)
if (mp->mnt_kern_flag & MNTK_WANTRDWR)
mp->mnt_flag &= ~MNT_RDONLY;
mp->mnt_flag &=~
(MNT_UPDATE | MNT_RELOAD | MNT_FORCE | MNT_WANTRDWR);
mp->mnt_flag &=~ (MNT_UPDATE | MNT_RELOAD | MNT_FORCE);
mp->mnt_kern_flag &=~ (MNTK_WANTRDWR);
if (error)
mp->mnt_flag = flag;
mp->mnt_kern_flag = flag2;
vfs_unbusy(mp, p);
return (error);
}
@ -415,7 +417,7 @@ dounmount(mp, flags, p)
int error;
simple_lock(&mountlist_slock);
mp->mnt_flag |= MNT_UNMOUNT;
mp->mnt_kern_flag |= MNTK_UNMOUNT;
lockmgr(&mp->mnt_lock, LK_DRAIN | LK_INTERLOCK, &mountlist_slock, p);
if (mp->mnt_flag & MNT_EXPUBLIC)
@ -431,7 +433,7 @@ dounmount(mp, flags, p)
error = VFS_UNMOUNT(mp, flags, p);
simple_lock(&mountlist_slock);
if (error) {
mp->mnt_flag &= ~MNT_UNMOUNT;
mp->mnt_kern_flag &= ~MNTK_UNMOUNT;
lockmgr(&mp->mnt_lock, LK_RELEASE | LK_INTERLOCK | LK_REENABLE,
&mountlist_slock, p);
return (error);
@ -445,7 +447,7 @@ dounmount(mp, flags, p)
if (mp->mnt_vnodelist.lh_first != NULL)
panic("unmount: dangling vnode");
lockmgr(&mp->mnt_lock, LK_RELEASE | LK_INTERLOCK, &mountlist_slock, p);
if (mp->mnt_flag & MNT_MWAIT)
if (mp->mnt_kern_flag & MNTK_MWAIT)
wakeup((caddr_t)mp);
free((caddr_t)mp, M_MOUNT);
return (0);

View File

@ -1,4 +1,4 @@
/* $Id: msdosfs_vfsops.c,v 1.21 1997/10/11 18:31:30 phk Exp $ */
/* $Id: msdosfs_vfsops.c,v 1.22 1997/10/12 20:25:01 phk Exp $ */
/* $NetBSD: msdosfs_vfsops.c,v 1.19 1994/08/21 18:44:10 ws Exp $ */
/*-
@ -138,7 +138,7 @@ msdosfs_mount(mp, path, data, ndp, p)
error = EINVAL;
if (error)
return error;
if (pmp->pm_ronly && (mp->mnt_flag & MNT_WANTRDWR))
if (pmp->pm_ronly && (mp->mnt_kern_flag & MNTK_WANTRDWR))
pmp->pm_ronly = 0;
if (args.fspec == 0) {
/*

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vfsops.c 8.12 (Berkeley) 5/20/95
* $Id: nfs_vfsops.c,v 1.50 1997/10/28 14:06:23 bde Exp $
* $Id: nfs_vfsops.c,v 1.51 1997/10/28 15:59:12 bde Exp $
*/
#include <sys/param.h>
@ -562,6 +562,7 @@ nfs_mountdiskless(path, which, mountflag, sin, args, p, vpp, mpp)
return (error);
}
mp->mnt_kern_flag = 0;
mp->mnt_flag = mountflag;
nam = dup_sockaddr((struct sockaddr *)sin, 1);
if (error = mountnfs(args, mp, nam, which, path, vpp)) {

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vfsops.c 8.12 (Berkeley) 5/20/95
* $Id: nfs_vfsops.c,v 1.50 1997/10/28 14:06:23 bde Exp $
* $Id: nfs_vfsops.c,v 1.51 1997/10/28 15:59:12 bde Exp $
*/
#include <sys/param.h>
@ -562,6 +562,7 @@ nfs_mountdiskless(path, which, mountflag, sin, args, p, vpp, mpp)
return (error);
}
mp->mnt_kern_flag = 0;
mp->mnt_flag = mountflag;
nam = dup_sockaddr((struct sockaddr *)sin, 1);
if (error = mountnfs(args, mp, nam, which, path, vpp)) {

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)mount.h 8.21 (Berkeley) 5/20/95
* $Id: mount.h,v 1.47 1997/09/27 13:39:49 kato Exp $
* $Id: mount.h,v 1.48 1997/10/12 20:26:02 phk Exp $
*/
#ifndef _SYS_MOUNT_H_
@ -78,7 +78,7 @@ struct statfs {
fsid_t f_fsid; /* file system id */
uid_t f_owner; /* user that mounted the filesystem */
int f_type; /* type of filesystem (see below) */
int f_flags; /* copy of mount flags */
int f_flags; /* copy of mount exported flags */
long f_spare[2]; /* spare for later */
char f_fstypename[MFSNAMELEN]; /* fs type name */
char f_mntonname[MNAMELEN]; /* directory on which mounted */
@ -146,7 +146,8 @@ struct mount {
struct vnode *mnt_vnodecovered; /* vnode we mounted on */
struct vnodelst mnt_vnodelist; /* list of vnodes this mount */
struct lock mnt_lock; /* mount structure lock */
int mnt_flag; /* flags */
int mnt_flag; /* exported flags */
int mnt_kern_flag; /* kernel only flags */
int mnt_maxsymlinklen; /* max size of short symlink */
struct statfs mnt_stat; /* cache of filesystem stats */
qaddr_t mnt_data; /* private data */
@ -165,7 +166,7 @@ struct mount {
#define MNT_NODEV 0x00000010 /* don't interpret special files */
#define MNT_UNION 0x00000020 /* union with underlying filesystem */
#define MNT_ASYNC 0x00000040 /* file system written asynchronously */
#define MNT_NOATIME 0x10000000 /* Disable update of file access times */
#define MNT_NOATIME 0x10000000 /* Disable update of file access time */
#define MNT_NOCLUSTERR 0x40000000 /* Disable cluster read */
#define MNT_NOCLUSTERW 0x80000000 /* Disable cluster read */
@ -194,7 +195,8 @@ struct mount {
MNT_NODEV|MNT_UNION|MNT_ASYNC|MNT_EXRDONLY| \
MNT_EXPORTED|MNT_DEFEXPORTED|MNT_EXPORTANON| \
MNT_EXKERB|MNT_LOCAL|MNT_USER|MNT_QUOTA|MNT_ROOTFS| \
MNT_NOATIME|MNT_NOCLUSTERR|MNT_NOCLUSTERW)
MNT_NOATIME|MNT_NOCLUSTERR|MNT_NOCLUSTERW \
/* | MNT_EXPUBLIC */)
/*
* External filesystem control flags.
@ -210,9 +212,9 @@ struct mount {
* past the mount point. This keeps the subtree stable during mounts
* and unmounts.
*/
#define MNT_UNMOUNT 0x01000000 /* unmount in progress */
#define MNT_MWAIT 0x02000000 /* waiting for unmount to finish */
#define MNT_WANTRDWR 0x04000000 /* upgrade to read/write requested */
#define MNTK_UNMOUNT 0x01000000 /* unmount in progress */
#define MNTK_MWAIT 0x02000000 /* waiting for unmount to finish */
#define MNTK_WANTRDWR 0x04000000 /* upgrade to read/write requested */
/*
* Sysctl CTL_VFS definitions.

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)ffs_vfsops.c 8.31 (Berkeley) 5/20/95
* $Id: ffs_vfsops.c,v 1.60 1997/10/16 10:49:33 phk Exp $
* $Id: ffs_vfsops.c,v 1.61 1997/10/16 20:32:35 phk Exp $
*/
#include "opt_quota.h"
@ -207,7 +207,7 @@ ffs_mount( mp, path, data, ndp, p)
if (err) {
goto error_1;
}
if (fs->fs_ronly && (mp->mnt_flag & MNT_WANTRDWR)) {
if (fs->fs_ronly && (mp->mnt_kern_flag & MNTK_WANTRDWR)) {
if (!fs->fs_clean) {
if (mp->mnt_flag & MNT_FORCE) {
printf("WARNING: %s was not properly dismounted.\n",fs->fs_fsmnt);

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)lfs_vfsops.c 8.20 (Berkeley) 6/10/95
* $Id: lfs_vfsops.c,v 1.25 1997/10/16 08:16:34 julian Exp $
* $Id: lfs_vfsops.c,v 1.26 1997/10/16 20:32:37 phk Exp $
*/
#include "opt_quota.h"
@ -213,7 +213,7 @@ lfs_mount(mp, path, data, ndp, p)
*/
if (mp->mnt_flag & MNT_UPDATE) {
ump = VFSTOUFS(mp);
if (fs->lfs_ronly && (mp->mnt_flag & MNT_WANTRDWR)) {
if (fs->lfs_ronly && (mp->mnt_kern_flag & MNTK_WANTRDWR)) {
/*
* If upgrade to read-write by non-root, then verify
* that user has necessary permissions on the device.

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)mfs_vfsops.c 8.11 (Berkeley) 6/19/95
* $Id: mfs_vfsops.c,v 1.36 1997/10/12 20:26:19 phk Exp $
* $Id: mfs_vfsops.c,v 1.37 1997/11/01 20:19:43 tegge Exp $
*/
#include <sys/param.h>
@ -343,7 +343,7 @@ mfs_mount(mp, path, data, ndp, p)
if (err)
goto error_1;
}
if (fs->fs_ronly && (mp->mnt_flag & MNT_WANTRDWR))
if (fs->fs_ronly && (mp->mnt_kern_flag & MNTK_WANTRDWR))
fs->fs_ronly = 0;
#ifdef EXPORTMFS
/* if not updating name...*/

View File

@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)pstat.c 8.16 (Berkeley) 5/9/95";
#endif
static const char rcsid[] =
"$Id: pstat.c,v 1.31 1997/10/09 07:22:08 charnier Exp $";
"$Id: pstat.c,v 1.32 1997/10/19 18:41:23 davidg Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -195,9 +195,11 @@ struct {
{ MNT_DELEXPORT, "delexport" },
{ MNT_RELOAD, "reload" },
{ MNT_FORCE, "force" },
#if 0
{ MNT_UNMOUNT, "unmount" },
{ MNT_MWAIT, "mwait" },
{ MNT_WANTRDWR, "wantrdwr" },
#endif
{ 0 }
};