mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-17 15:27:36 +00:00
Teach mount(8) about a 'late' keyword, which means the file system should
not be mounted unless the -l flag was specified. Add an rc script, mountlate, which basically runs 'mount -a -l'. It runs after DAEMON but before LOGIN. This is useful for things like loopback mounts, because mountcritremote runs before mountd / nfsd (since /usr might be a remote file system), so an attempt to mount a loopback network file system in mountcritremote will fail. Also add a progress message to mountcritlocal, for the sake of symmetry with similar messages in mountcritremote and mountlate. Reviewed by: freebsd-rc MFC after: 3 weeks
This commit is contained in:
parent
7f5932be3e
commit
4b4f91707c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=160303
@ -27,6 +27,7 @@ mountcritlocal_start()
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
# Mount everything except nfs filesystems.
|
# Mount everything except nfs filesystems.
|
||||||
|
echo -n 'Mounting local file systems:'
|
||||||
mount_excludes='no'
|
mount_excludes='no'
|
||||||
for i in ${netfs_types}; do
|
for i in ${netfs_types}; do
|
||||||
fstype=${i%:*}
|
fstype=${i%:*}
|
||||||
@ -34,6 +35,7 @@ mountcritlocal_start()
|
|||||||
done
|
done
|
||||||
mount_excludes=${mount_excludes%,}
|
mount_excludes=${mount_excludes%,}
|
||||||
mount -a -t ${mount_excludes}
|
mount -a -t ${mount_excludes}
|
||||||
|
echo '.'
|
||||||
|
|
||||||
case $? in
|
case $? in
|
||||||
0)
|
0)
|
||||||
|
36
etc/rc.d/mountlate
Normal file
36
etc/rc.d/mountlate
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# $FreeBSD$
|
||||||
|
#
|
||||||
|
|
||||||
|
# PROVIDE: mountlate
|
||||||
|
# REQUIRE: DAEMON
|
||||||
|
# BEFORE: LOGIN
|
||||||
|
# KEYWORD: nojail
|
||||||
|
|
||||||
|
. /etc/rc.subr
|
||||||
|
|
||||||
|
name="mountlate"
|
||||||
|
start_cmd="mountlate_start"
|
||||||
|
stop_cmd=":"
|
||||||
|
|
||||||
|
mountlate_start()
|
||||||
|
{
|
||||||
|
# Mount "late" filesystems.
|
||||||
|
echo -n 'Mounting late file systems:'
|
||||||
|
mount -a -l
|
||||||
|
echo '.'
|
||||||
|
|
||||||
|
case $? in
|
||||||
|
0)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo 'Mounting /etc/fstab filesystems failed,' \
|
||||||
|
' startup aborted'
|
||||||
|
kill -QUIT $$
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
load_rc_config $name
|
||||||
|
run_rc_command "$1"
|
@ -28,7 +28,7 @@
|
|||||||
.\" @(#)mount.8 8.8 (Berkeley) 6/16/94
|
.\" @(#)mount.8 8.8 (Berkeley) 6/16/94
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd November 26, 2004
|
.Dd July 12, 2006
|
||||||
.Dt MOUNT 8
|
.Dt MOUNT 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -36,7 +36,7 @@
|
|||||||
.Nd mount file systems
|
.Nd mount file systems
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl adfpruvw
|
.Op Fl adflpruvw
|
||||||
.Op Fl F Ar fstab
|
.Op Fl F Ar fstab
|
||||||
.Op Fl o Ar options
|
.Op Fl o Ar options
|
||||||
.Op Fl t Ar ufs | external_type
|
.Op Fl t Ar ufs | external_type
|
||||||
@ -78,7 +78,12 @@ All the file systems described in
|
|||||||
are mounted.
|
are mounted.
|
||||||
Exceptions are those marked as
|
Exceptions are those marked as
|
||||||
.Dq noauto ,
|
.Dq noauto ,
|
||||||
excluded by the
|
those marked as
|
||||||
|
.Dq late
|
||||||
|
(unless the
|
||||||
|
.Fl l
|
||||||
|
option was specified),
|
||||||
|
those excluded by the
|
||||||
.Fl t
|
.Fl t
|
||||||
flag (see below), or if they are already mounted (except the
|
flag (see below), or if they are already mounted (except the
|
||||||
root file system which is always remounted to preserve
|
root file system which is always remounted to preserve
|
||||||
@ -101,6 +106,11 @@ a file system mount status from read-write to read-only.
|
|||||||
Also
|
Also
|
||||||
forces the R/W mount of an unclean file system (dangerous; use with
|
forces the R/W mount of an unclean file system (dangerous; use with
|
||||||
caution).
|
caution).
|
||||||
|
.It Fl l
|
||||||
|
When used in conjunction with the
|
||||||
|
.Fl a
|
||||||
|
option, also mount those file systems which are marked as
|
||||||
|
.Dq late .
|
||||||
.It Fl o
|
.It Fl o
|
||||||
Options are specified with a
|
Options are specified with a
|
||||||
.Fl o
|
.Fl o
|
||||||
@ -142,6 +152,13 @@ When used with the
|
|||||||
flag, this is the same as specifying all the options listed in the
|
flag, this is the same as specifying all the options listed in the
|
||||||
.Xr fstab 5
|
.Xr fstab 5
|
||||||
file for the file system.
|
file for the file system.
|
||||||
|
.It Cm late
|
||||||
|
This file system should be skipped when
|
||||||
|
.Nm is run with the
|
||||||
|
.Fl a
|
||||||
|
flag but without the
|
||||||
|
.Fl l
|
||||||
|
flag.
|
||||||
.It Cm multilabel
|
.It Cm multilabel
|
||||||
Enable multi-label Mandatory Access Control, or MAC, on the specified file
|
Enable multi-label Mandatory Access Control, or MAC, on the specified file
|
||||||
system.
|
system.
|
||||||
|
@ -191,17 +191,17 @@ main(int argc, char *argv[])
|
|||||||
struct statfs *mntbuf;
|
struct statfs *mntbuf;
|
||||||
FILE *mountdfp;
|
FILE *mountdfp;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int all, ch, i, init_flags, mntsize, rval, have_fstab;
|
int all, ch, i, init_flags, late, mntsize, rval, have_fstab;
|
||||||
char *cp, *ep, *options;
|
char *cp, *ep, *options;
|
||||||
|
|
||||||
options = strdup("noro");
|
options = strdup("noro");
|
||||||
if (options == NULL)
|
if (options == NULL)
|
||||||
errx(1, "malloc failed");
|
errx(1, "malloc failed");
|
||||||
|
|
||||||
all = init_flags = 0;
|
all = init_flags = late = 0;
|
||||||
vfslist = NULL;
|
vfslist = NULL;
|
||||||
vfstype = "ufs";
|
vfstype = "ufs";
|
||||||
while ((ch = getopt(argc, argv, "adF:fo:prwt:uv")) != -1)
|
while ((ch = getopt(argc, argv, "adlF:fo:prwt:uv")) != -1)
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'a':
|
case 'a':
|
||||||
all = 1;
|
all = 1;
|
||||||
@ -215,6 +215,9 @@ main(int argc, char *argv[])
|
|||||||
case 'f':
|
case 'f':
|
||||||
init_flags |= MNT_FORCE;
|
init_flags |= MNT_FORCE;
|
||||||
break;
|
break;
|
||||||
|
case 'l':
|
||||||
|
late = 1;
|
||||||
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
options = catopt(options, optarg);
|
options = catopt(options, optarg);
|
||||||
break;
|
break;
|
||||||
@ -265,6 +268,8 @@ main(int argc, char *argv[])
|
|||||||
continue;
|
continue;
|
||||||
if (hasopt(fs->fs_mntops, "noauto"))
|
if (hasopt(fs->fs_mntops, "noauto"))
|
||||||
continue;
|
continue;
|
||||||
|
if (hasopt(fs->fs_mntops, "late") && !late)
|
||||||
|
continue;
|
||||||
if (!(init_flags & MNT_UPDATE) &&
|
if (!(init_flags & MNT_UPDATE) &&
|
||||||
ismounted(fs, mntbuf, mntsize))
|
ismounted(fs, mntbuf, mntsize))
|
||||||
continue;
|
continue;
|
||||||
@ -628,6 +633,15 @@ mangle(char *options, int *argcp, char *argv[])
|
|||||||
* not a real mount option.
|
* not a real mount option.
|
||||||
*/
|
*/
|
||||||
continue;
|
continue;
|
||||||
|
} else if (strcmp(p, "late") == 0) {
|
||||||
|
/*
|
||||||
|
* "late" is used to prevent certain file
|
||||||
|
* systems from being mounted before late
|
||||||
|
* in the boot cycle; for instance,
|
||||||
|
* loopback NFS mounts can't be mounted
|
||||||
|
* before mountd starts.
|
||||||
|
*/
|
||||||
|
continue;
|
||||||
} else if (strcmp(p, "userquota") == 0) {
|
} else if (strcmp(p, "userquota") == 0) {
|
||||||
continue;
|
continue;
|
||||||
} else if (strncmp(p, userquotaeq,
|
} else if (strncmp(p, userquotaeq,
|
||||||
@ -737,7 +751,7 @@ usage(void)
|
|||||||
{
|
{
|
||||||
|
|
||||||
(void)fprintf(stderr, "%s\n%s\n%s\n",
|
(void)fprintf(stderr, "%s\n%s\n%s\n",
|
||||||
"usage: mount [-adfpruvw] [-F fstab] [-o options] [-t ufs | external_type]",
|
"usage: mount [-adflpruvw] [-F fstab] [-o options] [-t ufs | external_type]",
|
||||||
" mount [-dfpruvw] special | node",
|
" mount [-dfpruvw] special | node",
|
||||||
" mount [-dfpruvw] [-o options] [-t ufs | external_type] special node");
|
" mount [-dfpruvw] [-o options] [-t ufs | external_type] special node");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user