Finish up umntall support. init now passed an argument to the
rundown script 'reboot' or 'single'. ISO support (which never worked) has been removed from mount_nfs. mount_nfs and umount now use mounttab, which allows umntall to work properly. The rc scripts now call umntall as appropriate. Submitted by: Martin Blapp <mb@imp.ch>
This commit is contained in:
parent
05e68e47a3
commit
a69497d73f
27
etc/rc
27
etc/rc
@ -113,10 +113,17 @@ esac
|
||||
|
||||
umount -a >/dev/null 2>&1
|
||||
|
||||
# Where/how would this get set?
|
||||
# Early NFS mounts and clean up of /var/db/mounttab.
|
||||
#
|
||||
case ${early_nfs_mounts} in
|
||||
[Yy][Ee][Ss])
|
||||
case $1 in
|
||||
autoboot)
|
||||
if [ -f /var/db/mounttab ]; then
|
||||
rpc.umntall -k
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
mount -a
|
||||
;;
|
||||
*)
|
||||
@ -199,10 +206,24 @@ if [ -r /etc/rc.network ]; then
|
||||
network_pass1
|
||||
fi
|
||||
|
||||
# Retest for early_nfs here?
|
||||
# Only mount NFS file systems if $early_nfs_mounts is false.
|
||||
# If there is a /var/db/mounttab, clean it up with rpc.umntall.
|
||||
#
|
||||
echo -n "Mounting NFS file systems"
|
||||
mount -a -t nfs
|
||||
case ${early_nfs_mounts} in
|
||||
[Yy][Ee][Ss])
|
||||
;;
|
||||
*)
|
||||
case $1 in
|
||||
autoboot)
|
||||
if [ -f /var/db/mounttab ]; then
|
||||
rpc.umntall -k
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
mount -a -t nfs
|
||||
;;
|
||||
esac
|
||||
echo .
|
||||
|
||||
# Whack the pty perms back into shape.
|
||||
|
@ -17,6 +17,15 @@ HOME=/
|
||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
|
||||
export HOME PATH
|
||||
|
||||
# Check if /var/db/mounttab is clean.
|
||||
case $1 in
|
||||
reboot)
|
||||
if [ -f /var/db/mounttab ]; then
|
||||
rpc.umntall
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
echo -n "Shutting down daemon processes: "
|
||||
|
||||
# Insert shutdown procedures here
|
||||
|
@ -646,7 +646,8 @@ single_user()
|
||||
*/
|
||||
typ = getttynam("console");
|
||||
pp = getpwnam("root");
|
||||
if (typ && (typ->ty_status & TTY_SECURE) == 0 && pp && *pp->pw_passwd) {
|
||||
if (typ && (typ->ty_status & TTY_SECURE) == 0 &&
|
||||
pp && *pp->pw_passwd) {
|
||||
write(2, banner, sizeof banner - 1);
|
||||
for (;;) {
|
||||
clear = getpass("Password:");
|
||||
@ -1488,7 +1489,7 @@ runshutdown()
|
||||
int status;
|
||||
int shutdowntimeout;
|
||||
size_t len;
|
||||
char *argv[3];
|
||||
char *argv[4];
|
||||
struct sigaction sa;
|
||||
struct stat sb;
|
||||
|
||||
@ -1527,7 +1528,11 @@ runshutdown()
|
||||
*/
|
||||
argv[0] = "sh";
|
||||
argv[1] = _PATH_RUNDOWN;
|
||||
argv[2] = 0;
|
||||
if (Reboot)
|
||||
argv[2] = "reboot";
|
||||
else
|
||||
argv[2] = "single";
|
||||
argv[3] = 0;
|
||||
|
||||
sigprocmask(SIG_SETMASK, &sa.sa_mask, (sigset_t *) 0);
|
||||
|
||||
|
@ -1,12 +1,15 @@
|
||||
# @(#)Makefile 8.2 (Berkeley) 3/27/94
|
||||
#
|
||||
# $FreeBSD$
|
||||
|
||||
PROG= mount_nfs
|
||||
SRCS= mount_nfs.c getmntopts.c
|
||||
SRCS= mount_nfs.c getmntopts.c mounttab.c
|
||||
MAN8= mount_nfs.8
|
||||
|
||||
MOUNT= ${.CURDIR}/../mount
|
||||
CFLAGS+= -DNFS -I${MOUNT}
|
||||
.PATH: ${MOUNT}
|
||||
UMNTALL= ${.CURDIR}/../../usr.sbin/rpc.umntall
|
||||
CFLAGS+= -DNFS -I${MOUNT} -I${UMNTALL}
|
||||
.PATH: ${MOUNT} ${UMNTALL}
|
||||
|
||||
.if exists(${DESTDIR}/usr/lib/libkrb.a) && (defined(MAKE_KERBEROS) \
|
||||
|| defined(MAKE_EBONES))
|
||||
|
@ -57,10 +57,6 @@ static const char rcsid[] =
|
||||
#include <rpc/pmap_clnt.h>
|
||||
#include <rpc/pmap_prot.h>
|
||||
|
||||
#ifdef ISO
|
||||
#include <netiso/iso.h>
|
||||
#endif
|
||||
|
||||
#ifdef NFSKERB
|
||||
#include <kerberosIV/des.h>
|
||||
#include <kerberosIV/krb.h>
|
||||
@ -84,6 +80,7 @@ static const char rcsid[] =
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mntopts.h"
|
||||
#include "mounttab.h"
|
||||
|
||||
#define ALTF_BG 0x1
|
||||
#define ALTF_NOCONN 0x2
|
||||
@ -121,9 +118,6 @@ struct mntopt mopts[] = {
|
||||
{ "rdirplus", 0, ALTF_RDIRPLUS, 1 },
|
||||
{ "mntudp", 0, ALTF_MNTUDP, 1 },
|
||||
{ "resvport", 0, ALTF_RESVPORT, 1 },
|
||||
#ifdef ISO
|
||||
{ "seqpacket", 0, ALTF_SEQPACKET, 1 },
|
||||
#endif
|
||||
{ "nqnfs", 0, ALTF_NQNFS, 1 },
|
||||
{ "soft", 0, ALTF_SOFT, 1 },
|
||||
{ "tcp", 0, ALTF_TCP, 1 },
|
||||
@ -199,9 +193,6 @@ NFSKERBKEYSCHED_T kerb_keysched;
|
||||
#endif
|
||||
|
||||
int getnfsargs __P((char *, struct nfs_args *));
|
||||
#ifdef ISO
|
||||
struct iso_addr *iso_addr __P((const char *));
|
||||
#endif
|
||||
void set_rpc_maxgrouplist __P((int));
|
||||
void usage __P((void)) __dead2;
|
||||
int xdr_dir __P((XDR *, char *));
|
||||
@ -369,10 +360,6 @@ main(argc, argv)
|
||||
opflags |= BGRND;
|
||||
if(altflags & ALTF_MNTUDP)
|
||||
mnttcp_ok = 0;
|
||||
#ifdef ISO
|
||||
if(altflags & ALTF_SEQPACKET)
|
||||
nfsargsp->sotype = SOCK_SEQPACKET;
|
||||
#endif
|
||||
if(altflags & ALTF_TCP) {
|
||||
nfsargsp->sotype = SOCK_STREAM;
|
||||
nfsproto = IPPROTO_TCP;
|
||||
@ -400,11 +387,6 @@ main(argc, argv)
|
||||
case 'P':
|
||||
/* obsolete for NFSMNT_RESVPORT, now default */
|
||||
break;
|
||||
#ifdef ISO
|
||||
case 'p':
|
||||
nfsargsp->sotype = SOCK_SEQPACKET;
|
||||
break;
|
||||
#endif
|
||||
case 'q':
|
||||
mountmode = V3;
|
||||
nfsargsp->flags |= NFSMNT_NQNFS;
|
||||
@ -649,11 +631,6 @@ getnfsargs(spec, nfsargsp)
|
||||
register CLIENT *clp;
|
||||
struct hostent *hp;
|
||||
static struct sockaddr_in saddr;
|
||||
#ifdef ISO
|
||||
static struct sockaddr_iso isoaddr;
|
||||
struct iso_addr *isop;
|
||||
int isoflag = 0;
|
||||
#endif
|
||||
struct timeval pertry, try;
|
||||
enum clnt_stat clnt_stat;
|
||||
int so = RPC_ANYSOCK, i, nfsvers, mntvers, orgcnt, speclen;
|
||||
@ -702,35 +679,6 @@ getnfsargs(spec, nfsargsp)
|
||||
memmove(nam + len + 1, spec, speclen);
|
||||
nam[len + speclen + 1] = '\0';
|
||||
}
|
||||
/*
|
||||
* DUMB!! Until the mount protocol works on iso transport, we must
|
||||
* supply both an iso and an inet address for the host.
|
||||
*/
|
||||
#ifdef ISO
|
||||
if (!strncmp(hostp, "iso=", 4)) {
|
||||
u_short isoport;
|
||||
|
||||
hostp += 4;
|
||||
isoflag++;
|
||||
if ((delimp = strchr(hostp, '+')) == NULL) {
|
||||
warnx("no iso+inet address");
|
||||
return (0);
|
||||
}
|
||||
*delimp = '\0';
|
||||
if ((isop = iso_addr(hostp)) == NULL) {
|
||||
warnx("bad ISO address");
|
||||
return (0);
|
||||
}
|
||||
memset(&isoaddr, 0, sizeof (isoaddr));
|
||||
memmove(&isoaddr.siso_addr, isop, sizeof (struct iso_addr));
|
||||
isoaddr.siso_len = sizeof (isoaddr);
|
||||
isoaddr.siso_family = AF_ISO;
|
||||
isoaddr.siso_tlen = 2;
|
||||
isoport = htons(NFS_PORT);
|
||||
memmove(TSEL(&isoaddr), &isoport, isoaddr.siso_tlen);
|
||||
hostp = delimp + 1;
|
||||
}
|
||||
#endif /* ISO */
|
||||
|
||||
/*
|
||||
* Handle an internet host address and reverse resolve it if
|
||||
@ -844,7 +792,8 @@ tryagain:
|
||||
}
|
||||
if (--retrycnt > 0) {
|
||||
if (opflags & BGRND) {
|
||||
warnx("Cannot immediately mount %s:%s, backgrounding", hostp, spec);
|
||||
warnx("Cannot immediately mount %s:%s, "
|
||||
"backgrounding", hostp, spec);
|
||||
opflags &= ~BGRND;
|
||||
if ((i = fork())) {
|
||||
if (i == -1)
|
||||
@ -868,12 +817,6 @@ tryagain:
|
||||
return (0);
|
||||
}
|
||||
saddr.sin_port = htons(tport);
|
||||
#ifdef ISO
|
||||
if (isoflag) {
|
||||
nfsargsp->addr = (struct sockaddr *) &isoaddr;
|
||||
nfsargsp->addrlen = sizeof (isoaddr);
|
||||
} else
|
||||
#endif /* ISO */
|
||||
{
|
||||
nfsargsp->addr = (struct sockaddr *) &saddr;
|
||||
nfsargsp->addrlen = sizeof (saddr);
|
||||
@ -881,6 +824,9 @@ tryagain:
|
||||
nfsargsp->fh = nfhret.nfh;
|
||||
nfsargsp->fhsize = nfhret.fhsize;
|
||||
nfsargsp->hostname = nam;
|
||||
/* Add mounted filesystem to PATH_MOUNTTAB */
|
||||
if (!add_mtab(hostp, spec))
|
||||
warnx("can't update %s for %s:%s", PATH_MOUNTTAB, hostp, spec);
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,14 @@
|
||||
# @(#)Makefile 8.4 (Berkeley) 6/22/95
|
||||
#
|
||||
# $FreeBSD$
|
||||
|
||||
PROG= umount
|
||||
SRCS= umount.c vfslist.c
|
||||
SRCS= umount.c vfslist.c mounttab.c
|
||||
MAN8= umount.8
|
||||
|
||||
MOUNT= ${.CURDIR}/../mount
|
||||
CFLAGS+= -I${MOUNT}
|
||||
.PATH: ${MOUNT}
|
||||
UMNTALL= ${.CURDIR}/../../usr.sbin/rpc.umntall
|
||||
CFLAGS+= -I${MOUNT} -I${UMNTALL}
|
||||
.PATH: ${MOUNT} ${UMNTALL}
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -59,12 +59,15 @@ static const char rcsid[] =
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mounttab.h"
|
||||
|
||||
#define ISDOT(x) ((x)[0] == '.' && (x)[1] == '\0')
|
||||
#define ISDOTDOT(x) ((x)[0] == '.' && (x)[1] == '.' && (x)[2] == '\0')
|
||||
|
||||
typedef enum { MNTON, MNTFROM, NOTHING } mntwhat;
|
||||
typedef enum { MARK, UNMARK, NAME, COUNT, FREE } dowhat;
|
||||
|
||||
struct mtablist *mtabhead;
|
||||
int fflag, vflag;
|
||||
char *nfshost;
|
||||
|
||||
@ -76,7 +79,6 @@ char *getrealname(char *, char *resolved_path);
|
||||
char **makevfslist (const char *);
|
||||
size_t mntinfo (struct statfs **);
|
||||
int namematch (struct hostent *);
|
||||
int selected (int);
|
||||
int umountall (char **);
|
||||
int umountfs (char *, char **);
|
||||
void usage (void);
|
||||
@ -240,6 +242,7 @@ umountfs(char *name, char **typelist)
|
||||
{
|
||||
enum clnt_stat clnt_stat;
|
||||
struct hostent *hp;
|
||||
struct mtablist *mtab;
|
||||
struct sockaddr_in saddr;
|
||||
struct timeval pertry, try;
|
||||
CLIENT *clp;
|
||||
@ -252,6 +255,7 @@ umountfs(char *name, char **typelist)
|
||||
char *type, *delimp, *hostp, *origname;
|
||||
|
||||
len = 0;
|
||||
mtab = NULL;
|
||||
mntfromname = mntonname = delimp = hostp = orignfsdirname = NULL;
|
||||
|
||||
/*
|
||||
@ -428,6 +432,17 @@ umountfs(char *name, char **typelist)
|
||||
clnt_perror(clp, "Bad MNT RPC");
|
||||
return (1);
|
||||
}
|
||||
/*
|
||||
* Remove the unmounted entry from /var/db/mounttab.
|
||||
*/
|
||||
if (read_mtab(mtab)) {
|
||||
mtab = mtabhead;
|
||||
clean_mtab(hostp, nfsdirname);
|
||||
if(!write_mtab())
|
||||
warnx("cannot remove entry %s:%s",
|
||||
hostp, nfsdirname);
|
||||
free_mtab();
|
||||
}
|
||||
free(orignfsdirname);
|
||||
auth_destroy(clp->cl_auth);
|
||||
clnt_destroy(clp);
|
||||
@ -533,6 +548,7 @@ getmntname(const char *fromname, const char *onname,
|
||||
case FREE:
|
||||
free(mntbuf);
|
||||
free(mntcheck);
|
||||
free(mntcount);
|
||||
return (NULL);
|
||||
default:
|
||||
return (NULL);
|
||||
@ -587,7 +603,7 @@ mntinfo(struct statfs **mntbuf)
|
||||
size_t bufsize;
|
||||
int mntsize;
|
||||
|
||||
mntsize = getfsstat(NULL, 0l, MNT_NOWAIT);
|
||||
mntsize = getfsstat(NULL, 0, MNT_NOWAIT);
|
||||
if (mntsize <= 0)
|
||||
return (0);
|
||||
bufsize = (mntsize + 1) * sizeof(struct statfs);
|
||||
|
Loading…
x
Reference in New Issue
Block a user