diff options
Diffstat (limited to 'contrib/amd/amd')
61 files changed, 496 insertions, 433 deletions
diff --git a/contrib/amd/amd/am_ops.c b/contrib/amd/amd/am_ops.c index 49db91e5830e..9f5656206b9b 100644 --- a/contrib/amd/amd/am_ops.c +++ b/contrib/amd/amd/am_ops.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: am_ops.c,v 1.4 1999/03/13 17:03:26 ezk Exp $ + * $Id: am_ops.c,v 1.6.2.3 2001/02/23 01:03:39 ezk Exp $ * */ @@ -53,7 +53,7 @@ * The order of these entries matters, since lookups in this table are done * on a first-match basis. The entries below are a mixture of native * filesystems supported by the OS (HAVE_FS_FOO), and some meta-filesystems - * supported by amd (HAVE_AM_FS_FOO). The order is set here in expected + * supported by amd (HAVE_AMU_FS_FOO). The order is set here in expected * match-hit such that more popular filesystems are listed first (nfs is the * most popular, followed by a symlink F/S) */ @@ -62,34 +62,34 @@ static am_ops *vops[] = #ifdef HAVE_FS_NFS &nfs_ops, /* network F/S (version 2) */ #endif /* HAVE_FS_NFS */ -#ifdef HAVE_AM_FS_LINK +#ifdef HAVE_AMU_FS_LINK &amfs_link_ops, /* symlink F/S */ -#endif /* HAVE_AM_FS_LINK */ +#endif /* HAVE_AMU_FS_LINK */ /* * Other amd-supported meta-filesystems. */ -#ifdef HAVE_AM_FS_NFSX +#ifdef HAVE_AMU_FS_NFSX &amfs_nfsx_ops, /* multiple-nfs F/S */ -#endif /* HAVE_AM_FS_NFSX */ -#ifdef HAVE_AM_FS_NFSL +#endif /* HAVE_AMU_FS_NFSX */ +#ifdef HAVE_AMU_FS_NFSL &amfs_nfsl_ops, /* NFS with local link existence check */ -#endif /* HAVE_AM_FS_NFSL */ -#ifdef HAVE_AM_FS_HOST +#endif /* HAVE_AMU_FS_NFSL */ +#ifdef HAVE_AMU_FS_HOST &amfs_host_ops, /* multiple exported nfs F/S */ -#endif /* HAVE_AM_FS_HOST */ -#ifdef HAVE_AM_FS_LINKX +#endif /* HAVE_AMU_FS_HOST */ +#ifdef HAVE_AMU_FS_LINKX &amfs_linkx_ops, /* symlink F/S with link target verify */ -#endif /* HAVE_AM_FS_LINKX */ -#ifdef HAVE_AM_FS_PROGRAM +#endif /* HAVE_AMU_FS_LINKX */ +#ifdef HAVE_AMU_FS_PROGRAM &amfs_program_ops, /* program F/S */ -#endif /* HAVE_AM_FS_PROGRAM */ -#ifdef HAVE_AM_FS_UNION +#endif /* HAVE_AMU_FS_PROGRAM */ +#ifdef HAVE_AMU_FS_UNION &amfs_union_ops, /* union F/S */ -#endif /* HAVE_AM_FS_UNION */ -#ifdef HAVE_AM_FS_INHERIT +#endif /* HAVE_AMU_FS_UNION */ +#ifdef HAVE_AMU_FS_INHERIT &amfs_inherit_ops, /* inheritance F/S */ -#endif /* HAVE_AM_FS_INHERIT */ +#endif /* HAVE_AMU_FS_INHERIT */ /* * A few more native filesystems. @@ -133,21 +133,21 @@ static am_ops *vops[] = * (4) autofs * (5) amfs_error */ -#ifdef HAVE_AM_FS_AUTO +#ifdef HAVE_AMU_FS_AUTO &amfs_auto_ops, /* Automounter F/S */ -#endif /* HAVE_AM_FS_AUTO */ -#ifdef HAVE_AM_FS_DIRECT +#endif /* HAVE_AMU_FS_AUTO */ +#ifdef HAVE_AMU_FS_DIRECT &amfs_direct_ops, /* direct-mount F/S */ -#endif /* HAVE_AM_FS_DIRECT */ -#ifdef HAVE_AM_FS_TOPLVL +#endif /* HAVE_AMU_FS_DIRECT */ +#ifdef HAVE_AMU_FS_TOPLVL &amfs_toplvl_ops, /* top-level mount F/S */ -#endif /* HAVE_AM_FS_TOPLVL */ +#endif /* HAVE_AMU_FS_TOPLVL */ #ifdef HAVE_FS_AUTOFS &autofs_ops, /* autofs mount F/S */ #endif /* HAVE_FS_AUTOFS */ -#ifdef HAVE_AM_FS_ERROR +#ifdef HAVE_AMU_FS_ERROR &amfs_error_ops, /* error F/S */ -#endif /* HAVE_AM_FS_ERROR */ +#endif /* HAVE_AMU_FS_ERROR */ 0 }; @@ -320,7 +320,7 @@ merge_opts(const char *opts1, const char *opts2) mntent_t mnt2; /* place holder for opts2 */ char *newstr; /* new string to return (malloc'ed) */ char *tmpstr; /* temp */ - char *eq; /* pointer to '=' within temp */ + char *eq; /* pointer to whatever follows '=' within temp */ char oneopt[80]; /* one option w/o value if any */ char *revoneopt; /* reverse of oneopt */ int len = strlen(opts1) + strlen(opts2) + 2; /* space for "," and NULL */ @@ -338,8 +338,8 @@ merge_opts(const char *opts1, const char *opts2) strncpy(oneopt, tmpstr, 80); oneopt[79] = '\0'; /* if option has a value such as rsize=1024, chop the value part */ - if ((eq = strchr(oneopt, '='))) - eq[1] = '\0'; + if ((eq = haseq(oneopt))) + *eq = '\0'; /* find reverse option of oneopt */ revoneopt = reverse_option(oneopt); /* if option orits reverse exist in opts2, ignore it */ @@ -420,7 +420,7 @@ ops_match(am_opts *fo, char *key, char *g_key, char *path, char *keym, char *map /* optimize things for the common case where opts==remopts */ char *mergedstr; mergedstr = merge_opts(fo->opt_opts, fo->opt_addopts); - plog(XLOG_USER, "merge rem/opts \"%s\" add \"%s\" => \"%s\"", + plog(XLOG_INFO, "merge rem/opts \"%s\" add \"%s\" => \"%s\"", fo->opt_opts, fo->opt_addopts, mergedstr); XFREE(fo->opt_opts); XFREE(fo->opt_remopts); @@ -429,12 +429,12 @@ ops_match(am_opts *fo, char *key, char *g_key, char *path, char *keym, char *map } else { char *mergedstr, *remmergedstr; mergedstr = merge_opts(fo->opt_opts, fo->opt_addopts); - plog(XLOG_USER, "merge opts \"%s\" add \"%s\" => \"%s\"", + plog(XLOG_INFO, "merge opts \"%s\" add \"%s\" => \"%s\"", fo->opt_opts, fo->opt_addopts, mergedstr); XFREE(fo->opt_opts); fo->opt_opts = mergedstr; remmergedstr = merge_opts(fo->opt_remopts, fo->opt_addopts); - plog(XLOG_USER, "merge remopts \"%s\" add \"%s\" => \"%s\"", + plog(XLOG_INFO, "merge remopts \"%s\" add \"%s\" => \"%s\"", fo->opt_remopts, fo->opt_addopts, remmergedstr); XFREE(fo->opt_remopts); fo->opt_remopts = remmergedstr; diff --git a/contrib/amd/amd/amd.8 b/contrib/amd/amd/amd.8 index 0e68d0f5335d..1bebce650cb2 100644 --- a/contrib/amd/amd/amd.8 +++ b/contrib/amd/amd/amd.8 @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 1997-1999 Erez Zadok +.\" Copyright (c) 1997-2001 Erez Zadok .\" Copyright (c) 1989 Jan-Simon Pendry .\" Copyright (c) 1989 Imperial College of Science, Technology & Medicine .\" Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ .\" .\" %W% (Berkeley) %G% .\" -.\" $Id: amd.8,v 1.3 1999/09/30 21:01:29 ezk Exp $ +.\" $Id: amd.8,v 1.4.2.1 2001/01/10 03:22:59 ezk Exp $ .\" .TH AMD 8 "3 November 1989" .SH NAME diff --git a/contrib/amd/amd/amd.c b/contrib/amd/amd/amd.c index 3f3da1b80226..cc10a8386ab5 100644 --- a/contrib/amd/amd/amd.c +++ b/contrib/amd/amd/amd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: amd.c,v 1.6 1999/09/30 21:01:29 ezk Exp $ + * $Id: amd.c,v 1.8.2.3 2001/01/10 03:22:59 ezk Exp $ * */ @@ -177,8 +177,8 @@ daemon_mode(void) if (gopt.flags & CFM_PRINT_PID) { if (STREQ(gopt.pid_file, "/dev/stdout")) { printf("%ld\n", (long) am_mypid); + /* flush stdout, just in case */ fflush(stdout); - /* do not fclose stdout */ } else { FILE *f; mode_t prev_umask = umask(0022); /* set secure temporary umask */ @@ -476,7 +476,7 @@ main(int argc, char *argv[]) verstr = strtok(get_version_string(), "\n"); plog(XLOG_INFO, "AM-UTILS VERSION INFORMATION:"); while (verstr) { - plog(XLOG_INFO, verstr); + plog(XLOG_INFO, "%s", verstr); verstr = strtok(NULL, "\n"); } diff --git a/contrib/amd/amd/amd.h b/contrib/amd/amd/amd.h index c8960220060f..b37978bf4e12 100644 --- a/contrib/amd/amd/amd.h +++ b/contrib/amd/amd/amd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: amd.h,v 1.4 1999/09/30 21:01:29 ezk Exp $ + * $Id: amd.h,v 1.8.2.3 2001/04/07 00:47:41 ib42 Exp $ * */ @@ -53,7 +53,7 @@ /* options for amd.conf */ #define CFM_BROWSABLE_DIRS 0x0001 #define CFM_MOUNT_TYPE_AUTOFS 0x0002 -#define CFM_ENABLE_DEFAULT_SELECTORS 0x0004 +#define CFM_SELECTORS_IN_DEFAULTS 0x0004 #define CFM_NORMALIZE_HOSTNAMES 0x0008 #define CFM_PROCESS_LOCK 0x0010 #define CFM_PRINT_PID 0x0020 @@ -134,6 +134,8 @@ struct amu_global_options { #ifdef HAVE_MAP_NIS char *nis_domain; /* YP domain name */ #endif /* HAVE_MAP_NIS */ + char *nfs_proto; /* NFS protocol (NULL, udp, tcp) */ + int nfs_vers; /* NFS version (0, 2, 3, 4) */ }; /* if you add anything here, update conf.c:reset_cf_map() */ @@ -227,7 +229,7 @@ extern voidp amqproc_umnt_1_svc(voidp argp, struct svc_req *rqstp); /* other external definitions */ extern am_nfs_fh *root_fh(char *dir); -extern am_node * autofs_lookuppn(am_node *mp, char *fname, int *error_return, int op); +extern am_node *autofs_lookuppn(am_node *mp, char *fname, int *error_return, int op); extern am_node *find_ap(char *); extern am_node *find_ap2(char *, am_node *); extern bool_t xdr_amq_mount_info_qelem(XDR *xdrs, qelem *qhead); @@ -252,8 +254,10 @@ extern void root_newmap(const char *, const char *, const char *, const cf_map_t /* amd global variables */ extern FILE *yyin; -extern SVCXPRT *nfs_program_2_transp; /* For quick_reply() */ +extern SVCXPRT *nfs_program_2_transp; /* For quick_reply() */ extern char *conf_tag; +extern char *opt_gid; +extern char *opt_uid; extern int NumChild; extern int fwd_sock; extern int select_intr_valid; @@ -261,20 +265,21 @@ extern int usage; extern int use_conf_file; /* use amd configuration file */ extern jmp_buf select_intr; extern qelem mfhead; -extern struct amu_global_options gopt; /* where global options are stored */ +extern struct am_opts fs_static; /* copy of the options to play with */ +extern struct amu_global_options gopt; /* where global options are stored */ #ifdef HAVE_SIGACTION extern sigset_t masked_sigs; #endif /* HAVE_SIGACTION */ -#if defined(HAVE_AM_FS_LINK) || defined(HAVE_AM_FS_LINKX) +#if defined(HAVE_AMU_FS_LINK) || defined(HAVE_AMU_FS_LINKX) extern char *amfs_link_match(am_opts *fo); extern int amfs_link_fumount(mntfs *mf); -#endif /* defined(HAVE_AM_FS_LINK) || defined(HAVE_AM_FS_LINKX) */ +#endif /* defined(HAVE_AMU_FS_LINK) || defined(HAVE_AMU_FS_LINKX) */ -#ifdef HAVE_AM_FS_NFSL +#ifdef HAVE_AMU_FS_NFSL extern char *nfs_match(am_opts *fo); -#endif /* HAVE_AM_FS_NFSL */ +#endif /* HAVE_AMU_FS_NFSL */ #if defined(HAVE_FS_NFS3) && !defined(HAVE_XDR_MOUNTRES3) extern bool_t xdr_mountres3(XDR *xdrs, mountres3 *objp); diff --git a/contrib/amd/amd/amfs_auto.c b/contrib/amd/amd/amfs_auto.c index f04cc509535e..dd9b7466ff20 100644 --- a/contrib/amd/amd/amfs_auto.c +++ b/contrib/amd/amd/amfs_auto.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: amfs_auto.c,v 1.5 1999/09/30 21:01:29 ezk Exp $ + * $Id: amfs_auto.c,v 1.9.2.7 2001/04/14 21:08:19 ezk Exp $ * */ @@ -57,10 +57,7 @@ ****************************************************************************/ #define IN_PROGRESS(cp) ((cp)->mp->am_mnt->mf_flags & MFF_MOUNTING) -/* DEVELOPERS: turn this on for special debugging of readdir code */ -#undef DEBUG_READDIR - -#define DOT_DOT_COOKIE (u_int) 1 +#define DOT_DOT_COOKIE (u_int) 1 /**************************************************************************** *** STRUCTURES *** @@ -70,7 +67,7 @@ /**************************************************************************** *** FORWARD DEFINITIONS *** ****************************************************************************/ -static int amfs_auto_bgmount(struct continuation * cp, int mpe); +static int amfs_auto_bgmount(struct continuation *cp, int mpe); static int amfs_auto_mount(am_node *mp); static int amfs_auto_readdir_browsable(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, int count, int fully_browsable); static void amfs_auto_umounted(am_node *mp); @@ -504,7 +501,7 @@ For each location: endfor */ static int -amfs_auto_bgmount(struct continuation * cp, int mpe) +amfs_auto_bgmount(struct continuation *cp, int mpe) { mntfs *mf = cp->mp->am_mnt; /* Current mntfs */ mntfs *mf_retry = 0; /* First mntfs which needed retrying */ @@ -580,7 +577,7 @@ amfs_auto_bgmount(struct continuation * cp, int mpe) * Note whether this is a real mount attempt */ if (p == &amfs_error_ops) { - plog(XLOG_MAP, "Map entry %s for %s failed to match", *cp->ivec, mp->am_path); + plog(XLOG_MAP, "Map entry %s for %s did not match", *cp->ivec, mp->am_path); if (this_error <= 0) this_error = ENOENT; continue; @@ -606,7 +603,7 @@ amfs_auto_bgmount(struct continuation * cp, int mpe) mp->am_link = strdup(link_dir); } else { /* - * try getting fs option from continuation, not mountpoint! + * Try getting fs option from continuation, not mountpoint! * Don't try logging the string from mf, since it may be bad! */ if (cp->fs_opts.opt_fs != mf->mf_fo->opt_fs) @@ -671,8 +668,6 @@ amfs_auto_bgmount(struct continuation * cp, int mpe) else mk_fattr(mp, NFLNK); - mp->am_fattr.na_fileid = mp->am_gen; - if (p->fs_init) this_error = (*p->fs_init) (mf); } @@ -722,7 +717,10 @@ amfs_auto_bgmount(struct continuation * cp, int mpe) untimeout(cp->callout); cp->callout = 0; } + + /* actually run the task, backgrounding as necessary */ run_task(try_mount, (voidp) mp, amfs_auto_cont, (voidp) cp); + mf->mf_flags |= MFF_MKMNT; /* XXX */ if (mf_retry) free_mntfs(mf_retry); @@ -1120,7 +1118,7 @@ amfs_auto_lookuppn(am_node *mp, char *fname, int *error_return, int op) */ rvec = strsplit(dfl, ' ', '\"'); - if (gopt.flags & CFM_ENABLE_DEFAULT_SELECTORS) { + if (gopt.flags & CFM_SELECTORS_IN_DEFAULTS) { /* * Pick whichever first entry matched the list of selectors. * Strip the selectors from the string, and assign to dfl the @@ -1132,11 +1130,18 @@ amfs_auto_lookuppn(am_node *mp, char *fname, int *error_return, int op) char **sp = rvec; while (*sp) { /* loop until you find something, if any */ memset((char *) &ap, 0, sizeof(am_opts)); + /* + * This next routine cause many spurious "expansion of ... is" + * messages, which are ignored, b/c all we need out of this + * routine is to match selectors. These spurious messages may + * be wrong, esp. if they try to expand ${key} b/c it will + * get expanded to "/defaults" + */ pt = ops_match(&ap, *sp, "", mp->am_path, "/defaults", mp->am_parent->am_mnt->mf_info); free_opts(&ap); /* don't leak */ if (pt == &amfs_error_ops) { - plog(XLOG_MAP, "failed to match defaults for \"%s\"", *sp); + plog(XLOG_MAP, "did not match defaults for \"%s\"", *sp); } else { dfl = strip_selectors(*sp, "/defaults"); plog(XLOG_MAP, "matched default selectors \"%s\"", dfl); @@ -1159,7 +1164,7 @@ amfs_auto_lookuppn(am_node *mp, char *fname, int *error_return, int op) /* * Log error if there were other values */ - if (!(gopt.flags & CFM_ENABLE_DEFAULT_SELECTORS) && rvec[1]) { + if (!(gopt.flags & CFM_SELECTORS_IN_DEFAULTS) && rvec[1]) { # ifdef DEBUG dlog("/defaults chopped into %s", dfl); # endif /* DEBUG */ @@ -1305,6 +1310,10 @@ amfs_auto_readdir(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, i u_int gen = *(u_int *) cookie; am_node *xp; mntent_t mnt; +#ifdef DEBUG + nfsentry *ne; + static int j; +#endif /* DEBUG */ dp->dl_eof = FALSE; /* assume readdir not done */ @@ -1317,6 +1326,7 @@ amfs_auto_readdir(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, i return amfs_auto_readdir_browsable(mp, cookie, dp, ep, count, FALSE); } + /* when gen is 0, we start reading from the beginning of the directory */ if (gen == 0) { /* * In the default instance (which is used to start a search) we return @@ -1361,6 +1371,12 @@ amfs_auto_readdir(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, i if (!xp) dp->dl_eof = TRUE; /* by default assume readdir done */ +#ifdef DEBUG + amuDebug(D_READDIR) + for (j=0,ne=ep; ne; ne=ne->ne_nextentry) + plog(XLOG_DEBUG, "gen1 key %4d \"%s\" fi=%d ck=%d", + j++, ne->ne_name, ne->ne_fileid, *(u_int *)ne->ne_cookie); +#endif /* DEBUG */ return 0; } #ifdef DEBUG @@ -1373,6 +1389,10 @@ amfs_auto_readdir(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, i #endif /* DEBUG */ dp->dl_eof = TRUE; dp->dl_entries = 0; +#ifdef DEBUG + amuDebug(D_READDIR) + plog(XLOG_DEBUG, "end of readdir eof=TRUE, dl_entries=0\n"); +#endif /* DEBUG */ return 0; } @@ -1415,6 +1435,12 @@ amfs_auto_readdir(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, i ep->ne_nextentry = 0; +#ifdef DEBUG + amuDebug(D_READDIR) + for (j=0,ne=ep; ne; ne=ne->ne_nextentry) + plog(XLOG_DEBUG, "gen2 key %4d \"%s\" fi=%d ck=%d", + j++, ne->ne_name, ne->ne_fileid, *(u_int *)ne->ne_cookie); +#endif /* DEBUG */ return 0; } return ESTALE; @@ -1428,17 +1454,18 @@ amfs_auto_readdir_browsable(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsen u_int gen = *(u_int *) cookie; int chain_length, i; static nfsentry *te, *te_next; -#ifdef DEBUG_READDIR +#ifdef DEBUG nfsentry *ne; static int j; -#endif /* DEBUG_READDIR */ +#endif /* DEBUG */ dp->dl_eof = FALSE; /* assume readdir not done */ -#ifdef DEBUG_READDIR - plog(XLOG_INFO, "amfs_auto_readdir_browsable gen=%u, count=%d", - gen, count); -#endif /* DEBUG_READDIR */ +#ifdef DEBUG + amuDebug(D_READDIR) + plog(XLOG_DEBUG, "amfs_auto_readdir_browsable gen=%u, count=%d", + gen, count); +#endif /* DEBUG */ if (gen == 0) { /* @@ -1488,6 +1515,7 @@ amfs_auto_readdir_browsable(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsen ep[1].ne_fileid = mp->am_parent->am_gen; else ep[1].ne_fileid = mp->am_gen; + ep[1].ne_name = ".."; ep[1].ne_nextentry = 0; *(u_int *) ep[1].ne_cookie = DOT_DOT_COOKIE; @@ -1501,10 +1529,11 @@ amfs_auto_readdir_browsable(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsen te = make_entry_chain(mp, dp->dl_entries, fully_browsable); if (!te) return 0; -#ifdef DEBUG_READDIR - for (j=0,ne=te; ne; ne=ne->ne_nextentry) - plog(XLOG_INFO, "gen1 key %4d \"%s\"", j++, ne->ne_name); -#endif /* DEBUG_READDIR */ +#ifdef DEBUG + amuDebug(D_READDIR) + for (j=0,ne=te; ne; ne=ne->ne_nextentry) + plog(XLOG_DEBUG, "gen1 key %4d \"%s\"", j++, ne->ne_name); +#endif /* DEBUG */ /* return only "chain_length" entries */ te_next = te; @@ -1522,13 +1551,15 @@ amfs_auto_readdir_browsable(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsen dp->dl_eof = TRUE; /* tell readdir that's it */ } ep[1].ne_nextentry = te; /* append this chunk of "te" chain */ -#ifdef DEBUG_READDIR - for (j=0,ne=te; ne; ne=ne->ne_nextentry) - plog(XLOG_INFO, "gen2 key %4d \"%s\"", j++, ne->ne_name); - for (j=0,ne=ep; ne; ne=ne->ne_nextentry) - plog(XLOG_INFO, "gen2+ key %4d \"%s\" fi=%d ck=%d", - j++, ne->ne_name, ne->ne_fileid, *(u_int *)ne->ne_cookie); - plog(XLOG_INFO, "EOF is %d", dp->dl_eof); +#ifdef DEBUG + amuDebug(D_READDIR) { + for (j=0,ne=te; ne; ne=ne->ne_nextentry) + plog(XLOG_DEBUG, "gen2 key %4d \"%s\"", j++, ne->ne_name); + for (j=0,ne=ep; ne; ne=ne->ne_nextentry) + plog(XLOG_DEBUG, "gen2+ key %4d \"%s\" fi=%d ck=%d", + j++, ne->ne_name, ne->ne_fileid, *(u_int *)ne->ne_cookie); + plog(XLOG_DEBUG, "EOF is %d", dp->dl_eof); + } #endif /* DEBUG_READDIR */ return 0; } /* end of "if (gen == 0)" statement */ @@ -1579,12 +1610,14 @@ amfs_auto_readdir_browsable(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsen } ep = te; /* send next chunk of "te" chain */ dp->dl_entries = ep; -#ifdef DEBUG_READDIR - plog(XLOG_INFO, "dl_entries=0x%x, te_next=0x%x, dl_eof=%d", - (int) dp->dl_entries, (int) te_next, dp->dl_eof); - for (ne=te; ne; ne=ne->ne_nextentry) - plog(XLOG_INFO, "gen3 key %4d \"%s\"", j++, ne->ne_name); -#endif /* DEBUG_READDIR */ +#ifdef DEBUG + amuDebug(D_READDIR) { + plog(XLOG_DEBUG, "dl_entries=0x%lx, te_next=0x%lx, dl_eof=%d", + (long) dp->dl_entries, (long) te_next, dp->dl_eof); + for (ne=te; ne; ne=ne->ne_nextentry) + plog(XLOG_DEBUG, "gen3 key %4d \"%s\"", j++, ne->ne_name); + } +#endif /* DEBUG */ return 0; } diff --git a/contrib/amd/amd/amfs_direct.c b/contrib/amd/amd/amfs_direct.c index 475f3883a4e7..dad917b77e28 100644 --- a/contrib/amd/amd/amfs_direct.c +++ b/contrib/amd/amd/amfs_direct.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: amfs_direct.c,v 1.2 1999/01/10 21:53:41 ezk Exp $ + * $Id: amfs_direct.c,v 1.3.2.1 2001/01/10 03:23:00 ezk Exp $ * */ diff --git a/contrib/amd/amd/amfs_error.c b/contrib/amd/amd/amfs_error.c index 4d4d865df480..cf711869d13a 100644 --- a/contrib/amd/amd/amfs_error.c +++ b/contrib/amd/amd/amfs_error.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: amfs_error.c,v 1.2 1999/01/10 21:53:41 ezk Exp $ + * $Id: amfs_error.c,v 1.3.2.2 2001/01/12 23:28:56 ro Exp $ * */ @@ -56,7 +56,7 @@ #include <am_defs.h> #include <amd.h> -static char * amfs_error_match(am_opts *fo); +static char *amfs_error_match(am_opts *fo); static int amfs_error_fmount(mntfs *mf); static int amfs_error_fumount(mntfs *mf); static void amfs_error_umounted(am_node *mp); diff --git a/contrib/amd/amd/amfs_host.c b/contrib/amd/amd/amfs_host.c index 71b08df179b5..082016cce9c0 100644 --- a/contrib/amd/amd/amfs_host.c +++ b/contrib/amd/amd/amfs_host.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: amfs_host.c,v 1.3 1999/01/13 23:30:57 ezk Exp $ + * $Id: amfs_host.c,v 1.4.2.4 2001/05/19 02:00:58 ib42 Exp $ * */ @@ -204,7 +204,7 @@ sortfun(const voidp x, const voidp y) * Get filehandle */ static int -fetch_fhandle(CLIENT * client, char *dir, am_nfs_handle_t *fhp, u_long nfs_version) +fetch_fhandle(CLIENT *client, char *dir, am_nfs_handle_t *fhp, u_long nfs_version) { struct timeval tv; enum clnt_stat clnt_stat; @@ -256,8 +256,7 @@ fetch_fhandle(CLIENT * client, char *dir, am_nfs_handle_t *fhp, u_long nfs_versi (SVC_IN_ARG_TYPE) &fhp->v2, tv); if (clnt_stat != RPC_SUCCESS) { - const char *msg = clnt_sperrno(clnt_stat); - plog(XLOG_ERROR, "mountd rpc failed: %s", msg); + plog(XLOG_ERROR, "mountd rpc failed: %s", clnt_sperrno(clnt_stat)); return EIO; } /* Check status of filehandle */ @@ -403,7 +402,6 @@ amfs_host_fmount(mntfs *mf) * Figure out how many exports were returned */ for (n_export = 0, ex = exlist; ex; ex = ex->ex_next) { - /* printf("export %s\n", ex->ex_dir); */ n_export++; } @@ -415,7 +413,10 @@ amfs_host_fmount(mntfs *mf) ep = (exports *) xmalloc(n_export * sizeof(exports)); for (j = 0, ex = exlist; ex; ex = ex->ex_next) { make_mntpt(mntpt, ex, mf); - if (!already_mounted(mlist, mntpt)) + if (already_mounted(mlist, mntpt)) + /* we have at least one mounted f/s, so don't fail the mount */ + ok = TRUE; + else ep[j++] = ex; } n_export = j; diff --git a/contrib/amd/amd/amfs_inherit.c b/contrib/amd/amd/amfs_inherit.c index 891afeae492e..905254a86264 100644 --- a/contrib/amd/amd/amfs_inherit.c +++ b/contrib/amd/amd/amfs_inherit.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: amfs_inherit.c,v 1.2 1999/01/10 21:53:41 ezk Exp $ + * $Id: amfs_inherit.c,v 1.3.2.1 2001/01/10 03:23:01 ezk Exp $ * */ diff --git a/contrib/amd/amd/amfs_link.c b/contrib/amd/amd/amfs_link.c index fcb142d32e04..6e357e1c880f 100644 --- a/contrib/amd/amd/amfs_link.c +++ b/contrib/amd/amd/amfs_link.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: amfs_link.c,v 1.2 1999/01/10 21:53:42 ezk Exp $ + * $Id: amfs_link.c,v 1.3.2.1 2001/01/10 03:23:02 ezk Exp $ * */ diff --git a/contrib/amd/amd/amfs_linkx.c b/contrib/amd/amd/amfs_linkx.c index 728597f0be13..5e77cc94d7b6 100644 --- a/contrib/amd/amd/amfs_linkx.c +++ b/contrib/amd/amd/amfs_linkx.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: amfs_linkx.c,v 1.2 1999/01/10 21:53:42 ezk Exp $ + * $Id: amfs_linkx.c,v 1.3.2.1 2001/01/10 03:23:02 ezk Exp $ * */ diff --git a/contrib/amd/amd/amfs_nfsl.c b/contrib/amd/amd/amfs_nfsl.c index 42e01023e6a8..4b193fb99c1d 100644 --- a/contrib/amd/amd/amfs_nfsl.c +++ b/contrib/amd/amd/amfs_nfsl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: amfs_nfsl.c,v 1.3 1999/01/10 21:53:42 ezk Exp $ + * $Id: amfs_nfsl.c,v 1.4.2.1 2001/01/10 03:23:02 ezk Exp $ * */ diff --git a/contrib/amd/amd/amfs_nfsx.c b/contrib/amd/amd/amfs_nfsx.c index a253e5060989..098970f009db 100644 --- a/contrib/amd/amd/amfs_nfsx.c +++ b/contrib/amd/amd/amfs_nfsx.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: amfs_nfsx.c,v 1.2 1999/01/10 21:53:42 ezk Exp $ + * $Id: amfs_nfsx.c,v 1.3.2.2 2001/04/14 21:08:20 ezk Exp $ * */ @@ -149,7 +149,7 @@ amfs_nfsx_match(am_opts *fo) */ xmtab = str3cat((char *) 0, fo->opt_rhost, ":", fo->opt_rfs); #ifdef DEBUG - dlog("NFS: mounting remote server \"%s\", remote fs \"%s\" on \"%s\"", + dlog("NFSX: mounting remote server \"%s\", remote fs \"%s\" on \"%s\"", fo->opt_rhost, fo->opt_rfs, fo->opt_fs); #endif /* DEBUG */ diff --git a/contrib/amd/amd/amfs_program.c b/contrib/amd/amd/amfs_program.c index fd032311ad31..3067a9343cea 100644 --- a/contrib/amd/amd/amfs_program.c +++ b/contrib/amd/amd/amfs_program.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: amfs_program.c,v 1.5 1999/09/30 21:01:30 ezk Exp $ + * $Id: amfs_program.c,v 1.6.2.1 2001/01/10 03:23:03 ezk Exp $ * */ diff --git a/contrib/amd/amd/amfs_root.c b/contrib/amd/amd/amfs_root.c index 91f770dec792..4abd23fb9c46 100644 --- a/contrib/amd/amd/amfs_root.c +++ b/contrib/amd/amd/amfs_root.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: amfs_root.c,v 1.2 1999/01/10 21:53:43 ezk Exp $ + * $Id: amfs_root.c,v 1.3.2.1 2001/01/10 03:23:03 ezk Exp $ * */ diff --git a/contrib/amd/amd/amfs_toplvl.c b/contrib/amd/amd/amfs_toplvl.c index 5d07f62d90f2..29d35a6bfb77 100644 --- a/contrib/amd/amd/amfs_toplvl.c +++ b/contrib/amd/amd/amfs_toplvl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: amfs_toplvl.c,v 1.5 1999/02/04 07:24:14 ezk Exp $ + * $Id: amfs_toplvl.c,v 1.7.2.2 2001/04/14 21:08:20 ezk Exp $ * */ @@ -275,10 +275,10 @@ amfs_toplvl_mount(am_node *mp) mnttype = "indirect"; else if (mf->mf_ops == &amfs_direct_ops) mnttype = "direct"; -#ifdef HAVE_AM_FS_UNION +#ifdef HAVE_AMU_FS_UNION else if (mf->mf_ops == &amfs_union_ops) mnttype = "union"; -#endif /* HAVE_AM_FS_UNION */ +#endif /* HAVE_AMU_FS_UNION */ else mnttype = "auto"; @@ -309,7 +309,7 @@ amfs_toplvl_mount(am_node *mp) error = mount_amfs_toplvl(mf->mf_mount, opts); if (error) { errno = error; - plog(XLOG_FATAL, "mount_amfs_toplvl: %m"); + plog(XLOG_FATAL, "amfs_toplvl_mount: mount_amfs_toplvl failed: %m"); return error; } return 0; diff --git a/contrib/amd/amd/amfs_union.c b/contrib/amd/amd/amfs_union.c index 6e079a4f131c..08c420647124 100644 --- a/contrib/amd/amd/amfs_union.c +++ b/contrib/amd/amd/amfs_union.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: amfs_union.c,v 1.2 1999/01/10 21:53:43 ezk Exp $ + * $Id: amfs_union.c,v 1.3.2.2 2001/04/14 21:08:21 ezk Exp $ * */ @@ -92,7 +92,7 @@ create_amfs_union_node(char *dir, voidp arg) (void) amfs_toplvl_ops.lookuppn(arg, dir, &error, VLOOK_CREATE); if (error > 0) { errno = error; /* XXX */ - plog(XLOG_ERROR, "Could not mount %s: %m", dir); + plog(XLOG_ERROR, "unionfs: could not mount %s: %m", dir); } return error; } diff --git a/contrib/amd/amd/amq_subr.c b/contrib/amd/amd/amq_subr.c index c75fd16d975d..eea1d252e954 100644 --- a/contrib/amd/amd/amq_subr.c +++ b/contrib/amd/amd/amq_subr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: amq_subr.c,v 1.5 1999/08/24 21:31:06 ezk Exp $ + * $Id: amq_subr.c,v 1.6.2.2 2001/01/12 22:43:42 ro Exp $ * */ /* @@ -171,90 +171,6 @@ amqproc_getmntfs_1_svc(voidp argp, struct svc_req *rqstp) return (amq_mount_info_list *) &mfhead; /* XXX */ } -#ifdef ENABLE_AMQ_MOUNT -/* - * This is code that is vulnerable to IP spoofing attacks. Unless you - * absolutely need it, I suggest you do not enable it - * (using configure --enable-amq-mount) - */ -static int -ok_security(struct svc_req *rqstp) -{ - struct sockaddr_in *sin = (struct sockaddr_in *) NULL; - - if ((sin = amu_svc_getcaller(rqstp->rq_xprt)) == NULL) { - plog(XLOG_ERROR, "amu_svc_getcaller returned NULL"); - return(0); /* assume security is therefore not OK */ - } - - if (ntohs(sin->sin_port) >= IPPORT_RESERVED || - !(sin->sin_addr.s_addr == htonl(0x7f000001) || - sin->sin_addr.s_addr == myipaddr.s_addr)) { - char dq[20]; - plog(XLOG_INFO, "AMQ request from %s.%d DENIED", - inet_dquad(dq, sin->sin_addr.s_addr), - ntohs(sin->sin_port)); - return (0); - } - - return (1); -} - - -int * -amqproc_mount_1_svc(voidp argp, struct svc_req *rqstp) -{ - static int rc = EINVAL; - char s[AMQ_STRLEN]; - char *cp; - char dq[20]; - struct sockaddr_in *sin; - - if ((sin = amu_svc_getcaller(rqstp->rq_xprt)) == NULL) { - plog(XLOG_ERROR, "amu_svc_getcaller returned NULL"); - return &rc; - } - - strncpy(s, *(amq_string *) argp, AMQ_STRLEN-1); - s[AMQ_STRLEN-1] = '\0'; /* null terminate, to be sure */ - plog(XLOG_ERROR, - "amq requested mount of %s from %s.%d", - s, inet_dquad(dq, sin->sin_addr.s_addr), - ntohs(sin->sin_port)); - - /* - * Minimalist security check. - */ - if (!ok_security(rqstp)) { - rc = EACCES; - return &rc; - } - /* - * Find end of key - */ - for (cp = (char *) s; *cp && (!isascii(*cp) || !isspace(*cp)); cp++) ; - - if (!*cp) { - plog(XLOG_INFO, "amqproc_mount: Invalid arguments"); - rc = EINVAL; - return &rc; - } - *cp++ = '\0'; - - /* - * Find start of value - */ - while (*cp && isascii(*cp) && isspace(*cp)) - cp++; - - root_newmap(s, cp, (char *) 0, NULL); - rc = mount_auto_node(s, (voidp) root_node); - if (rc < 0) - return 0; - return &rc; -} -#endif /* ENABLE_AMQ_MOUNT */ - amq_string * amqproc_getvers_1_svc(voidp argp, struct svc_req *rqstp) diff --git a/contrib/amd/amd/amq_svc.c b/contrib/amd/amd/amq_svc.c index c22f21978035..6626c40bb1de 100644 --- a/contrib/amd/amd/amq_svc.c +++ b/contrib/amd/amd/amq_svc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: amq_svc.c,v 1.3 1999/08/24 21:31:06 ezk Exp $ + * $Id: amq_svc.c,v 1.4.2.2 2001/01/12 22:43:42 ro Exp $ * */ @@ -59,9 +59,6 @@ amq_program_1(struct svc_req *rqstp, SVCXPRT *transp) amq_string amqproc_mnttree_1_arg; amq_string amqproc_umnt_1_arg; amq_setopt amqproc_setopt_1_arg; -#ifdef ENABLE_AMQ_MOUNT - amq_string amqproc_mount_1_arg; -#endif /* ENABLE_AMQ_MOUNT */ } argument; char *result; xdrproc_t xdr_argument, xdr_result; @@ -111,14 +108,6 @@ amq_program_1(struct svc_req *rqstp, SVCXPRT *transp) local = (amqsvcproc_t) amqproc_getmntfs_1_svc; break; -#ifdef ENABLE_AMQ_MOUNT - case AMQPROC_MOUNT: - xdr_argument = (xdrproc_t) xdr_amq_string; - xdr_result = (xdrproc_t) xdr_int; - local = (amqsvcproc_t) amqproc_mount_1_svc; - break; -#endif /* ENABLE_AMQ_MOUNT */ - case AMQPROC_GETVERS: xdr_argument = (xdrproc_t) xdr_void; xdr_result = (xdrproc_t) xdr_amq_string; diff --git a/contrib/amd/amd/autil.c b/contrib/amd/amd/autil.c index 006c755ac88e..f76b67aa8e5a 100644 --- a/contrib/amd/amd/autil.c +++ b/contrib/amd/amd/autil.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: autil.c,v 1.3 1999/01/10 21:53:44 ezk Exp $ + * $Id: autil.c,v 1.4.2.2 2001/04/29 05:08:35 ib42 Exp $ * */ @@ -219,7 +219,9 @@ forcibly_timeout_mp(am_node *mp) */ if (mf && ((mp->am_flags & AMF_ROOT) || (mf->mf_flags & (MFF_MOUNTING | MFF_UNMOUNTING)))) { - if (!(mf->mf_flags & MFF_UNMOUNTING)) + if (mf->mf_flags & MFF_UNMOUNTING) + plog(XLOG_WARNING, "node %s is currently being unmounted, ignoring timeout request", mp->am_path); + else plog(XLOG_WARNING, "ignoring timeout request for active node %s", mp->am_path); } else { plog(XLOG_INFO, "\"%s\" forcibly timed out", mp->am_path); diff --git a/contrib/amd/amd/clock.c b/contrib/amd/amd/clock.c index 72d471931a4a..64afa3fdf6a0 100644 --- a/contrib/amd/amd/clock.c +++ b/contrib/amd/amd/clock.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: clock.c,v 1.3 1999/01/13 23:30:58 ezk Exp $ + * $Id: clock.c,v 1.4.2.1 2001/01/10 03:23:04 ezk Exp $ * */ diff --git a/contrib/amd/amd/conf.c b/contrib/amd/amd/conf.c index a45e130407ba..b53c5948d8ab 100644 --- a/contrib/amd/amd/conf.c +++ b/contrib/amd/amd/conf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: conf.c,v 1.5 1999/09/30 21:01:30 ezk Exp $ + * $Id: conf.c,v 1.7.2.3 2001/04/14 21:08:21 ezk Exp $ * */ @@ -98,8 +98,10 @@ static int gopt_map_type(const char *val); static int gopt_mount_type(const char *val); static int gopt_pid_file(const char *val); static int gopt_portmap_program(const char *val); +static int gopt_nfs_proto(const char *val); static int gopt_nfs_retransmit_counter(const char *val); static int gopt_nfs_retry_interval(const char *val); +static int gopt_nfs_vers(const char *val); static int gopt_nis_domain(const char *val); static int gopt_normalize_hostnames(const char *val); static int gopt_os(const char *val); @@ -109,7 +111,7 @@ static int gopt_print_pid(const char *val); static int gopt_print_version(const char *val); static int gopt_restart_mounts(const char *val); static int gopt_search_path(const char *val); -static int gopt_selectors_on_default(const char *val); +static int gopt_selectors_in_defaults(const char *val); static int gopt_show_statfs_entries(const char *val); static int gopt_unmount_on_exit(const char *val); static int gopt_vendor(const char *val); @@ -154,8 +156,10 @@ static struct _func_map glob_functable[] = { {"mount_type", gopt_mount_type}, {"pid_file", gopt_pid_file}, {"portmap_program", gopt_portmap_program}, + {"nfs_proto", gopt_nfs_proto}, {"nfs_retransmit_counter", gopt_nfs_retransmit_counter}, {"nfs_retry_interval", gopt_nfs_retry_interval}, + {"nfs_vers", gopt_nfs_vers}, {"nis_domain", gopt_nis_domain}, {"normalize_hostnames", gopt_normalize_hostnames}, {"os", gopt_os}, @@ -165,7 +169,8 @@ static struct _func_map glob_functable[] = { {"print_version", gopt_print_version}, {"restart_mounts", gopt_restart_mounts}, {"search_path", gopt_search_path}, - {"selectors_on_default", gopt_selectors_on_default}, + {"selectors_on_default", gopt_selectors_in_defaults}, + {"selectors_in_defaults", gopt_selectors_in_defaults}, {"show_statfs_entries", gopt_show_statfs_entries}, {"unmount_on_exit", gopt_unmount_on_exit}, {"vendor", gopt_vendor}, @@ -230,7 +235,7 @@ reset_cf_map(cf_map_t *cfm) cfm->cfm_flags = gopt.flags & (CFM_BROWSABLE_DIRS | CFM_BROWSABLE_DIRS_FULL | CFM_MOUNT_TYPE_AUTOFS | - CFM_ENABLE_DEFAULT_SELECTORS); + CFM_SELECTORS_IN_DEFAULTS); } @@ -480,7 +485,7 @@ gopt_ldap_cache_seconds(const char *val) } return 0; #else /* not HAVE_MAP_LDAP */ - fprintf(stderr, "conf: ldap_cache option ignored. No LDAP support available.\n"); + fprintf(stderr, "conf: ldap_cache_seconds option ignored. No LDAP support available.\n"); return 1; #endif /* not HAVE_MAP_LDAP */ } @@ -499,7 +504,7 @@ gopt_ldap_cache_maxmem(const char *val) } return 0; #else /* not HAVE_MAP_LDAP */ - fprintf(stderr, "conf: ldap_cache option ignored. No LDAP support available.\n"); + fprintf(stderr, "conf: ldap_cache_maxmem option ignored. No LDAP support available.\n"); return 1; #endif /* not HAVE_MAP_LDAP */ } @@ -590,7 +595,7 @@ gopt_portmap_program(const char *val) gopt.portmap_program > AMQ_PROGRAM + 10) { gopt.portmap_program = AMQ_PROGRAM; set_amd_program_number(gopt.portmap_program); - fprintf(stderr, "conf: illegal amd program numver \"%s\"\n", val); + fprintf(stderr, "conf: illegal amd program number \"%s\"\n", val); return 1; } @@ -600,6 +605,18 @@ gopt_portmap_program(const char *val) static int +gopt_nfs_proto(const char *val) +{ + if (STREQ(val, "udp") || STREQ(val, "tcp")) { + gopt.nfs_proto = strdup((char *)val); + return 0; + } + fprintf(stderr, "conf: illegal nfs_proto \"%s\"\n", val); + return 1; +} + + +static int gopt_nfs_retransmit_counter(const char *val) { gopt.amfs_auto_retrans = atoi(val); @@ -616,6 +633,20 @@ gopt_nfs_retry_interval(const char *val) static int +gopt_nfs_vers(const char *val) +{ + int i = atoi(val); + + if (i == 2 || i == 3) { + gopt.nfs_vers = i; + return 0; + } + fprintf(stderr, "conf: illegal nfs_vers \"%s\"\n", val); + return 1; +} + + +static int gopt_nis_domain(const char *val) { #ifdef HAVE_MAP_NIS @@ -732,13 +763,13 @@ gopt_search_path(const char *val) static int -gopt_selectors_on_default(const char *val) +gopt_selectors_in_defaults(const char *val) { if (STREQ(val, "yes")) { - gopt.flags |= CFM_ENABLE_DEFAULT_SELECTORS; + gopt.flags |= CFM_SELECTORS_IN_DEFAULTS; return 0; } else if (STREQ(val, "no")) { - gopt.flags &= ~CFM_ENABLE_DEFAULT_SELECTORS; + gopt.flags &= ~CFM_SELECTORS_IN_DEFAULTS; return 0; } diff --git a/contrib/amd/amd/conf_parse.y b/contrib/amd/amd/conf_parse.y index fb426ece5bcf..64006a7467fb 100644 --- a/contrib/amd/amd/conf_parse.y +++ b/contrib/amd/amd/conf_parse.y @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: conf_parse.y,v 1.3 1999/04/16 14:20:59 ezk Exp $ + * $Id: conf_parse.y,v 1.4.2.1 2001/01/10 03:23:05 ezk Exp $ * */ diff --git a/contrib/amd/amd/conf_tok.l b/contrib/amd/amd/conf_tok.l index 0756711ab932..61ab7e448b07 100644 --- a/contrib/amd/amd/conf_tok.l +++ b/contrib/amd/amd/conf_tok.l @@ -1,6 +1,6 @@ %{ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -39,7 +39,7 @@ * * %W% (Berkeley) %G% * - * $Id: conf_tok.l,v 1.2 1999/01/10 21:53:45 ezk Exp $ + * $Id: conf_tok.l,v 1.3.2.1 2001/01/10 03:23:05 ezk Exp $ * */ diff --git a/contrib/amd/amd/get_args.c b/contrib/amd/amd/get_args.c index 6c4445ad8d14..6590326e61ce 100644 --- a/contrib/amd/amd/get_args.c +++ b/contrib/amd/amd/get_args.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: get_args.c,v 1.4 1999/09/30 21:01:31 ezk Exp $ + * $Id: get_args.c,v 1.7.2.1 2001/01/10 03:23:05 ezk Exp $ * */ @@ -85,7 +85,7 @@ get_version_string(void) vers = xmalloc(2048 + wire_buf_len); sprintf(vers, "%s\n%s\n%s\n%s\n", - "Copyright (c) 1997-1999 Erez Zadok", + "Copyright (c) 1997-2001 Erez Zadok", "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."); @@ -334,6 +334,9 @@ get_args(int argc, char *argv[]) if (debug_flags & D_MTAB) dlog("-D mtab option ignored"); # endif /* DEBUG */ +# ifdef MNTTAB_FILE_NAME + mnttab_file_name = MNTTAB_FILE_NAME; +# endif /* MNTTAB_FILE_NAME */ #endif /* not MOUNT_TABLE_ON_FILE */ if (switch_to_logfile(gopt.logfile, orig_umask) != 0) diff --git a/contrib/amd/amd/info_file.c b/contrib/amd/amd/info_file.c index e2357524e422..2978de6080fa 100644 --- a/contrib/amd/amd/info_file.c +++ b/contrib/amd/amd/info_file.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: info_file.c,v 1.2 1999/01/10 21:53:45 ezk Exp $ + * $Id: info_file.c,v 1.3.2.2 2001/01/12 23:28:56 ro Exp $ * */ @@ -62,7 +62,7 @@ int file_mtime(mnt_map *m, char *map, time_t *tp); static int -read_line(char *buf, int size, FILE * fp) +read_line(char *buf, int size, FILE *fp) { int done = 0; @@ -97,7 +97,7 @@ read_line(char *buf, int size, FILE * fp) * Try to locate a key in a file */ static int -search_or_reload_file(FILE * fp, char *map, char *key, char **val, mnt_map *m, void (*fn) (mnt_map *m, char *, char *)) +search_or_reload_file(FILE *fp, char *map, char *key, char **val, mnt_map *m, void (*fn) (mnt_map *m, char *, char *)) { char key_val[MAX_LINE_LEN]; int chuck = 0; diff --git a/contrib/amd/amd/info_hesiod.c b/contrib/amd/amd/info_hesiod.c index 62007d605808..d3e907700a33 100644 --- a/contrib/amd/amd/info_hesiod.c +++ b/contrib/amd/amd/info_hesiod.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: info_hesiod.c,v 1.5 1999/02/04 07:24:15 ezk Exp $ + * $Id: info_hesiod.c,v 1.6.2.1 2001/01/10 03:23:05 ezk Exp $ * */ diff --git a/contrib/amd/amd/info_ldap.c b/contrib/amd/amd/info_ldap.c index a2bd9baeaf6e..35e0d6477ad8 100644 --- a/contrib/amd/amd/info_ldap.c +++ b/contrib/amd/amd/info_ldap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: info_ldap.c,v 1.6 1999/09/30 21:01:31 ezk Exp $ + * $Id: info_ldap.c,v 1.9.2.2 2001/01/12 23:28:56 ro Exp $ * */ @@ -127,24 +127,25 @@ he_free(HE *h) static HE * -string2he(char *s) +string2he(char *s_orig) { char *c, *p; + char *s; HE *new, *old = NULL; - if (s == NULL) - return (NULL); + if (NULL == s_orig || NULL == (s = strdup(s_orig))) + return NULL; for (p = s; p; p = strchr(p, ',')) { if (old != NULL) { - new = (HE *) xmalloc(sizeof(HE)); + new = ALLOC(HE); old->next = new; old = new; } else { - old = (HE *) xmalloc(sizeof(HE)); + old = ALLOC(HE); old->next = NULL; } c = strchr(p, ':'); - if (c) { /* Host and port */ + if (c) { /* Host and port */ *c++ = '\0'; old->host = strdup(p); old->port = atoi(c); @@ -152,6 +153,7 @@ string2he(char *s) old->host = strdup(p); } + XFREE(s); return (old); } @@ -196,8 +198,8 @@ amu_ldap_init(mnt_map *m, char *map, time_t *ts) } #endif /* DEBUG */ - aldh = (ALD *) xmalloc(sizeof(ALD)); - creds = (CR *) xmalloc(sizeof(CR)); + aldh = ALLOC(ALD); + creds = ALLOC(CR); aldh->hostent = string2he(gopt.ldap_hostports); if (aldh->hostent == NULL) { @@ -278,7 +280,7 @@ amu_ldap_rebind(ALD *a) static int -get_ldap_timestamp(LDAP * ld, char *map, time_t *ts) +get_ldap_timestamp(LDAP *ld, char *map, time_t *ts) { struct timeval tv; char **vals, *end; @@ -313,7 +315,7 @@ get_ldap_timestamp(LDAP * ld, char *map, time_t *ts) if (err != LDAP_SUCCESS) { *ts = 0; plog(XLOG_USER, "LDAP timestamp search failed: %s\n", - ldap_err2string(ld->ld_errno)); + ldap_err2string(err)); return (ENOENT); } @@ -413,7 +415,7 @@ amu_ldap_search(mnt_map *m, char *map, char *key, char **pval, time_t *ts) return (ENOENT); default: plog(XLOG_USER, "LDAP search failed: %s\n", - ldap_err2string(a->ldap->ld_errno)); + ldap_err2string(err)); ldap_msgfree(res); return (EIO); } diff --git a/contrib/amd/amd/info_ndbm.c b/contrib/amd/amd/info_ndbm.c index 91cb8e015950..981aea7bd911 100644 --- a/contrib/amd/amd/info_ndbm.c +++ b/contrib/amd/amd/info_ndbm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: info_ndbm.c,v 1.2 1999/01/10 21:53:46 ezk Exp $ + * $Id: info_ndbm.c,v 1.3.2.1 2001/01/10 03:23:06 ezk Exp $ * */ diff --git a/contrib/amd/amd/info_nis.c b/contrib/amd/amd/info_nis.c index 17699d435b57..81e19a372e13 100644 --- a/contrib/amd/amd/info_nis.c +++ b/contrib/amd/amd/info_nis.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: info_nis.c,v 1.5 1999/08/22 05:12:51 ezk Exp $ + * $Id: info_nis.c,v 1.6.2.2 2001/04/14 21:08:21 ezk Exp $ * */ @@ -321,7 +321,7 @@ nis_search(mnt_map *m, char *map, char *key, char **val, time_t *tp) return ENOENT; default: - plog(XLOG_ERROR, "%s: %s", map, yperr_string(res)); + plog(XLOG_ERROR, "nis_search: %s: %s", map, yperr_string(res)); return EIO; } } diff --git a/contrib/amd/amd/info_nisplus.c b/contrib/amd/amd/info_nisplus.c index ea7a3d76f5cd..f954354c440e 100644 --- a/contrib/amd/amd/info_nisplus.c +++ b/contrib/amd/amd/info_nisplus.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: info_nisplus.c,v 1.2 1999/01/10 21:53:46 ezk Exp $ + * $Id: info_nisplus.c,v 1.3.2.2 2001/04/14 21:08:21 ezk Exp $ * */ @@ -207,7 +207,7 @@ nisplus_search(mnt_map *m, char *map, char *key, char **val, time_t *tp) XFREE(index); if (result == NULL) { - plog(XLOG_ERROR, "%s: %s", map, strerror(ENOMEM)); + plog(XLOG_ERROR, "nisplus_search: %s: %s", map, strerror(ENOMEM)); return ENOMEM; } @@ -254,7 +254,7 @@ nisplus_search(mnt_map *m, char *map, char *key, char **val, time_t *tp) break; default: - plog(XLOG_ERROR, "%s: %s", map, nis_sperrno(result->status)); + plog(XLOG_ERROR, "nisplus_search: %s: %s", map, nis_sperrno(result->status)); error = EIO; break; } diff --git a/contrib/amd/amd/info_passwd.c b/contrib/amd/amd/info_passwd.c index d367f3830695..1f19593f471c 100644 --- a/contrib/amd/amd/info_passwd.c +++ b/contrib/amd/amd/info_passwd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: info_passwd.c,v 1.2 1999/01/10 21:53:46 ezk Exp $ + * $Id: info_passwd.c,v 1.3.2.1 2001/01/10 03:23:06 ezk Exp $ * */ diff --git a/contrib/amd/amd/info_union.c b/contrib/amd/amd/info_union.c index d81602b46705..8f608fdf5c30 100644 --- a/contrib/amd/amd/info_union.c +++ b/contrib/amd/amd/info_union.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: info_union.c,v 1.2 1999/01/10 21:53:47 ezk Exp $ + * $Id: info_union.c,v 1.3.2.1 2001/01/10 03:23:07 ezk Exp $ * */ diff --git a/contrib/amd/amd/map.c b/contrib/amd/amd/map.c index 4bfb058b88a9..ebf4894d666d 100644 --- a/contrib/amd/amd/map.c +++ b/contrib/amd/amd/map.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: map.c,v 1.5 1999/08/22 05:12:51 ezk Exp $ + * $Id: map.c,v 1.6.2.3 2001/01/10 03:23:07 ezk Exp $ * */ @@ -65,6 +65,7 @@ * there is no way that 2^32 generation numbers could ever * be allocated by a single run of amd - there is simply * not enough cpu time available. + * Famous last words... -Ion */ static u_int am_gen = 2; /* Initial generation number */ static int timeout_mp_id; /* Id from last call to timeout */ @@ -307,7 +308,7 @@ init_map(am_node *mp, char *dir) { /* * mp->am_mapno is initialized by exported_ap_alloc - * other fields don't need to be set to zero. + * other fields don't need to be initialized. */ mp->am_mnt = new_mntfs(); mp->am_name = strdup(dir); @@ -318,7 +319,7 @@ init_map(am_node *mp, char *dir) mp->am_attr.ns_status = NFS_OK; mp->am_fattr = gen_fattr; mp->am_fattr.na_fsid = 42; - mp->am_fattr.na_fileid = 0; + mp->am_fattr.na_fileid = mp->am_gen; mp->am_fattr.na_atime.nt_seconds = clocktime(); mp->am_fattr.na_atime.nt_useconds = 0; mp->am_fattr.na_mtime = mp->am_fattr.na_ctime = mp->am_fattr.na_atime; @@ -937,6 +938,21 @@ unmount_mp(am_node *mp) int was_backgrounded = 0; mntfs *mf = mp->am_mnt; +#ifndef MNT2_NFS_OPT_SYMTTL + /* + * This code is needed to defeat Solaris 2.4's (and newer) symlink + * values cache. It forces the last-modified time of the symlink to be + * current. It is not needed if the O/S has an nfs flag to turn off the + * symlink-cache at mount time (such as Irix 5.x and 6.x). -Erez. + */ + if (mp->am_parent) { + /* defensive programming... can't we assert the above condition? */ + nfsattrstat *attrp = &mp->am_parent->am_attr; + if (++attrp->ns_u.ns_attr_u.na_mtime.nt_useconds == 0) + ++attrp->ns_u.ns_attr_u.na_mtime.nt_seconds; + } +#endif /* not MNT2_NFS_OPT_SYMTTL */ + #ifdef notdef plog(XLOG_INFO, "\"%s\" on %s timed out", mp->am_path, mp->am_mnt->mf_mount); #endif /* notdef */ diff --git a/contrib/amd/amd/mapc.c b/contrib/amd/amd/mapc.c index e27928bf03d0..865e07a86e53 100644 --- a/contrib/amd/amd/mapc.c +++ b/contrib/amd/amd/mapc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: mapc.c,v 1.5 1999/09/30 21:01:31 ezk Exp $ + * $Id: mapc.c,v 1.7.2.3 2001/04/14 21:08:22 ezk Exp $ * */ @@ -230,7 +230,7 @@ static map_type maptypes[] = NULL, /* isup function */ passwd_search, error_mtime, - MAPC_ALL + MAPC_INC }, #endif /* HAVE_MAP_PASSWD */ #ifdef HAVE_MAP_HESIOD @@ -241,7 +241,7 @@ static map_type maptypes[] = hesiod_isup, /* is Hesiod up or not? */ hesiod_search, error_mtime, - MAPC_ALL + MAPC_INC }, #endif /* HAVE_MAP_HESIOD */ #ifdef HAVE_MAP_LDAP @@ -252,7 +252,7 @@ static map_type maptypes[] = NULL, /* isup function */ amu_ldap_search, amu_ldap_mtime, - MAPC_ALL + MAPC_INC }, #endif /* HAVE_MAP_LDAP */ #ifdef HAVE_MAP_UNION @@ -296,7 +296,7 @@ static map_type maptypes[] = NULL, /* isup function */ ndbm_search, ndbm_mtime, - MAPC_ALL + MAPC_INC }, #endif /* HAVE_MAP_NDBM */ #ifdef HAVE_MAP_FILE @@ -498,26 +498,25 @@ mapc_reload_map(mnt_map *m) { int error; kv *maphash[NKVHASH], *tmphash[NKVHASH]; + time_t t; + + error = (*m->mtime) (m, m->map_name, &t); + if (error) { + t = m->modify; + } /* * skip reloading maps that have not been modified, unless * amq -f was used (do_mapc_reload is 0) */ if (m->reloads != 0 && do_mapc_reload != 0) { - time_t t; - error = (*m->mtime) (m, m->map_name, &t); - if (!error) { - if (t <= m->modify) { + if (t <= m->modify) { plog(XLOG_INFO, "reload of map %s is not needed (in sync)", m->map_name); #ifdef DEBUG dlog("map %s last load time is %d, last modify time is %d", m->map_name, (int) m->modify, (int) t); #endif /* DEBUG */ return; - } else { - /* reload of the map is needed, update map reload time */ - m->modify = t; - } } } @@ -547,6 +546,7 @@ mapc_reload_map(mnt_map *m) memcpy((voidp) m->kvhash, (voidp) maphash, sizeof(m->kvhash)); mapc_clear(m); memcpy((voidp) m->kvhash, (voidp) tmphash, sizeof(m->kvhash)); + m->modify = t; } m->wildcard = 0; @@ -584,7 +584,7 @@ mapc_create(char *map, char *opt, const char *type) mt < maptypes + sizeof(maptypes) / sizeof(maptypes[0]); mt++) { if (STREQ(type, mt->name)) { - plog(XLOG_INFO, "initializing amd conf map %s of type %s", map, type); + plog(XLOG_INFO, "initializing amd.conf map %s of type %s", map, type); if ((*mt->init) (m, map, &modify) == 0) { break; } else { @@ -780,6 +780,7 @@ mapc_meta_search(mnt_map *m, char *key, char **pval, int recurse) plog(XLOG_ERROR, "Null map request for %s", key); return ENOENT; } + if (m->flags & MAPC_SYNC) { /* * Get modify time... @@ -787,7 +788,6 @@ mapc_meta_search(mnt_map *m, char *key, char **pval, int recurse) time_t t; error = (*m->mtime) (m, m->map_name, &t); if (error || t > m->modify) { - m->modify = t; plog(XLOG_INFO, "Map %s is out of date", m->map_name); mapc_sync(m); } @@ -1122,6 +1122,9 @@ make_entry_chain(am_node *mp, const nfsentry *current_chain, int fully_browsable return retval; } + if (mp->am_pref) + preflen = strlen(mp->am_pref); + /* iterate over keys */ for (i = 0; i < NKVHASH; i++) { kv *k; @@ -1142,12 +1145,15 @@ make_entry_chain(am_node *mp, const nfsentry *current_chain, int fully_browsable /* * If the map has a prefix-string then check if the key starts with - * this * string, and if it does, skip over this prefix. + * this string, and if it does, skip over this prefix. If it has a + * prefix and it doesn't match the start of the key, skip it. */ - if (preflen) { + if (preflen && (preflen <= (strlen(key)))) { if (!NSTREQ(key, mp->am_pref, preflen)) continue; key += preflen; + } else if (preflen) { + continue; } /* no more '/' are allowed, unless browsable_dirs=full was used */ diff --git a/contrib/amd/amd/mntfs.c b/contrib/amd/amd/mntfs.c index 7e679595ce1f..e875519b2380 100644 --- a/contrib/amd/amd/mntfs.c +++ b/contrib/amd/amd/mntfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: mntfs.c,v 1.2 1999/01/10 21:53:47 ezk Exp $ + * $Id: mntfs.c,v 1.5.2.1 2001/01/10 03:23:07 ezk Exp $ * */ @@ -174,8 +174,8 @@ find_mntfs(am_ops *ops, am_opts *mo, char *mp, char *info, char *auto_opts, char mf->mf_server = fs; } return dup_mntfs(mf); - } - } + } /* end of "if (STREQ(mf-> ..." */ + } /* end of ITER */ return alloc_mntfs(ops, mo, mp, info, auto_opts, mopts, remopts); } @@ -310,7 +310,9 @@ realloc_mntfs(mntfs *mf, am_ops *ops, am_opts *mo, char *mp, char *info, char *a { mntfs *mf2; - if (mf->mf_refc == 1 && mf->mf_ops == &amfs_inherit_ops && STREQ(mf->mf_mount, mp)) { + if (mf->mf_refc == 1 && + mf->mf_ops == &amfs_inherit_ops && + STREQ(mf->mf_mount, mp)) { /* * If we are inheriting then just return * the same node... @@ -331,5 +333,23 @@ realloc_mntfs(mntfs *mf, am_ops *ops, am_opts *mo, char *mp, char *info, char *a mf2 = find_mntfs(ops, mo, mp, info, auto_opts, mopts, remopts); free_mntfs(mf); +#if 0 + /* + * XXX: EZK IS THIS RIGHT??? + * The next "if" statement is what supposedly fixes bgmount() in + * that it will actually use the ops structure of the next mount + * entry, if the previous one failed. + */ + if (mf2 && + ops && + mf2->mf_ops != ops && + mf2->mf_ops != &amfs_inherit_ops && + mf2->mf_ops != &amfs_toplvl_ops && + mf2->mf_ops != &amfs_error_ops) { + plog(XLOG_WARNING, "realloc_mntfs: copy fallback ops \"%s\" over \"%s\"", + ops->fs_type, mf2->mf_ops->fs_type); + mf2->mf_ops = ops; + } +#endif return mf2; } diff --git a/contrib/amd/amd/nfs_prot_svc.c b/contrib/amd/amd/nfs_prot_svc.c index 7c0048b5094d..19bd4c56a25f 100644 --- a/contrib/amd/amd/nfs_prot_svc.c +++ b/contrib/amd/amd/nfs_prot_svc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: nfs_prot_svc.c,v 1.4 1999/08/22 21:12:30 ezk Exp $ + * $Id: nfs_prot_svc.c,v 1.5.2.2 2001/01/12 23:28:56 ro Exp $ * */ @@ -50,23 +50,23 @@ /* external definitions */ extern voidp nfsproc_null_2_svc(voidp, struct svc_req *); -extern nfsattrstat * nfsproc_getattr_2_svc(am_nfs_fh *, struct svc_req *); -extern nfsattrstat * nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); +extern nfsattrstat *nfsproc_getattr_2_svc(am_nfs_fh *, struct svc_req *); +extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern voidp nfsproc_root_2_svc(voidp, struct svc_req *); -extern nfsdiropres * nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); -extern nfsreadlinkres * nfsproc_readlink_2_svc(am_nfs_fh *, struct svc_req *); -extern nfsreadres * nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); +extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); +extern nfsreadlinkres *nfsproc_readlink_2_svc(am_nfs_fh *, struct svc_req *); +extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern voidp nfsproc_writecache_2_svc(voidp, struct svc_req *); -extern nfsattrstat * nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); -extern nfsdiropres * nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); -extern nfsstat * nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); -extern nfsstat * nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); -extern nfsstat * nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); -extern nfsstat * nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); -extern nfsdiropres * nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); -extern nfsstat * nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); -extern nfsreaddirres * nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); -extern nfsstatfsres * nfsproc_statfs_2_svc(am_nfs_fh *, struct svc_req *); +extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); +extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); +extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); +extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); +extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); +extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); +extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); +extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); +extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); +extern nfsstatfsres *nfsproc_statfs_2_svc(am_nfs_fh *, struct svc_req *); /* global variables */ SVCXPRT *nfs_program_2_transp; diff --git a/contrib/amd/amd/nfs_start.c b/contrib/amd/amd/nfs_start.c index 48d6f06e78ec..5aaea5cc2104 100644 --- a/contrib/amd/amd/nfs_start.c +++ b/contrib/amd/amd/nfs_start.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: nfs_start.c,v 1.4 1999/02/04 07:24:16 ezk Exp $ + * $Id: nfs_start.c,v 1.5.2.1 2001/01/10 03:23:08 ezk Exp $ * */ diff --git a/contrib/amd/amd/nfs_subr.c b/contrib/amd/amd/nfs_subr.c index d06d0085e342..540202ae5651 100644 --- a/contrib/amd/amd/nfs_subr.c +++ b/contrib/amd/amd/nfs_subr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: nfs_subr.c,v 1.3 1999/01/13 23:31:00 ezk Exp $ + * $Id: nfs_subr.c,v 1.6.2.3 2001/04/14 21:08:22 ezk Exp $ * */ @@ -108,6 +108,7 @@ nfsproc_getattr_2_svc(am_nfs_fh *argp, struct svc_req *rqstp) static nfsattrstat res; am_node *mp; int retry; + time_t now = clocktime(); #ifdef DEBUG amuDebug(D_TRACE) @@ -122,33 +123,31 @@ nfsproc_getattr_2_svc(am_nfs_fh *argp, struct svc_req *rqstp) plog(XLOG_DEBUG, "\tretry=%d", retry); #endif /* DEBUG */ - if (retry < 0) + if (retry < 0) { + amd_stats.d_drops++; return 0; + } res.ns_status = nfs_error(retry); } else { nfsattrstat *attrp = &mp->am_attr; #ifdef DEBUG amuDebug(D_TRACE) - plog(XLOG_DEBUG, "\tstat(%s), size = %d", mp->am_path, - (int) attrp->ns_u.ns_attr_u.na_size); + plog(XLOG_DEBUG, "\tstat(%s), size = %d, mtime=%ld", + mp->am_path, + (int) attrp->ns_u.ns_attr_u.na_size, + (long) attrp->ns_u.ns_attr_u.na_mtime.nt_seconds); #endif /* DEBUG */ + /* Delay unmount of what was looked up */ + if (mp->am_timeo_w < 4 * gopt.am_timeo_w) + mp->am_timeo_w += gopt.am_timeo_w; + mp->am_ttl = now + mp->am_timeo_w; + mp->am_stats.s_getattr++; return attrp; } -#ifndef MNT2_NFS_OPT_SYMTTL - /* - * This code is needed to defeat Solaris 2.4's (and newer) symlink values - * cache. It forces the last-modified time of the symlink to be current. - * It is not needed if the O/S has an nfs flag to turn off the - * symlink-cache at mount time (such as Irix 5.x and 6.x). -Erez. - */ - if (++res.ns_u.ns_attr_u.na_mtime.nt_useconds == 0) - ++res.ns_u.ns_attr_u.na_mtime.nt_seconds; -#endif /* not MNT2_NFS_OPT_SYMTTL */ - return &res; } @@ -182,16 +181,26 @@ nfsproc_lookup_2_svc(nfsdiropargs *argp, struct svc_req *rqstp) static nfsdiropres res; am_node *mp; int retry; + uid_t uid; + gid_t gid; #ifdef DEBUG amuDebug(D_TRACE) plog(XLOG_DEBUG, "lookup:"); #endif /* DEBUG */ + /* finally, find the effective uid/gid from RPC request */ + if (getcreds(rqstp, &uid, &gid, nfsxprt) < 0) + plog(XLOG_ERROR, "cannot get uid/gid from RPC credentials"); + sprintf(opt_uid, "%d", (int) uid); + sprintf(opt_gid, "%d", (int) gid); + mp = fh_to_mp2(&argp->da_fhandle, &retry); if (mp == 0) { - if (retry < 0) + if (retry < 0) { + amd_stats.d_drops++; return 0; + } res.dr_status = nfs_error(retry); } else { int error; @@ -203,9 +212,6 @@ nfsproc_lookup_2_svc(nfsdiropargs *argp, struct svc_req *rqstp) ap = (*mp->am_mnt->mf_ops->lookuppn) (mp, argp->da_name, &error, VLOOK_CREATE); if (ap == 0) { if (error < 0) { -#ifdef DEBUG - dlog("Not sending RPC reply"); -#endif /* DEBUG */ amd_stats.d_drops++; return 0; } @@ -289,8 +295,10 @@ nfsproc_readlink_2_svc(am_nfs_fh *argp, struct svc_req *rqstp) mp = fh_to_mp2(argp, &retry); if (mp == 0) { readlink_retry: - if (retry < 0) + if (retry < 0) { + amd_stats.d_drops++; return 0; + } res.rlr_status = nfs_error(retry); } else { char *ln = do_readlink(mp, &retry, (nfsattrstat **) 0); @@ -367,8 +375,10 @@ unlink_or_rmdir(nfsdiropargs *argp, struct svc_req *rqstp, int unlinkp) am_node *mp = fh_to_mp3(&argp->da_fhandle, &retry, VLOOK_DELETE); if (mp == 0) { - if (retry < 0) + if (retry < 0) { + amd_stats.d_drops++; return 0; + } res = nfs_error(retry); goto out; } @@ -500,8 +510,10 @@ nfsproc_readdir_2_svc(nfsreaddirargs *argp, struct svc_req *rqstp) mp = fh_to_mp2(&argp->rda_fhandle, &retry); if (mp == 0) { - if (retry < 0) + if (retry < 0) { + amd_stats.d_drops++; return 0; + } res.rdr_status = nfs_error(retry); } else { #ifdef DEBUG @@ -533,8 +545,10 @@ nfsproc_statfs_2_svc(am_nfs_fh *argp, struct svc_req *rqstp) mp = fh_to_mp2(argp, &retry); if (mp == 0) { - if (retry < 0) + if (retry < 0) { + amd_stats.d_drops++; return 0; + } res.sfr_status = nfs_error(retry); } else { nfsstatfsokres *fp; diff --git a/contrib/amd/amd/ops_TEMPLATE.c b/contrib/amd/amd/ops_TEMPLATE.c index 34fd308571d6..17c55b317a9f 100644 --- a/contrib/amd/amd/ops_TEMPLATE.c +++ b/contrib/amd/amd/ops_TEMPLATE.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: ops_TEMPLATE.c,v 1.2 1999/01/10 21:53:48 ezk Exp $ + * $Id: ops_TEMPLATE.c,v 1.3.2.2 2001/01/12 23:28:57 ro Exp $ * */ @@ -60,18 +60,18 @@ #include <amd.h> /* forward declarations */ -static char * foofs_match(am_opts *fo); +static char *foofs_match(am_opts *fo); static int foofs_init(mntfs *mf); static int foofs_mount(am_node *mp); static int foofs_fmount(mntfs *mf); static int foofs_umount(am_node *mp); static int foofs_fumount(mntfs *mf); -static am_node * foofs_lookuppn(am_node *mp, char *fname, int *error_return, int op); +static am_node *foofs_lookuppn(am_node *mp, char *fname, int *error_return, int op); static int foofs_readdir(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, int count); -static am_node * foofs_readlink(am_node *mp, int *error_return); +static am_node *foofs_readlink(am_node *mp, int *error_return); static void foofs_mounted(mntfs *mf); static void foofs_umounted(am_node *mp); -fserver * foofs_ffserver(mntfs *mf); +fserver *foofs_ffserver(mntfs *mf); /* diff --git a/contrib/amd/amd/ops_autofs.c b/contrib/amd/amd/ops_autofs.c index da77af1f6086..bd0bb122fe03 100644 --- a/contrib/amd/amd/ops_autofs.c +++ b/contrib/amd/amd/ops_autofs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: ops_autofs.c,v 1.4 1999/01/13 23:31:00 ezk Exp $ + * $Id: ops_autofs.c,v 1.7.2.4 2001/04/24 06:17:40 ib42 Exp $ * */ @@ -138,10 +138,10 @@ autofs_mount(am_node *mp) mnttype = "indirect"; else if (mf->mf_ops == &amfs_direct_ops) mnttype = "direct"; -#ifdef HAVE_AM_FS_UNION +#ifdef HAVE_AMU_FS_UNION else if (mf->mf_ops == &amfs_union_ops) mnttype = "union"; -#endif /* HAVE_AM_FS_UNION */ +#endif /* HAVE_AMU_FS_UNION */ else mnttype = "auto"; @@ -510,7 +510,7 @@ out: endfor */ static int -autofs_bgmount(struct continuation * cp, int mpe) +autofs_bgmount(struct continuation *cp, int mpe) { mntfs *mf = cp->mp->am_mnt; /* Current mntfs */ mntfs *mf_retry = 0; /* First mntfs which needed retrying */ @@ -586,7 +586,7 @@ autofs_bgmount(struct continuation * cp, int mpe) * Note whether this is a real mount attempt */ if (p == &amfs_error_ops) { - plog(XLOG_MAP, "Map entry %s for %s failed to match", *cp->ivec, mp->am_path); + plog(XLOG_MAP, "Map entry %s for %s did not match", *cp->ivec, mp->am_path); if (this_error <= 0) this_error = ENOENT; continue; @@ -677,8 +677,6 @@ autofs_bgmount(struct continuation * cp, int mpe) else mk_fattr(mp, NFLNK); - mp->am_fattr.na_fileid = mp->am_gen; - if (p->fs_init) this_error = (*p->fs_init) (mf); } @@ -1122,7 +1120,7 @@ autofs_lookuppn(am_node *mp, char *fname, int *error_return, int op) */ rvec = strsplit(dfl, ' ', '\"'); - if (gopt.flags & CFM_ENABLE_DEFAULT_SELECTORS) { + if (gopt.flags & CFM_SELECTORS_IN_DEFAULTS) { /* * Pick whichever first entry matched the list of selectors. * Strip the selectors from the string, and assign to dfl the @@ -1138,7 +1136,7 @@ autofs_lookuppn(am_node *mp, char *fname, int *error_return, int op) mp->am_parent->am_mnt->mf_info); free_opts(&ap); /* don't leak */ if (pt == &amfs_error_ops) { - plog(XLOG_MAP, "failed to match defaults for \"%s\"", *sp); + plog(XLOG_MAP, "did not match defaults for \"%s\"", *sp); } else { dfl = strip_selectors(*sp, "/defaults"); plog(XLOG_MAP, "matched default selectors \"%s\"", dfl); @@ -1147,7 +1145,7 @@ autofs_lookuppn(am_node *mp, char *fname, int *error_return, int op) ++sp; } } - } else { /* not enable_default_selectors */ + } else { /* not selectors_in_defaults */ /* * Extract first value */ @@ -1161,7 +1159,7 @@ autofs_lookuppn(am_node *mp, char *fname, int *error_return, int op) /* * Log error if there were other values */ - if (!(gopt.flags & CFM_ENABLE_DEFAULT_SELECTORS) && rvec[1]) { + if (!(gopt.flags & CFM_SELECTORS_IN_DEFAULTS) && rvec[1]) { # ifdef DEBUG dlog("/defaults chopped into %s", dfl); # endif /* DEBUG */ diff --git a/contrib/amd/amd/ops_cdfs.c b/contrib/amd/amd/ops_cdfs.c index 0f104d63310b..0fae196fe727 100644 --- a/contrib/amd/amd/ops_cdfs.c +++ b/contrib/amd/amd/ops_cdfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: ops_cdfs.c,v 1.3 1999/03/30 17:22:46 ezk Exp $ + * $Id: ops_cdfs.c,v 1.4.2.1 2001/01/10 03:23:09 ezk Exp $ * */ diff --git a/contrib/amd/amd/ops_efs.c b/contrib/amd/amd/ops_efs.c index 5c8b27edf85d..a8cdd04af38b 100644 --- a/contrib/amd/amd/ops_efs.c +++ b/contrib/amd/amd/ops_efs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: ops_efs.c,v 1.2 1999/01/10 21:53:49 ezk Exp $ + * $Id: ops_efs.c,v 1.3.2.1 2001/01/10 03:23:09 ezk Exp $ * */ diff --git a/contrib/amd/amd/ops_lofs.c b/contrib/amd/amd/ops_lofs.c index a7cccbab0c10..1dbeff80a073 100644 --- a/contrib/amd/amd/ops_lofs.c +++ b/contrib/amd/amd/ops_lofs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: ops_lofs.c,v 1.2 1999/01/10 21:53:49 ezk Exp $ + * $Id: ops_lofs.c,v 1.3.2.2 2001/01/12 23:28:57 ro Exp $ * */ @@ -53,7 +53,7 @@ #include <amd.h> /* forward definitions */ -static char * lofs_match(am_opts *fo); +static char *lofs_match(am_opts *fo); static int lofs_fmount(mntfs *mf); static int lofs_fumount(mntfs *mf); static int mount_lofs(char *dir, char *fs_name, char *opts); diff --git a/contrib/amd/amd/ops_mfs.c b/contrib/amd/amd/ops_mfs.c index 87178b0f5157..468a8aadf15b 100644 --- a/contrib/amd/amd/ops_mfs.c +++ b/contrib/amd/amd/ops_mfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: ops_mfs.c,v 1.2 1999/01/10 21:53:50 ezk Exp $ + * $Id: ops_mfs.c,v 1.3.2.1 2001/01/10 03:23:09 ezk Exp $ * */ diff --git a/contrib/amd/amd/ops_nfs.c b/contrib/amd/amd/ops_nfs.c index 01cdcee787f4..14bf5def38ae 100644 --- a/contrib/amd/amd/ops_nfs.c +++ b/contrib/amd/amd/ops_nfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: ops_nfs.c,v 1.5 1999/03/13 17:03:28 ezk Exp $ + * $Id: ops_nfs.c,v 1.6.2.3 2001/04/14 21:08:22 ezk Exp $ * */ @@ -167,7 +167,7 @@ find_nfs_fhandle_cache(voidp idv, int done) * Called when a filehandle appears */ static void -got_nfs_fh(voidp pkt, int len, struct sockaddr_in * sa, struct sockaddr_in * ia, voidp idv, int done) +got_nfs_fh(voidp pkt, int len, struct sockaddr_in *sa, struct sockaddr_in *ia, voidp idv, int done) { fh_cache *fp; @@ -397,14 +397,14 @@ make_nfs_auth(void) #ifdef HAVE_TRANSPORT_TYPE_TLI if (gopt.flags & CFM_FULLY_QUALIFIED_HOSTS) { - plog(XLOG_INFO, "Using NFS auth for fqhn \"%s\"", hostd); + plog(XLOG_INFO, "Using NFS auth for FQHN \"%s\"", hostd); nfs_auth = authsys_create(hostd, 0, 0, 1, &group_wheel); } else { nfs_auth = authsys_create_default(); } #else /* not HAVE_TRANSPORT_TYPE_TLI */ if (gopt.flags & CFM_FULLY_QUALIFIED_HOSTS) { - plog(XLOG_INFO, "Using NFS auth for fqhn \"%s\"", hostd); + plog(XLOG_INFO, "Using NFS auth for FQHN \"%s\"", hostd); nfs_auth = authunix_create(hostd, 0, 0, 1, &group_wheel); } else { nfs_auth = authunix_create_default(); @@ -664,7 +664,7 @@ mount_nfs_fh(am_nfs_handle_t *fhp, char *dir, char *fs_name, char *opts, mntfs * #ifdef DEBUG amuDebug(D_TRACE) { print_nfs_args(&nfs_args, nfs_version); - plog(XLOG_DEBUG, "Generic mount flags 0x%x", genflags); + plog(XLOG_DEBUG, "Generic mount flags 0x%x used for NFS mount", genflags); } #endif /* DEBUG */ error = mount_fs(&mnt, genflags, (caddr_t) &nfs_args, retry, type, diff --git a/contrib/amd/amd/ops_nfs3.c b/contrib/amd/amd/ops_nfs3.c index 0a9a19805e9a..91b83dedd6bf 100644 --- a/contrib/amd/amd/ops_nfs3.c +++ b/contrib/amd/amd/ops_nfs3.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: ops_nfs3.c,v 1.2 1999/01/10 21:53:50 ezk Exp $ + * $Id: ops_nfs3.c,v 1.3.2.1 2001/01/10 03:23:10 ezk Exp $ * */ diff --git a/contrib/amd/amd/ops_nullfs.c b/contrib/amd/amd/ops_nullfs.c index bd2e5ba6dd8d..e35fb31f8238 100644 --- a/contrib/amd/amd/ops_nullfs.c +++ b/contrib/amd/amd/ops_nullfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: ops_nullfs.c,v 1.2 1999/01/10 21:53:50 ezk Exp $ + * $Id: ops_nullfs.c,v 1.3.2.1 2001/01/10 03:23:10 ezk Exp $ * */ diff --git a/contrib/amd/amd/ops_pcfs.c b/contrib/amd/amd/ops_pcfs.c index bca33ae69604..c7f1e6eae931 100644 --- a/contrib/amd/amd/ops_pcfs.c +++ b/contrib/amd/amd/ops_pcfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: ops_pcfs.c,v 1.2 1999/01/10 21:53:50 ezk Exp $ + * $Id: ops_pcfs.c,v 1.3.2.1 2001/01/10 03:23:10 ezk Exp $ * */ diff --git a/contrib/amd/amd/ops_tfs.c b/contrib/amd/amd/ops_tfs.c index f370eb914358..8dbb91b20742 100644 --- a/contrib/amd/amd/ops_tfs.c +++ b/contrib/amd/amd/ops_tfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: ops_tfs.c,v 1.2 1999/01/10 21:53:51 ezk Exp $ + * $Id: ops_tfs.c,v 1.3.2.1 2001/01/10 03:23:10 ezk Exp $ * */ diff --git a/contrib/amd/amd/ops_tmpfs.c b/contrib/amd/amd/ops_tmpfs.c index 99f47dc6f8a3..e361e466a2ee 100644 --- a/contrib/amd/amd/ops_tmpfs.c +++ b/contrib/amd/amd/ops_tmpfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: ops_tmpfs.c,v 1.2 1999/01/10 21:53:51 ezk Exp $ + * $Id: ops_tmpfs.c,v 1.3.2.1 2001/01/10 03:23:10 ezk Exp $ * */ diff --git a/contrib/amd/amd/ops_ufs.c b/contrib/amd/amd/ops_ufs.c index 0b2ff2dc0806..0b2bc1d1511f 100644 --- a/contrib/amd/amd/ops_ufs.c +++ b/contrib/amd/amd/ops_ufs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: ops_ufs.c,v 1.2 1999/01/10 21:53:51 ezk Exp $ + * $Id: ops_ufs.c,v 1.3.2.1 2001/01/10 03:23:11 ezk Exp $ * */ diff --git a/contrib/amd/amd/ops_umapfs.c b/contrib/amd/amd/ops_umapfs.c index 98629339dcf6..e524517d61af 100644 --- a/contrib/amd/amd/ops_umapfs.c +++ b/contrib/amd/amd/ops_umapfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: ops_umapfs.c,v 1.2 1999/01/10 21:53:51 ezk Exp $ + * $Id: ops_umapfs.c,v 1.3.2.1 2001/01/10 03:23:11 ezk Exp $ * */ diff --git a/contrib/amd/amd/ops_unionfs.c b/contrib/amd/amd/ops_unionfs.c index 2e914a9724df..d0260ce3c96d 100644 --- a/contrib/amd/amd/ops_unionfs.c +++ b/contrib/amd/amd/ops_unionfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: ops_unionfs.c,v 1.2 1999/01/10 21:53:51 ezk Exp $ + * $Id: ops_unionfs.c,v 1.3.2.1 2001/01/10 03:23:11 ezk Exp $ * */ diff --git a/contrib/amd/amd/ops_xfs.c b/contrib/amd/amd/ops_xfs.c index 86ebfa053a1a..83f9641cd833 100644 --- a/contrib/amd/amd/ops_xfs.c +++ b/contrib/amd/amd/ops_xfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: ops_xfs.c,v 1.2 1999/01/10 21:53:52 ezk Exp $ + * $Id: ops_xfs.c,v 1.3.2.2 2001/01/12 23:28:58 ro Exp $ * */ @@ -53,7 +53,7 @@ #include <amd.h> /* forward declarations */ -static char * xfs_match(am_opts *fo); +static char *xfs_match(am_opts *fo); static int xfs_fmount(mntfs *mf); static int xfs_fumount(mntfs *mf); diff --git a/contrib/amd/amd/opts.c b/contrib/amd/amd/opts.c index d564e6914432..2fda3b725117 100644 --- a/contrib/amd/amd/opts.c +++ b/contrib/amd/amd/opts.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: opts.c,v 1.6 1999/09/30 21:01:32 ezk Exp $ + * $Id: opts.c,v 1.8.2.4 2001/01/10 03:23:11 ezk Exp $ * */ @@ -103,7 +103,6 @@ static int f_true(char *); /* * STATICS: */ -static struct am_opts fs_static; /* copy of the options to play with */ static char NullStr[] = "<NULL>"; static char nullstr[] = ""; static char *opt_dkey = NullStr; @@ -113,7 +112,16 @@ static char *opt_key = nullstr; static char *opt_keyd = nullstr; static char *opt_map = nullstr; static char *opt_path = nullstr; +static char uid_str[12], gid_str[12]; +char *opt_uid = uid_str; +char *opt_gid = gid_str; static char *vars[8]; +static char *literal_dollar = "$"; /* ${dollar}: a literal '$' in maps */ + +/* + * GLOBALS + */ +struct am_opts fs_static; /* copy of the options to play with */ /* @@ -122,7 +130,7 @@ static char *vars[8]; */ static struct opt opt_fields[] = { /* Name and length. - Option str. Selector str. boolean fxn. flags */ + Option str. Selector str. boolean fxn. case sensitive */ { S("opts"), &fs_static.opt_opts, 0, 0, FALSE }, { S("host"), @@ -149,8 +157,6 @@ static struct opt opt_fields[] = { &fs_static.opt_dev, 0, 0, FALSE }, { S("pref"), &fs_static.opt_pref, 0, 0, FALSE }, - { S("autopref"), - &fs_static.opt_autopref,0, 0, FALSE }, { S("path"), 0, &opt_path, 0, FALSE }, { S("autodir"), @@ -195,12 +201,19 @@ static struct opt opt_fields[] = { 0, &opt_dkey, 0, FALSE }, { S("key."), 0, &opt_keyd, 0, FALSE }, + /* XXX: should maptype really be a variable? I think selector. -Erez */ { S("maptype"), &fs_static.opt_maptype, 0, 0, FALSE }, { S("cachedir"), &fs_static.opt_cachedir, 0, 0, FALSE }, { S("addopts"), - &fs_static.opt_addopts, 0, 0, FALSE }, + &fs_static.opt_addopts, 0, 0, FALSE }, + { S("uid"), + 0, &opt_uid, 0, FALSE }, + { S("gid"), + 0, &opt_gid, 0, FALSE }, + { S("dollar"), + &literal_dollar, 0, 0, FALSE }, { S("var0"), &vars[0], 0, 0, FALSE }, { S("var1"), @@ -303,7 +316,7 @@ backslash(char **p) if (**p == '\\') { (*p)++; switch (**p) { - case 'a': + case 'g': c = '\007'; /* Bell */ break; case 'b': @@ -856,7 +869,7 @@ normalize_slash(char *p) static void expand_op(opt_apply *p, int sel_p) { - static char expand_error[] = "No space to expand \"%s\""; + static const char expand_error[] = "No space to expand \"%s\""; char expbuf[MAXPATHLEN + 1]; char nbuf[NLEN + 1]; char *ep = expbuf; diff --git a/contrib/amd/amd/restart.c b/contrib/amd/amd/restart.c index bd8e4aade096..cf628ce95a12 100644 --- a/contrib/amd/amd/restart.c +++ b/contrib/amd/amd/restart.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: restart.c,v 1.2 1999/01/10 21:53:52 ezk Exp $ + * $Id: restart.c,v 1.3.2.1 2001/01/10 03:23:12 ezk Exp $ * */ diff --git a/contrib/amd/amd/rpc_fwd.c b/contrib/amd/amd/rpc_fwd.c index 5a74f3b7f735..5422def6823e 100644 --- a/contrib/amd/amd/rpc_fwd.c +++ b/contrib/amd/amd/rpc_fwd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: rpc_fwd.c,v 1.2 1999/01/10 21:53:52 ezk Exp $ + * $Id: rpc_fwd.c,v 1.3.2.2 2001/04/14 21:08:23 ezk Exp $ * */ @@ -187,7 +187,7 @@ fwd_init(void) * Some things we talk to require a priv port - so make one here */ if (bind_resv_port(fwd_sock, (u_short *) 0) < 0) - plog(XLOG_ERROR, "can't bind privileged port"); + plog(XLOG_ERROR, "can't bind privileged port (rpc_fwd)"); if (fcntl(fwd_sock, F_SETFL, FNDELAY) < 0 #ifdef FIONBIO diff --git a/contrib/amd/amd/sched.c b/contrib/amd/amd/sched.c index e5cf6797696c..46346ae63acd 100644 --- a/contrib/amd/amd/sched.c +++ b/contrib/amd/amd/sched.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: sched.c,v 1.3 1999/01/13 23:31:01 ezk Exp $ + * $Id: sched.c,v 1.4.2.2 2001/01/10 03:23:12 ezk Exp $ * */ @@ -219,7 +219,7 @@ do_task_notify(void) /* * Keep taking the first item off the list and processing it. * - * Done this way because the the callback can, quite reasonably, + * Done this way because the callback can, quite reasonably, * queue a new task, so no local reference into the list can be * held here. */ diff --git a/contrib/amd/amd/srvr_amfs_auto.c b/contrib/amd/amd/srvr_amfs_auto.c index a8ddd1765a7b..78c586fe7670 100644 --- a/contrib/amd/amd/srvr_amfs_auto.c +++ b/contrib/amd/amd/srvr_amfs_auto.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: srvr_amfs_auto.c,v 1.2 1999/01/10 21:53:53 ezk Exp $ + * $Id: srvr_amfs_auto.c,v 1.3.2.3 2001/04/14 21:08:23 ezk Exp $ * */ @@ -208,7 +208,8 @@ dup_srvr(fserver *fs) /* * Log state change */ -void srvrlog(fserver *fs, char *state) +void +srvrlog(fserver *fs, char *state) { - plog(XLOG_INFO, "file server %s type %s %s", fs->fs_host, fs->fs_type, state); + plog(XLOG_INFO, "file server %s, type %s, state %s", fs->fs_host, fs->fs_type, state); } diff --git a/contrib/amd/amd/srvr_nfs.c b/contrib/amd/amd/srvr_nfs.c index b204be14735c..f267447b681e 100644 --- a/contrib/amd/amd/srvr_nfs.c +++ b/contrib/amd/amd/srvr_nfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1999 Erez Zadok + * Copyright (c) 1997-2001 Erez Zadok * 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. @@ -38,7 +38,7 @@ * * %W% (Berkeley) %G% * - * $Id: srvr_nfs.c,v 1.5 1999/09/08 23:36:39 ezk Exp $ + * $Id: srvr_nfs.c,v 1.7.2.5 2001/04/14 21:08:23 ezk Exp $ * */ @@ -93,7 +93,13 @@ static int ping_len; static char ping_buf[sizeof(struct rpc_msg) + 32]; #if defined(MNTTAB_OPT_PROTO) || defined(HAVE_FS_NFS3) -/* protocols we know about, in order of preference */ +/* + * Protocols we know about, in order of preference. + * + * Note that Solaris 8 and newer NetBSD systems are switching to UDP first, + * so this order may have to be adjusted for Amd in the future once more + * vendors make that change. -Erez 11/24/2000 + */ static char *protocols[] = { "tcp", "udp", NULL }; #endif /* defined(MNTTAB_OPT_PROTO) || defined(HAVE_FS_NFS3) */ @@ -168,7 +174,7 @@ start_ping(u_long nfs_version) * Called when a portmap reply arrives */ static void -got_portmap(voidp pkt, int len, struct sockaddr_in * sa, struct sockaddr_in * ia, voidp idv, int done) +got_portmap(voidp pkt, int len, struct sockaddr_in *sa, struct sockaddr_in *ia, voidp idv, int done) { fserver *fs2 = (fserver *) idv; fserver *fs = 0; @@ -227,7 +233,7 @@ got_portmap(voidp pkt, int len, struct sockaddr_in * sa, struct sockaddr_in * ia * Obtain portmap information */ static int -call_portmap(fserver *fs, AUTH * auth, u_long prog, u_long vers, u_long prot) +call_portmap(fserver *fs, AUTH *auth, u_long prog, u_long vers, u_long prot) { struct rpc_msg pmap_msg; int len; @@ -301,7 +307,7 @@ recompute_portmap(fserver *fs) * structure when the ping was transmitted. */ static void -nfs_pinged(voidp pkt, int len, struct sockaddr_in * sp, struct sockaddr_in * tsp, voidp idv, int done) +nfs_pinged(voidp pkt, int len, struct sockaddr_in *sp, struct sockaddr_in *tsp, voidp idv, int done) { int xid = (long) idv; /* for 64-bit archs */ fserver *fs; @@ -541,7 +547,7 @@ nfs_keepalive(voidp v) int -nfs_srvr_port(fserver *fs, u_short * port, voidp wchan) +nfs_srvr_port(fserver *fs, u_short *port, voidp wchan) { int error = -1; if ((fs->fs_flags & FSF_VALID) == FSF_VALID) { @@ -644,15 +650,11 @@ find_nfs_srvr(mntfs *mf) #ifdef MNTTAB_OPT_PROTO { - char *proto_opt = hasmntopt(&mnt, MNTTAB_OPT_PROTO); + char *proto_opt = hasmnteq(&mnt, MNTTAB_OPT_PROTO); if (proto_opt) { char **p; - - proto_opt += sizeof(MNTTAB_OPT_PROTO) - 1; /* skip the "proto" */ - for (p = protocols; *p; p ++) - if (proto_opt[0] == '=' && - NSTREQ(&proto_opt[1], *p, strlen(*p))) { + if (NSTREQ(proto_opt, *p, strlen(*p))) { nfs_proto = *p; break; } @@ -668,10 +670,21 @@ find_nfs_srvr(mntfs *mf) if (hasmntopt(&mnt, "nfsv2")) { nfs_version = (u_long) 2; /* nullify any ``vers=X'' statements */ nfs_proto = "udp"; /* nullify any ``proto=tcp'' statements */ - plog(XLOG_WARNING, "found compatiblity option \"nfsv2\": set options vers=2, proto=udp for host %s", host); + plog(XLOG_WARNING, "found compatiblity option \"nfsv2\": set options vers=2,proto=udp for host %s", host); } #endif /* HAVE_NFS_NFSV2_H */ + /* check if we globally overridden the NFS version/protocol */ + if (gopt.nfs_vers) { + nfs_version = gopt.nfs_vers; + plog(XLOG_INFO, "find_nfs_srvr: force NFS version to %d", + (int) nfs_version); + } + if (gopt.nfs_proto) { + nfs_proto = gopt.nfs_proto; + plog(XLOG_INFO, "find_nfs_srvr: force NFS protocol transport to %s", nfs_proto); + } + /* * lookup host address and canonical name */ |