BSD 4_3_Reno release
[unix-history] / usr / src / sbin / mount / mount.c
index 979a4a1..f3456c7 100644 (file)
@@ -2,7 +2,19 @@
  * Copyright (c) 1980, 1989 The Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1980, 1989 The Regents of the University of California.
  * All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms are permitted provided
+ * that: (1) source distributions retain this entire copyright notice and
+ * comment, and (2) distributions including binaries display the following
+ * acknowledgement:  ``This product includes software developed by the
+ * University of California, Berkeley and its contributors'' in the
+ * documentation or other materials provided with the distribution and in
+ * all advertising materials mentioning features or use of this software.
+ * Neither the name of the University nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
@@ -12,15 +24,19 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)mount.c    5.42 (Berkeley) %G%";
+static char sccsid[] = "@(#)mount.c    5.39 (Berkeley) 6/22/90";
 #endif /* not lint */
 
 #endif /* not lint */
 
+#include "pathnames.h"
 #include <sys/param.h>
 #include <sys/file.h>
 #include <sys/time.h>
 #include <sys/wait.h>
 #include <sys/param.h>
 #include <sys/file.h>
 #include <sys/time.h>
 #include <sys/wait.h>
-#include <sys/errno.h>
-#include <sys/signal.h>
+#include <fstab.h>
+#include <errno.h>
+#include <stdio.h>
+#include <signal.h>
+#include <string.h>
 #include <sys/mount.h>
 #ifdef NFS
 #include <sys/socket.h>
 #include <sys/mount.h>
 #ifdef NFS
 #include <sys/socket.h>
@@ -33,11 +49,6 @@ static char sccsid[] = "@(#)mount.c  5.42 (Berkeley) %G%";
 #include <nfs/nfsv2.h>
 #include <nfs/nfs.h>
 #endif
 #include <nfs/nfsv2.h>
 #include <nfs/nfs.h>
 #endif
-#include <fstab.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "pathnames.h"
 
 #define DEFAULT_ROOTUID        -2
 
 
 #define DEFAULT_ROOTUID        -2
 
@@ -228,6 +239,7 @@ mountfs(spec, name, flags, type, options, mntopts)
        char *spec, *name, *type, *options, *mntopts;
        int flags;
 {
        char *spec, *name, *type, *options, *mntopts;
        int flags;
 {
+       extern int errno;
        union wait status;
        pid_t pid;
        int argc, i;
        union wait status;
        pid_t pid;
        int argc, i;
@@ -327,10 +339,8 @@ mountfs(spec, name, flags, type, options, mntopts)
                        if (flags & MNT_UPDATE)
                                fprintf(stderr, "Specified device does %s\n",
                                        "not match mounted device");
                        if (flags & MNT_UPDATE)
                                fprintf(stderr, "Specified device does %s\n",
                                        "not match mounted device");
-                       else if (mnttype == MOUNT_UFS)
-                               fprintf(stderr, "Bogus super block\n");
                        else
                        else
-                               perror((char *)NULL);
+                               fprintf(stderr, "Bogus super block\n");
                        break;
                case EOPNOTSUPP:
                        fprintf(stderr, "Operation not supported\n");
                        break;
                case EOPNOTSUPP:
                        fprintf(stderr, "Operation not supported\n");
@@ -618,8 +628,6 @@ getnfsopts(optarg, nfsargsp, opflagsp, retrycntp)
                                exit(1);
                        }
                        nfsargsp->flags |= NFSMNT_SPONGY;
                                exit(1);
                        }
                        nfsargsp->flags |= NFSMNT_SPONGY;
-               } else if (!strcmp(cp, "compress")) {
-                       nfsargsp->flags |= NFSMNT_COMPRESS;
                } else if (!strcmp(cp, "intr")) {
                        nfsargsp->flags |= NFSMNT_INT;
                } else if (!strcmp(cp, "tcp")) {
                } else if (!strcmp(cp, "intr")) {
                        nfsargsp->flags |= NFSMNT_INT;
                } else if (!strcmp(cp, "tcp")) {
@@ -656,28 +664,25 @@ getnfsargs(spec, nfsargsp)
        char *spec;
        struct nfs_args *nfsargsp;
 {
        char *spec;
        struct nfs_args *nfsargsp;
 {
+       extern int errno;
        register CLIENT *clp;
        struct hostent *hp;
        static struct sockaddr_in saddr;
        struct timeval pertry, try;
        enum clnt_stat clnt_stat;
        int so = RPC_ANYSOCK;
        register CLIENT *clp;
        struct hostent *hp;
        static struct sockaddr_in saddr;
        struct timeval pertry, try;
        enum clnt_stat clnt_stat;
        int so = RPC_ANYSOCK;
-       char *fsp, *hostp, *delimp;
+       char *hostp, *delimp;
        u_short tport;
        static struct nfhret nfhret;
        static char nam[MNAMELEN + 1];
        u_short tport;
        static struct nfhret nfhret;
        static char nam[MNAMELEN + 1];
-       char buf[MAXPATHLEN + 1];
 
 
-       strncpy(buf, spec, MAXPATHLEN);
-       buf[MAXPATHLEN] = '\0';
        strncpy(nam, spec, MNAMELEN);
        nam[MNAMELEN] = '\0';
        strncpy(nam, spec, MNAMELEN);
        nam[MNAMELEN] = '\0';
-       if ((delimp = index(buf, '@')) != NULL) {
+       if ((delimp = index(spec, '@')) != NULL) {
                hostp = delimp + 1;
                hostp = delimp + 1;
-               fsp = buf;
-       } else if ((delimp = index(buf, ':')) != NULL) {
-               hostp = buf;
-               fsp = delimp + 1;
+       } else if ((delimp = index(spec, ':')) != NULL) {
+               hostp = spec;
+               spec = delimp + 1;
        } else {
                fprintf(stderr,
                    "No <host>:<dirpath> or <dirpath>@<host> spec\n");
        } else {
                fprintf(stderr,
                    "No <host>:<dirpath> or <dirpath>@<host> spec\n");
@@ -689,7 +694,7 @@ getnfsargs(spec, nfsargsp)
                return (0);
        }
        bcopy(hp->h_addr, (caddr_t)&saddr.sin_addr, hp->h_length);
                return (0);
        }
        bcopy(hp->h_addr, (caddr_t)&saddr.sin_addr, hp->h_length);
-       nfhret.stat = ETIMEDOUT;        /* Mark not yet successful */
+       nfhret.stat = EACCES;   /* Mark not yet successful */
        while (retrycnt > 0) {
                saddr.sin_family = AF_INET;
                saddr.sin_port = htons(PMAPPORT);
        while (retrycnt > 0) {
                saddr.sin_family = AF_INET;
                saddr.sin_port = htons(PMAPPORT);
@@ -710,7 +715,7 @@ getnfsargs(spec, nfsargsp)
                                try.tv_sec = 10;
                                try.tv_usec = 0;
                                clnt_stat = clnt_call(clp, RPCMNT_MOUNT,
                                try.tv_sec = 10;
                                try.tv_usec = 0;
                                clnt_stat = clnt_call(clp, RPCMNT_MOUNT,
-                                   xdr_dir, fsp, xdr_fh, &nfhret, try);
+                                   xdr_dir, spec, xdr_fh, &nfhret, try);
                                if (clnt_stat != RPC_SUCCESS) {
                                        if ((opflags & ISBGRND) == 0)
                                                clnt_perror(clp, "Bad MNT RPC");
                                if (clnt_stat != RPC_SUCCESS) {
                                        if ((opflags & ISBGRND) == 0)
                                                clnt_perror(clp, "Bad MNT RPC");
@@ -735,7 +740,7 @@ getnfsargs(spec, nfsargsp)
        if (nfhret.stat) {
                if (opflags & ISBGRND)
                        exit(1);
        if (nfhret.stat) {
                if (opflags & ISBGRND)
                        exit(1);
-               fprintf(stderr, "Mount RPC error on %s: ", spec);
+               fprintf(stderr, "Can't access %s: ", spec);
                errno = nfhret.stat;
                perror((char *)NULL);
                return (0);
                errno = nfhret.stat;
                perror((char *)NULL);
                return (0);