BSD 4_3_Net_2 release
[unix-history] / usr / src / usr.sbin / amd / amd / mount_fs.c
index 1f993c9..cda10bf 100644 (file)
@@ -1,6 +1,4 @@
 /*
 /*
- * $Id: mount_fs.c,v 5.2 90/06/23 22:19:42 jsp Rel $
- *
  * Copyright (c) 1990 Jan-Simon Pendry
  * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
  * Copyright (c) 1990 The Regents of the University of California.
  * Copyright (c) 1990 Jan-Simon Pendry
  * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
  * Copyright (c) 1990 The Regents of the University of California.
@@ -9,21 +7,38 @@
  * This code is derived from software contributed to Berkeley by
  * Jan-Simon Pendry at Imperial College, London.
  *
  * This code is derived from software contributed to Berkeley by
  * Jan-Simon Pendry at Imperial College, London.
  *
- * 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.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. 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 BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)mount_fs.c  5.3 (Berkeley) 5/12/91
+ *
+ * $Id: mount_fs.c,v 5.2.1.4 91/05/07 22:18:13 jsp Alpha $
  *
  *
- *     @(#)mount_fs.c  5.1 (Berkeley) 6/29/90
  */
 
 #include "am.h"
  */
 
 #include "am.h"
@@ -32,13 +47,6 @@ typedef nfs_fh fhandle_t;
 #endif /* NFS_3 */
 #include <sys/mount.h>
 
 #endif /* NFS_3 */
 #include <sys/mount.h>
 
-/*
- * System Vr4 / SunOS 4.1 compatibility
- * - put dev= in the options list
- *
- * From: Brent Callaghan <brent@eng.sun.com>
- */
-#define        MNTINFO_DEV     "dev"
 #include <sys/stat.h>
 
 /*
 #include <sys/stat.h>
 
 /*
@@ -101,6 +109,7 @@ struct mntent *mnt;
        return flags;
 }
 
        return flags;
 }
 
+int mount_fs P((struct mntent *mnt, int flags, caddr_t mnt_data, int retry, MTYPE_TYPE type));
 int mount_fs(mnt, flags, mnt_data, retry, type)
 struct mntent *mnt;
 int flags;
 int mount_fs(mnt, flags, mnt_data, retry, type)
 struct mntent *mnt;
 int flags;
@@ -109,7 +118,6 @@ int retry;
 MTYPE_TYPE type;
 {
        int error = 0;
 MTYPE_TYPE type;
 {
        int error = 0;
-       int automount = 0;
 #ifdef MNTINFO_DEV
        struct stat stb;
        char *xopts = 0;
 #ifdef MNTINFO_DEV
        struct stat stb;
        char *xopts = 0;
@@ -128,31 +136,18 @@ MTYPE_TYPE type;
        /*
         * Fake some mount table entries for the automounter
         */
        /*
         * Fake some mount table entries for the automounter
         */
+#ifdef FASCIST_DF_COMMAND
+       /*
+        * Some systems have a df command which blows up when
+        * presented with an unknown mount type.
+        */
        if (STREQ(mnt->mnt_type, MNTTYPE_AUTO)) {
        if (STREQ(mnt->mnt_type, MNTTYPE_AUTO)) {
-               automount = 1;
-               mnt->mnt_fsname = pid_fsname;
                /*
                 * Try it with the normal name
                 */
                /*
                 * Try it with the normal name
                 */
-#ifdef notdef
-               /*
-                * This is notdef'ed because some systems use
-                * the mount table in getwd() (esp. SunOS4) and
-                * if all the mount points are not marked it can
-                * cause major confusion.  This can probably
-                * be changed when no-one is running SunOS 4.0
-                * any more.
-                */
-               mnt->mnt_type = MNTTYPE_IGNORE;
-#endif /* notdef */
                mnt->mnt_type = MNTTYPE_NFS;
                mnt->mnt_type = MNTTYPE_NFS;
-               /*
-                * Background the mount, so that the stat of the
-                * mountpoint is done in a background process.
-                */
-               if (background())
-                       return 0;
        }
        }
+#endif /* FASCIST_DF_COMMAND */
 
 again:
        clock_valid = 0;
 
 again:
        clock_valid = 0;
@@ -164,8 +159,10 @@ again:
                goto again;
        }
        if (error < 0) {
                goto again;
        }
        if (error < 0) {
+#ifdef notdef
                if (automount)
                        going_down(errno);
                if (automount)
                        going_down(errno);
+#endif
                return errno;
        }
 
                return errno;
        }
 
@@ -178,24 +175,26 @@ again:
                char *zopts = (char *) xmalloc(strlen(mnt->mnt_opts) + 32);
                xopts = mnt->mnt_opts;
                if (sizeof(stb.st_dev) == 2) {
                char *zopts = (char *) xmalloc(strlen(mnt->mnt_opts) + 32);
                xopts = mnt->mnt_opts;
                if (sizeof(stb.st_dev) == 2) {
-                       /* SunOS 4.1 */
-                       sprintf(zopts, "%s,%s=%04lx", xopts, MNTINFO_DEV,
-                                       (u_long) stb.st_dev & 0xffff);
+                       /* e.g. SunOS 4.1 */
+                       sprintf(zopts, "%s,%s=%s%04lx", xopts, MNTINFO_DEV,
+                                       MNTINFO_PREF, (u_long) stb.st_dev & 0xffff);
                } else {
                } else {
-                       /* System Vr4 */
-                       sprintf(zopts, "%s,%s=%08lx", xopts, MNTINFO_DEV,
-                                       (u_long) stb.st_dev);
+                       /* e.g. System Vr4 */
+                       sprintf(zopts, "%s,%s=%s%08lx", xopts, MNTINFO_DEV,
+                                       MNTINFO_PREF, (u_long) stb.st_dev);
                }
                mnt->mnt_opts = zopts;
        }
 #endif /* MNTINFO_DEV */
 
                }
                mnt->mnt_opts = zopts;
        }
 #endif /* MNTINFO_DEV */
 
-#ifdef hpux
+#ifdef FIXUP_MNTENT
        /*
        /*
-        * Yet another gratuitously incompatible change in HP-UX
+        * Additional fields in struct mntent
+        * are fixed up here
         */
         */
-       mnt->mnt_time = clocktime();
-#endif /* hpux */
+       FIXUP_MNTENT(mnt);
+#endif
+
        write_mntent(mnt);
 #ifdef MNTINFO_DEV
        if (xopts) {
        write_mntent(mnt);
 #ifdef MNTINFO_DEV
        if (xopts) {
@@ -205,12 +204,6 @@ again:
 #endif /* MNTINFO_DEV */
 #endif /* UPDATE_MTAB */
 
 #endif /* MNTINFO_DEV */
 #endif /* UPDATE_MTAB */
 
-       /*
-        * Needed this way since mnt may contain a pointer
-        * to a local variable in this stack frame.
-        */
-       if (automount)
-               going_down(0);
        return 0;
 }
 
        return 0;
 }
 
@@ -275,102 +268,6 @@ char *opt;
 }
 #endif /* NEED_MNTOPT_PARSER */
 
 }
 #endif /* NEED_MNTOPT_PARSER */
 
-#ifdef MOUNT_AIX3
-
-#include "aix3-nfs.h"
-
-static int aix3_mkvp(p, gfstype, flags, object, stub, host, info, info_size, args)
-char *p;
-int gfstype;
-int flags;
-char *object;
-char *stub;
-char *host;
-char *info;
-int info_size;
-char *args;
-{
-       struct vmount *vp = (struct vmount *) p;
-       bzero((voidp) vp, sizeof(*vp));
-       /*
-        * Fill in standard fields
-        */
-       vp->vmt_revision = VMT_REVISION;
-       vp->vmt_flags = flags;
-       vp->vmt_gfstype = gfstype;
-
-#define        VMT_ROUNDUP(len) (4 * ((len + 3) / 4))
-#define VMT_ASSIGN(vp, idx, data, size) \
-       vp->vmt_data[idx].vmt_off = p - (char *) vp; \
-       vp->vmt_data[idx].vmt_size = size; \
-       bcopy(data, p, size); \
-       p += VMT_ROUNDUP(size);
-
-       /*
-        * Fill in all variable length data
-        */
-       p += sizeof(*vp);
-
-       VMT_ASSIGN(vp, VMT_OBJECT, object, strlen(object) + 1);
-       VMT_ASSIGN(vp, VMT_STUB, stub, strlen(stub) + 1);
-       VMT_ASSIGN(vp, VMT_HOST, host, strlen(host) + 1);
-       VMT_ASSIGN(vp, VMT_HOSTNAME, host, strlen(host) + 1);
-       VMT_ASSIGN(vp, VMT_INFO, info, info_size);
-       VMT_ASSIGN(vp, VMT_ARGS, args, strlen(args) + 1);
-
-#undef VMT_ASSIGN
-#undef VMT_ROUNDUP
-
-       /*
-        * Return length
-        */
-       return vp->vmt_length = p - (char *) vp;
-}
-
-/*
- * Map from conventional mount arguments
- * to AIX 3-style arguments.
- */
-aix3_mount(fsname, dir, flags, type, data, args)
-char *fsname;
-char *dir;
-int flags;
-int type;
-void *data;
-char *args;
-{
-       char buf[4096];
-       int size;
-
-#ifdef DEBUG
-       dlog("aix3_mount: fsname %s, dir %s, type %d", fsname, dir, type);
-#endif /* DEBUG */
-
-/* aix3_mkvp(p, gfstype, flags, object, stub, host, info, info_size, args) */
-
-       switch (type) {
-
-       case MOUNT_TYPE_NFS: {
-               char *host = strdup(fsname);
-               char *rfs = strchr(host, ':');
-               *rfs++ = '\0';
-
-               size = aix3_mkvp(buf, type, flags, rfs, dir, host, data, sizeof(struct nfs_args), args);
-               free(host);
-
-               } break;
-
-       case MOUNT_TYPE_UFS:
-               /* Need to open block device and extract log device info from sblk. */
-               return EINVAL;
-
-       default:
-               return EINVAL;
-       }
-#ifdef DEBUG
-       /*dlog("aix3_mkvp: flags %#x, size %d, args %s", flags, size, args);*/
-#endif /* DEBUG */
-
-       return vmount(buf, size);
-}
-#endif /* MOUNT_AIX3 */
+#ifdef MOUNT_HELPER_SOURCE
+#include MOUNT_HELPER_SOURCE
+#endif /* MOUNT_HELPER_SOURCE */