diff options
author | peter <peter@FreeBSD.org> | 1997-03-11 12:43:45 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1997-03-11 12:43:45 +0000 |
commit | bd986f80513b7e43c2cfa9a31d651ead5bd1524a (patch) | |
tree | f6fb1326a39233d081243bac510d9ee8753c7a82 /usr.sbin | |
parent | 1c0f77f024b01c2df41c395b7e5afd760d0a9062 (diff) | |
download | FreeBSD-src-bd986f80513b7e43c2cfa9a31d651ead5bd1524a.zip FreeBSD-src-bd986f80513b7e43c2cfa9a31d651ead5bd1524a.tar.gz |
Merge from Lite2 (use new getvfsbyname() and mount(2) interface, cleanup)
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/mountd/Makefile | 3 | ||||
-rw-r--r-- | usr.sbin/mountd/exports.5 | 10 | ||||
-rw-r--r-- | usr.sbin/mountd/mountd.8 | 22 | ||||
-rw-r--r-- | usr.sbin/mountd/mountd.c | 113 |
4 files changed, 63 insertions, 85 deletions
diff --git a/usr.sbin/mountd/Makefile b/usr.sbin/mountd/Makefile index f32e11b..c05730d 100644 --- a/usr.sbin/mountd/Makefile +++ b/usr.sbin/mountd/Makefile @@ -1,7 +1,8 @@ # From: @(#)Makefile 8.3 (Berkeley) 1/25/94 -# $Id$ +# $Id: Makefile,v 1.6 1997/02/22 14:33:01 peter Exp $ PROG= mountd +CFLAGS+= -D_NEW_VFSCONF CFLAGS+=-DNFS -DMFS -DCD9660 -DMSDOSFS MAN5= exports.5 netgroup.5 MAN8= mountd.8 diff --git a/usr.sbin/mountd/exports.5 b/usr.sbin/mountd/exports.5 index 73f0207..866cae7 100644 --- a/usr.sbin/mountd/exports.5 +++ b/usr.sbin/mountd/exports.5 @@ -29,9 +29,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)exports.5 8.2 (Berkeley) 1/28/94 +.\" @(#)exports.5 8.3 (Berkeley) 3/29/95 .\" -.Dd January 28, 1994 +.Dd March 29, 1995 .Dt EXPORTS 5 .Os .Sh NAME @@ -74,7 +74,9 @@ followed by the .Fl alldirs flag; this form allows the host(s) to mount at any point within the filesystem, -including regular files if the ``-r'' option is used on mountd. +including regular files if the +.Fl r +option is used on mountd. The pathnames must not have any symbolic links in them and should not have any "." or ".." components. Mount points for a filesystem may appear on multiple lines each with @@ -143,7 +145,7 @@ The .Fl kerb option specifies that the Kerberos authentication server should be used to authenticate and map client credentials. -This requires that the kernel be built with the NFSKERB option. +This option requires that the kernel be built with the NFSKERB option. .Pp The .Fl ro diff --git a/usr.sbin/mountd/mountd.8 b/usr.sbin/mountd/mountd.8 index 099ac55..ffed3cb 100644 --- a/usr.sbin/mountd/mountd.8 +++ b/usr.sbin/mountd/mountd.8 @@ -29,10 +29,10 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" From: @(#)mountd.8 8.1 (Berkeley) 6/9/93 -.\" $Id$ +.\" @(#)mountd.8 8.4 (Berkeley) 4/28/95 +.\" $Id: mountd.8,v 1.7 1997/02/22 14:33:02 peter Exp $ .\" -.Dd September 22, 1994 +.Dd April 28, 1995 .Dt MOUNTD 8 .Os .Sh NAME @@ -71,11 +71,15 @@ that require it. The .Fl r option allows mount RPCs requests for regular files to be served. -Although this seems to violate the mount protocol specification, some diskless -workstations do mount requests for their swapfiles and expect them to be -regular files. Since a regular file cannot be specified in /etc/exports, the -entire file system that the swapfiles reside in will have to be exported with -the ``-alldirs'' flag. +Although this seems to violate the mount protocol specification, +some diskless workstations do mount requests for +their swapfiles and expect them to be regular files. +Since a regular file cannot be specified in +.Pa /etc/exports , +the entire file system in which the swapfiles resides +will have to be exported with the +.Fl alldirs +flag. .It Ar exportsfile The .Ar exportsfile @@ -90,7 +94,7 @@ After changing the exports file, a hangup signal should be sent to the mountd daemon to get it to reload the export information. After sending the SIGHUP -(kill -HUP `cat /var/run/mountd.pid`), +(kill \-s HUP `cat /var/run/mountd.pid`), check the syslog output to see if mountd logged any parsing errors in the exports file. .Pp diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c index 9e57342..f094863 100644 --- a/usr.sbin/mountd/mountd.c +++ b/usr.sbin/mountd/mountd.c @@ -41,9 +41,9 @@ static char copyright[] = #endif /*not lint*/ #ifndef lint -/*static char sccsid[] = "From: @(#)mountd.c 8.8 (Berkeley) 2/20/94";*/ +/*static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95"; */ static const char rcsid[] = - "$Id$"; + "$Id: mountd.c,v 1.13 1997/02/22 14:33:02 peter Exp $"; #endif /*not lint*/ #include <sys/param.h> @@ -63,6 +63,9 @@ static const char rcsid[] = #endif #include <nfs/rpcv2.h> #include <nfs/nfsproto.h> +#include <ufs/ufs/ufsmount.h> +#include <msdosfs/msdosfsmount.h> +#include <isofs/cd9660/cd9660_mount.h> /* XXX need isofs in include */ #include <arpa/inet.h> @@ -250,18 +253,18 @@ main(argc, argv) SVCXPRT *udptransp, *tcptransp; int c; #ifdef __FreeBSD__ - struct vfsconf *vfc; + struct vfsconf vfc; + int error; - vfc = getvfsbyname("nfs"); - if(!vfc && vfsisloadable("nfs")) { + error = getvfsbyname("nfs", &vfc); + if (error && vfsisloadable("nfs")) { if(vfsload("nfs")) err(1, "vfsload(nfs)"); endvfsent(); /* flush cache */ - vfc = getvfsbyname("nfs"); + error = getvfsbyname("nfs", &vfc); } - if(!vfc) { + if (error) errx(1, "NFS support is not available in the running kernel"); - } #endif /* __FreeBSD__ */ while ((c = getopt(argc, argv, "dnr")) != EOF) @@ -276,7 +279,7 @@ main(argc, argv) debug = debug ? 0 : 1; break; default: - fprintf(stderr, "Usage: mountd [-r] [-n] [export_file]\n"); + fprintf(stderr, "Usage: mountd [-d] [-r] [-n] [export_file]\n"); exit(1); }; argc -= optind; @@ -341,13 +344,12 @@ mntsrv(rqstp, transp) struct exportlist *ep; struct dirlist *dp; struct fhreturn fhr; - struct authunix_parms *ucr; struct stat stb; struct statfs fsb; struct hostent *hp; u_long saddr; u_short sport; - char rpcpath[RPCMNT_PATHLEN+1], dirpath[MAXPATHLEN]; + char rpcpath[RPCMNT_PATHLEN + 1], dirpath[MAXPATHLEN]; int bad = ENOENT, defset, hostset; sigset_t sighup_mask; @@ -404,7 +406,7 @@ mntsrv(rqstp, transp) fhr.fhr_flag = defset; fhr.fhr_vers = rqstp->rq_vers; /* Get the file handle */ - bzero((caddr_t)&fhr.fhr_fh, sizeof(nfsfh_t)); + memset(&fhr.fhr_fh, 0, sizeof(nfsfh_t)); if (getfh(dirpath, (fhandle_t *)&fhr.fhr_fh) < 0) { bad = errno; syslog(LOG_ERR, "Can't get fh for %s", dirpath); @@ -691,7 +693,7 @@ get_exportlist() * And delete exports that are in the kernel for all local * file systems. * XXX: Should know how to handle all local exportable file systems - * instead of just MOUNT_UFS. + * instead of just "ufs". */ num = getmntinfo(&fsp, MNT_NOWAIT); for (i = 0; i < num; i++) { @@ -699,29 +701,16 @@ get_exportlist() struct ufs_args ua; struct iso_args ia; struct mfs_args ma; -#ifdef __NetBSD__ struct msdosfs_args da; } targs; - if (!strcmp(fsp->f_fstypename, MOUNT_MFS) || - !strcmp(fsp->f_fstypename, MOUNT_UFS) || - !strcmp(fsp->f_fstypename, MOUNT_MSDOS) || - !strcmp(fsp->f_fstypename, MOUNT_CD9660)) { + if (!strcmp(fsp->f_fstypename, "mfs") || + !strcmp(fsp->f_fstypename, "ufs") || + !strcmp(fsp->f_fstypename, "msdos") || + !strcmp(fsp->f_fstypename, "cd9660")) { targs.ua.fspec = NULL; targs.ua.export.ex_flags = MNT_DELEXPORT; if (mount(fsp->f_fstypename, fsp->f_mntonname, -#else - } targs; - - switch (fsp->f_type) { - case MOUNT_MFS: - case MOUNT_UFS: - case MOUNT_CD9660: - case MOUNT_MSDOS: - targs.ua.fspec = NULL; - targs.ua.export.ex_flags = MNT_DELEXPORT; - if (mount(fsp->f_type, fsp->f_mntonname, -#endif fsp->f_flags | MNT_UPDATE, (caddr_t)&targs) < 0) syslog(LOG_ERR, "Can't delete exports for %s", @@ -963,7 +952,7 @@ get_exp() ep = (struct exportlist *)malloc(sizeof (struct exportlist)); if (ep == (struct exportlist *)NULL) out_of_mem(); - bzero((caddr_t)ep, sizeof (struct exportlist)); + memset(ep, 0, sizeof(struct exportlist)); return (ep); } @@ -978,7 +967,7 @@ get_grp() gp = (struct grouplist *)malloc(sizeof (struct grouplist)); if (gp == (struct grouplist *)NULL) out_of_mem(); - bzero((caddr_t)gp, sizeof (struct grouplist)); + memset(gp, 0, sizeof(struct grouplist)); return (gp); } @@ -1270,12 +1259,12 @@ do_opt(cpp, endcpp, ep, grp, has_hostp, exflagsp, cr) while (cpopt && *cpopt) { allflag = 1; usedarg = -2; - if (cpoptend = index(cpopt, ',')) { + if (cpoptend = strchr(cpopt, ',')) { *cpoptend++ = '\0'; - if (cpoptarg = index(cpopt, '=')) + if (cpoptarg = strchr(cpopt, '=')) *cpoptarg++ = '\0'; } else { - if (cpoptarg = index(cpopt, '=')) + if (cpoptarg = strchr(cpopt, '=')) *cpoptarg++ = '\0'; else { *cp = savedc; @@ -1418,13 +1407,12 @@ get_host(cp, grp, tgrp) malloc(sizeof(struct hostent)); if (nhp == (struct hostent *)NULL) out_of_mem(); - bcopy((caddr_t)hp, (caddr_t)nhp, - sizeof(struct hostent)); + memmove(nhp, hp, sizeof(struct hostent)); i = strlen(hp->h_name)+1; nhp->h_name = (char *)malloc(i); if (nhp->h_name == (char *)NULL) out_of_mem(); - bcopy(hp->h_name, nhp->h_name, i); + memmove(nhp->h_name, hp->h_name, i); addrp = hp->h_addr_list; i = 1; while (*addrp++) @@ -1439,8 +1427,7 @@ get_host(cp, grp, tgrp) malloc(hp->h_length); if (*naddrp == (char *)NULL) out_of_mem(); - bcopy(*addrp, *naddrp, - hp->h_length); + memmove(*naddrp, *addrp, hp->h_length); addrp++; naddrp++; } @@ -1519,10 +1506,9 @@ get_isoaddr(cp, grp) malloc(sizeof (struct sockaddr_iso)); if (isoaddr == (struct sockaddr_iso *)NULL) out_of_mem(); - bzero((caddr_t)isoaddr, sizeof (struct sockaddr_iso)); - bcopy((caddr_t)isop, (caddr_t)&isoaddr->siso_addr, - sizeof (struct iso_addr)); - isoaddr->siso_len = sizeof (struct sockaddr_iso); + memset(isoaddr, 0, sizeof(struct sockaddr_iso)); + memmove(&isoaddr->siso_addr, isop, sizeof(struct iso_addr)); + isoaddr->siso_len = sizeof(struct sockaddr_iso); isoaddr->siso_family = AF_ISO; grp->gr_type = GT_ISO; grp->gr_ptr.gt_isoaddr = isoaddr; @@ -1573,8 +1559,8 @@ do_mount(ep, grp, exflags, anoncrp, dirp, dirplen, fsb) args.ua.fspec = 0; args.ua.export.ex_flags = exflags; args.ua.export.ex_anon = *anoncrp; - bzero((char *)&sin, sizeof(sin)); - bzero((char *)&imask, sizeof(imask)); + memset(&sin, 0, sizeof(sin)); + memset(&imask, 0, sizeof(imask)); sin.sin_family = AF_INET; sin.sin_len = sizeof(sin); imask.sin_family = AF_INET; @@ -1640,13 +1626,9 @@ do_mount(ep, grp, exflags, anoncrp, dirp, dirplen, fsb) * Maybe I should just use the fsb->f_mntonname path instead * of looping back up the dirp to the mount point?? * Also, needs to know how to export all types of local - * exportable file systems and not just MOUNT_UFS. + * exportable file systems and not just "ufs". */ -#ifdef __NetBSD__ while (mount(fsb->f_fstypename, dirp, -#else - while (mount(fsb->f_type, dirp, -#endif fsb->f_flags | MNT_UPDATE, (caddr_t)&args) < 0) { if (cp) *cp-- = savedc; @@ -1896,7 +1878,7 @@ void get_mountlist() { struct mountlist *mlp, **mlpp; - char *eos, *dirp; + char *host, *dirp, *cp; int len; char str[STRSIZ]; FILE *mlfile; @@ -1907,27 +1889,16 @@ get_mountlist() } mlpp = &mlhead; while (fgets(str, STRSIZ, mlfile) != NULL) { - if ((dirp = index(str, '\t')) == NULL && - (dirp = index(str, ' ')) == NULL) + cp = str; + host = strsep(&cp, " \t\n"); + dirp = strsep(&cp, " \t\n"); + if (host == NULL || dirp == NULL) continue; mlp = (struct mountlist *)malloc(sizeof (*mlp)); - len = dirp-str; - if (len > RPCMNT_NAMELEN) - len = RPCMNT_NAMELEN; - bcopy(str, mlp->ml_host, len); - mlp->ml_host[len] = '\0'; - while (*dirp == '\t' || *dirp == ' ') - dirp++; - if ((eos = index(dirp, '\t')) == NULL && - (eos = index(dirp, ' ')) == NULL && - (eos = index(dirp, '\n')) == NULL) - len = strlen(dirp); - else - len = eos-dirp; - if (len > RPCMNT_PATHLEN) - len = RPCMNT_PATHLEN; - bcopy(dirp, mlp->ml_dirp, len); - mlp->ml_dirp[len] = '\0'; + strncpy(mlp->ml_host, host, RPCMNT_NAMELEN); + mlp->ml_host[RPCMNT_NAMELEN] = '\0'; + strncpy(mlp->ml_dirp, dirp, RPCMNT_PATHLEN); + mlp->ml_dirp[RPCMNT_PATHLEN] = '\0'; mlp->ml_next = (struct mountlist *)NULL; *mlpp = mlp; mlpp = &mlp->ml_next; |