BSD 4_4 release
[unix-history] / usr / src / usr.sbin / amd / amd / afs_ops.c
index 756283a..6dfdc14 100644 (file)
@@ -1,17 +1,43 @@
 /*
  * Copyright (c) 1990 Jan-Simon Pendry
  * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
 /*
  * 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.
- * All rights reserved.
+ * Copyright (c) 1990, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * 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.
  *
- * %sccs.include.redist.c%
+ * 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.
  *
  *
- *     @(#)afs_ops.c   5.3 (Berkeley) %G%
+ * 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.
  *
  *
- * $Id: afs_ops.c,v 5.2.1.9 91/05/07 22:17:40 jsp Alpha $
+ *     @(#)afs_ops.c   8.1 (Berkeley) 6/6/93
+ *
+ * $Id: afs_ops.c,v 5.2.2.4 1992/05/31 16:36:36 jsp Exp $
  *
  */
 
  *
  */
 
@@ -160,6 +186,11 @@ char *opts;
                strcpy(fs_hostname + HOSTNAMESZ - 3, "..");
 #endif /* HOSTNAMESZ */
 
                strcpy(fs_hostname + HOSTNAMESZ - 3, "..");
 #endif /* HOSTNAMESZ */
 
+#ifdef NFSMNT_DUMBTIMR
+       nfs_args.flags |= NFSMNT_DUMBTIMR;
+       plog(XLOG_INFO, "defeating nfs window computation");
+#endif
+
        /*
         * Parse a subset of the standard nfs options.  The
         * others are probably irrelevant for this application
        /*
         * Parse a subset of the standard nfs options.  The
         * others are probably irrelevant for this application
@@ -602,6 +633,8 @@ voidp closure;
         * Check for termination signal or exit status...
         */
        if (rc || term) {
         * Check for termination signal or exit status...
         */
        if (rc || term) {
+               am_node *xmp;
+
                if (term) {
                        /*
                         * Not sure what to do for an error code.
                if (term) {
                        /*
                         * Not sure what to do for an error code.
@@ -626,8 +659,9 @@ voidp closure;
                 */
                amd_stats.d_merr++;
                cp->ivec++;
                 */
                amd_stats.d_merr++;
                cp->ivec++;
+               xmp = cp->mp;
                (void) afs_bgmount(cp, 0);
                (void) afs_bgmount(cp, 0);
-               assign_error_mntfs(cp->mp);
+               assign_error_mntfs(xmp);
        } else {
                /*
                 * The mount worked.
        } else {
                /*
                 * The mount worked.
@@ -864,7 +898,7 @@ int mpe;
                 * Find a mounted filesystem for this node.
                 */
                mp->am_mnt = mf = realloc_mntfs(mf, p, &cp->fs_opts, cp->fs_opts.opt_fs,
                 * Find a mounted filesystem for this node.
                 */
                mp->am_mnt = mf = realloc_mntfs(mf, p, &cp->fs_opts, cp->fs_opts.opt_fs,
-                                               cp->fs_opts.fs_mtab, cp->auto_opts, cp->fs_opts.opt_opts);
+                       cp->fs_opts.fs_mtab, cp->auto_opts, cp->fs_opts.opt_opts, cp->fs_opts.opt_remopts);
 
                p = mf->mf_ops;
 #ifdef DEBUG
 
                p = mf->mf_ops;
 #ifdef DEBUG
@@ -1103,7 +1137,7 @@ int mpe;
                        cp->mp->am_timeo = 17;
                        break;
                }
                        cp->mp->am_timeo = 17;
                        break;
                }
-               cp->mp->am_timeo_w = 0;
+               new_ttl(cp->mp);
        }
 
        /*
        }
 
        /*
@@ -1225,6 +1259,10 @@ int op;
                         * Check for a hung node
                         */
                        if (FSRV_ISDOWN(mf->mf_server)) {
                         * Check for a hung node
                         */
                        if (FSRV_ISDOWN(mf->mf_server)) {
+#ifdef DEBUG
+                               dlog("server hung");
+#endif /* DEBUG */
+                               error = ap->am_error;
                                ap_hung = ap;
                                continue;
                        }
                                ap_hung = ap;
                                continue;
                        }
@@ -1411,24 +1449,19 @@ in_progrss:
                dfl = rvec[0];
 
                /*
                dfl = rvec[0];
 
                /*
-                * Log error if there were other values
+                * If there were any values at all...
                 */
                 */
-               if (rvec[1]) {
+               if (dfl) {
+                       /*
+                        * Log error if there were other values
+                        */
+                       if (rvec[1]) {
 #ifdef DEBUG
 #ifdef DEBUG
-                       dlog("/defaults chopped into %s", dfl);
+                               dlog("/defaults chopped into %s", dfl);
 #endif /* DEBUG */
 #endif /* DEBUG */
-                       plog(XLOG_USER, "More than a single value for /defaults in %s", mf->mf_info);
-               }
-
-               /*
-                * Don't need info vector any more
-                */
-               free((voidp) rvec);
+                               plog(XLOG_USER, "More than a single value for /defaults in %s", mf->mf_info);
+                       }
 
 
-               /*
-                * If there were any values at all...
-                */
-               if (dfl) {
                        /*
                         * Prepend to existing defaults if they exist,
                         * otherwise just use these defaults.
                        /*
                         * Prepend to existing defaults if they exist,
                         * otherwise just use these defaults.
@@ -1443,6 +1476,10 @@ in_progrss:
                        }
                }
                free(dflts);
                        }
                }
                free(dflts);
+               /*
+                * Don't need info vector any more
+                */
+               free((voidp) rvec);
        }
 
        /*
        }
 
        /*
@@ -1505,7 +1542,10 @@ in_progrss:
                return new_mp;
        }
 
                return new_mp;
        }
 
-       assign_error_mntfs(cp->mp);
+       if (error && (cp->mp->am_mnt->mf_ops == &efs_ops))
+               cp->mp->am_error = error;
+
+       assign_error_mntfs(new_mp);
 
        free(fname);
 
 
        free(fname);
 
@@ -1567,6 +1607,21 @@ int count;
 #ifdef DEBUG
                dlog("default search");
 #endif /* DEBUG */
 #ifdef DEBUG
                dlog("default search");
 #endif /* DEBUG */
+               /*
+                * Check for enough room.  This is extremely
+                * approximate but is more than enough space.
+                * Really need 2 times:
+                *      4byte fileid
+                *      4byte cookie
+                *      4byte name length
+                *      4byte name
+                * plus the dirlist structure
+                */
+               if (count <
+                       (2 * (2 * (sizeof(*ep) + sizeof("..") + 4)
+                                       + sizeof(*dp))))
+                       return EINVAL;
+
                xp = next_nonerror_node(mp->am_child);
                dp->entries = ep;
 
                xp = next_nonerror_node(mp->am_child);
                dp->entries = ep;