summaryrefslogtreecommitdiffstats
path: root/usr.sbin/mountd/mountd.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/mountd/mountd.c')
-rw-r--r--usr.sbin/mountd/mountd.c113
1 files changed, 42 insertions, 71 deletions
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;
OpenPOWER on IntegriCloud