/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
*/
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <syslog.h>
#include <errno.h>
#include <pwd.h>
#include <netdb.h>
#include <locale.h>
#include <stdlib.h>
#include <unistd.h>
#include <thread.h>
#include <fcntl.h>
#include <limits.h>
#include "automount.h"
/*
* This structure is used to determine the hierarchical
* relationship between directories
*/
typedef struct _hiernode {
} hiernode;
void free_mapent(struct mapent *);
char *, char *, uint_t);
static int push_options(hiernode *, char *, char *, int);
static int set_mapent_opts(struct mapent *, char *, char *, char *);
static int fstype_opts(struct mapent *, char *, char *, char *);
static int set_and_fake_mapent_mntlevel(hiernode *, char *, char *, char *,
static int mark_level1_root(hiernode *, char *);
static int mark_and_fake_level1_noroot(hiernode *, char *, char *, char *,
static int convert_mapent_to_automount(struct mapent *, char *, char *);
static int automount_opts(char **, char *);
static int parse_fsinfo(char *, struct mapent *);
int);
static int parse_special(struct mapent *, char *, char *, char **, char **,
int);
static int get_dir_from_path(char *, char **, int);
static int alloc_hiernode(hiernode **, char *);
static void free_hiernode(hiernode *);
static void trace_mapents(char *, struct mapent *);
static void trace_hierarchy(hiernode *, int);
static void freeex_ent(struct exportnode *);
static void freeex(struct exportnode *);
static void dump_mapent_err(struct mapent *, char *, char *);
#define PARSE_OK 0
/*
* mapentry error type defininitions
*/
#define MAPENT_NOERR 0
/*
* parse_entry(char *key, char *mapname, char *mapopts, struct mapline *ml,
* char *subdir, uint_t isdirect, bool_t mount_access)
* Parses the data in ml to build a mapentry list containing the information
* by processing ml, hierarchically sorts (builds a tree of) the list according
* to mountpoint. Then pushes options down the hierarchy, and fills in the mount
* file system. Finally, modifies the intermediate list depending on how far
* in the hierarchy the current request is (uses subdir). Deals with special
* case of /net map parsing.
* Returns a pointer to the head of the mapentry list.
*/
struct mapent *
{
char *p;
if (trace > 1)
/*
* Assure the key is only one token long.
* This prevents options from sneaking in through the
*/
for (p = key; *p != '\0'; p++) {
if (isspace(*p)) {
}
}
/*
* select the appropriate parser, and build the mapentry list
*/
/*
* the /net parser - uses do_mapent_hosts to build mapents.
* The mapopts are considered default for every entry, so we
* don't push options down hierarchies.
*/
return (mapents);
if (trace > 3)
!= PARSE_OK)
goto parse_error;
} else {
/*
* all other parsing
*/
goto parse_error;
return (mapents);
!= PARSE_OK)
goto parse_error;
MAPENT_NOERR) != PARSE_OK)
goto parse_error;
if (trace > 3) {
trace_hierarchy(rootnode, 0);
};
goto parse_error;
}
/*
* Modify the mapentry list. We *must* do this only after
* the mapentry list is completely built (since we need to
* have parse_fsinfo called first).
*/
goto parse_error;
/*
* XXX: its dangerous to use rootnode after modify mapents as
* it may be pointing to mapents that have been freed
*/
return (mapents);
}
/*
* mapline_to_mapent(struct mapent **mapents, struct mapline *ml,
* char *key, char *mapname, char *mapopts, char *defaultopts,
* uint_t isdirect)
* Parses the mapline information in ml word by word to build an intermediate
* mapentry list, which is passed back to the caller. The mapentries may have
* holes (example no options), as they are completed only later. The logic is
* awkward, but needed to provide the supported flexibility in the map entries.
* (especially the first line). Note that the key is the full pathname of the
* directory to be mounted in a direct map, and ml is the mapentry beyond key.
* Returns PARSE_OK or an appropriate error value.
*/
static int
{
char w[MAXPATHLEN];
int implied;
/* do any macro expansions that are required to complete ml */
"mapline_to_mapent: map %s: line too long (max %d chars)",
return (PARSE_ERROR);
}
trace_prt(1,
" mapline_to_mapent: (expanded) mapline (%s,%s)\n",
/* init the head of mapentry list to null */
/*
* Get the first word - its either a '-' if default options provided,
* a '/', if the mountroot is implicitly provided, or a mount filesystem
* if the mountroot is implicit. Note that if the first word begins with
* a '-' then the second must be read and it must be a mountpoint or a
* mount filesystem. Use mapopts if no default opts are provided.
*/
return (PARSE_ERROR);
if (*w == '-') {
strcpy(defaultopts, w);
return (PARSE_ERROR);
} else
/*
* implied is true if there is no '/'
* We need the same code path if we have an smbfs mount.
*/
while (*w == '/' || implied) {
goto alloc_failed;
else
/*
* direct maps get an empty string as root - to be filled
* by the entire path later. Indirect maps get /key as the
* map root. Note that xfn maps don't care about the root
* - they override it in getmapent_fn().
*/
if (isdirect) {
*w1 = '\0';
} else {
}
goto alloc_failed;
/* mntpnt is empty for the mount root */
else
goto alloc_failed;
/*
* If implied, the word must be a mount filesystem,
* and its already read in; also turn off implied - its
* not applicable except for the mount root. Else,
* read another (or two) words depending on if there's
* an option.
*/
if (implied) /* must be a mount filesystem */
implied = 0;
else {
return (PARSE_ERROR);
if (w[0] == '-') {
/* mount options */
goto alloc_failed;
sizeof (w)) == -1)
return (PARSE_ERROR);
}
}
/*
* must be a mount filesystem or a set of filesystems at
* this point.
*/
if (w[0] == '\0' || w[0] == '-') {
"mapline_to_mapent: bad location=%s map=%s key=%s",
return (PARSE_ERROR);
}
/*
* map_fsw and map_fswq hold information which will be
* used to determine filesystem information at a later
* point. This is required since we can only find out
* about the mount file system after the directories
* are hierarchically sorted and options have been pushed
* down the hierarchies.
*/
goto alloc_failed;
/*
* the next word, if any, is either another mount point or a
* mount filesystem if more than one server is listed.
*/
return (PARSE_ERROR);
while (*w && *w != '/') { /* more than 1 server listed */
int len;
goto alloc_failed;
goto alloc_failed;
return (PARSE_ERROR);
}
/* initialize flags */
}
if (verbose) {
"mapline_to_mapent: parsed with null mapents");
else
"mapline_to_mapent: parsed nononempty w=%s", w);
}
return (PARSE_ERROR);
}
if (trace > 3)
return (PARSE_OK);
return (ENOMEM);
}
/*
* hierarchical_sort(struct mapent *mapents, hiernode **rootnode, char *key
* char *mapname)
* sorts the mntpnts in each mapent to build a hierarchy of nodes, with
* with the rootnode being the mount root. The hierarchy is setup as
* levels, and subdirs below each level. Provides a link from node to
* the relevant mapentry.
* Returns PARSE_OK or appropriate error value
*/
static int
char *mapname)
{
char *path;
/* allocate the rootnode with a default path of "" */
return (rc);
/*
* walk through mapents - for each mapent, locate the position
* within the hierarchy by walking across leveldirs, and
* subdirs of matched leveldirs. Starts one level below
* the root (assumes an implicit match with rootnode).
* XXX - this could probably be done more cleanly using recursion.
*/
return (rc);
while (dirname[0] != '\0') {
/*
* match found - mntpnt is a child of
* this node
*/
} else {
/*
* No more leveldirs to match.
* Add a new one
*/
if ((rc = alloc_hiernode
!= PARSE_OK)
return (rc);
} else {
/* try this leveldir */
continue;
}
}
} else {
/* no more subdirs to match. Add a new one */
return (rc);
}
return (rc);
}
/* duplicate mntpoint found */
"hierarchical_sort: duplicate mntpnt map=%s key=%s",
return (PARSE_ERROR);
}
/* provide a pointer from node to mapent */
}
if (trace > 3) {
}
return (rc);
}
/*
* push_options(hiernode *node, char *opts, char *mapopts, int err)
* Pushes the options down a hierarchical structure. Works recursively from the
* root, which is passed in on the first call. Uses a replacement policy.
* If a node points to a mapentry, and it has an option, then thats the option
* for that mapentry. Else, the node's mapent inherits the option from the
* default (which may be the global option for the entry or mapopts).
* err is useful in flagging entries with errors in pushing options.
* returns PARSE_OK or appropriate error value.
*/
static int
{
/* ensure that all the dirs at a level are passed the default options */
return (rc);
}
/* push the options to subdirs */
MNTTYPE_AUTOFS) == 0)
err = MAPENT_UATFS;
return (rc);
}
}
return (rc);
}
/*
* set_mapent_opts(struct mapent *me, char *opts, char *defaultopts,
* char *mapopts)
* sets the mapentry's options, fstype and mounter fields by separating
* out the fstype part from the opts. Use default options if opts is NULL.
* Note taht defaultopts may be the same as mapopts.
* Returns PARSE_OK or appropriate error value.
*/
static int
char *mapopts)
{
/* set options to default options, if none exist for this entry */
opts = defaultopts;
goto done;
}
}
if (*opts == '-')
opts++;
/* separate opts into fstype and (other) entrypopts */
/* replace any existing opts */
return (ENOMEM);
/*
* child options are exactly fstype = somefs, we need to do some
* more option pushing work.
*/
if (fstype_opt == TRUE &&
return (rc);
}
done:
return (ENOMEM);
}
return (rc);
}
/*
* Check the option string for an "fstype"
* option. If found, return the fstype
* and the option string with the fstype
* option removed, e.g.
*
* input: "fstype=nfs,ro,nosuid"
* opts: "ro,nosuid"
* fstype: "nfs"
*
* Also indicates if the fstype option was present
* by setting a flag, if the pointer to the flag
* is not NULL.
*/
static void
char *input;
char *opts; /* output */
char *fstype; /* output */
{
char *p, *pb;
char *placeholder;
*opts = '\0';
if (fstype_opt != NULL)
*fstype_opt = TRUE;
} else {
if (*opts)
}
}
}
/*
* fstype_opts(struct mapent *me, char *opts, char *defaultopts,
* char *mapopts)
* We need to push global options to the child entry if it is exactly
* fstype=somefs.
*/
static int
char *mapopts)
{
defaultopts++;
/*
* the options to push are the global defaults for the entry,
* if they exist, or mapopts, if the global defaults for the
* entry does not exist.
*/
if (*mapopts == '-')
mapopts++;
} else {
}
if (!me->map_mntopts) {
return (ENOMEM);
}
return (PARSE_OK);
}
/*
* modify_mapents(struct mapent **mapents, char *mapname,
* char *mapopts, char *subdir, hiernode *rootnode,
* char *key, uint_t isdirect, bool_t mount_access)
* modifies the intermediate mapentry list into the final one, and passes
* back a pointer to it. The final list may contain faked mapentries for
* hiernodes that do not point to a mapentry, or converted mapentries, if
* hiernodes that point to a mapentry need to be converted from nfs to autofs.
* mounts. Entries that are not directly 1 level below the subdir are removed.
* Returns PARSE_OK or PARSE_ERROR
*/
static int
{
char w[MAXPATHLEN];
/*
* correct the mapentry mntlevel from default -1 to level depending on
* position in hierarchy, and build any faked mapentries, if required
* at one level below the rootnode given by subdir.
*/
return (rc);
/*
* attaches faked mapents to real mapents list. Assumes mapents
* is not NULL.
*/
/*
* get rid of nodes marked at level -1
*/
/*
* syslog any errors and free entry
*/
/* special case when head has to be freed */
/* something wierd happened */
if (verbose)
"modify_mapents: level error");
return (PARSE_ERROR);
}
/* separate out the node */
} else {
}
continue;
}
/*
* convert level 1 mapents that are not already autonodes
* to autonodes
*/
return (rc);
}
}
if (trace > 3)
return (PARSE_OK);
}
/*
* set_and_fake_mapent_mntlevel(hiernode *rootnode, char *subdir, char *key,
* char *mapname, struct mapent **faked_mapents,
* uint_t isdirect, char *mapopts, bool_t mount_access)
* sets the mapentry mount levels (depths) with respect to the subdir.
* Assigns a value of 0 to the new root. Finds the level1 directories by
* calling mark_*_level1_*(). Also cleans off extra /'s in level0 and
* level1 map_mntpnts. Note that one level below the new root is an existing
* mapentry if there's a mapentry (nfs mount) corresponding to the root,
* and the direct subdir set for the root, if there's no mapentry corresponding
* to the root (we install autodirs). Returns PARSE_OK or error value.
*/
static int
{
traversed_path[0] = '\0';
/*
* find and mark the root by tracing down subdir. Use traversed_path
* to keep track of how far we go, while guaranteeing that it
* contains no '/' at the end. Took some mucking to get that right.
*/
!= PARSE_OK)
return (rc);
if (dirname[0] != '\0')
/* subdir is a child of currnode */
return (rc);
if (dirname[0] != '\0')
} else {
/* try next leveldir */
}
}
if (dirname[0] != '\0') {
if (verbose)
"set_and_fake_mapent_mntlevel: subdir=%s error: map=%s",
return (PARSE_ERROR);
}
/*
* see if level of root really points to a mapent and if
* have access to that filessystem - call appropriate
* routine to mark level 1 nodes, and build faked entries
*/
if (trace > 3)
/*
* Copy traversed path map_mntpnt to get rid of any extra
* '/' the map entry may contain.
*/
if (verbose)
"set_and_fake_mapent_mntlevel: path=%s error",
return (PARSE_ERROR);
}
traversed_path)) != PARSE_OK)
return (rc);
}
if (trace > 3)
return (rc);
}
if (trace > 3) {
trace_hierarchy(rootnode, 0);
}
return (rc);
}
/*
* mark_level1_root(hiernode *node, char *traversed_path)
* marks nodes upto one level below the rootnode given by subdir
* recursively. Called if rootnode points to a mapent.
* In this routine, a level 1 node is considered to be the 1st existing
* mapentry below the root node, so there's no faking involved.
* Returns PARSE_OK or error value
*/
static int
{
/* ensure we touch all leveldirs */
while (node) {
/*
* mark node level as 1, if one exists - else walk down
* subdirs until we find one.
*/
char w[MAXPATHLEN];
== PARSE_ERROR)
return (PARSE_ERROR);
} else {
if (verbose) {
"mark_level1_root: hierarchy error");
}
return (PARSE_ERROR);
}
} else {
char w[MAXPATHLEN];
if (trace > 3)
/* replace mntpnt with travpath to clean extra '/' */
if (verbose) {
"mark_level1_root: path=%s error",
}
return (PARSE_ERROR);
}
}
}
return (PARSE_OK);
}
/*
* mark_and_fake_level1_noroot(hiernode *node, char *traversed_path,
* char *key,char *mapname, struct mapent **faked_mapents,
* uint_t isdirect, char *mapopts)
* Called if the root of the hierarchy does not point to a mapent. marks nodes
* upto one physical level below the rootnode given by subdir. checks if
* there's a real mapentry. If not, it builds a faked one (autonode) at that
* point. The faked autonode is direct, with the map being the same as the
* original one from which the call originated. Options are same as that of
* the map and assigned in automount_opts(). Returns PARSE_OK or error value.
*/
static int
{
int rc = 0;
char w[MAXPATHLEN];
/*
* existing mapentry at level 1 - copy travpath to
* get rid of extra '/' in mntpnt
*/
if (trace > 3)
/* sanity check */
if (verbose)
"mark_fake_level1_noroot:path=%s error",
return (PARSE_ERROR);
}
} else {
/*
* build the faked autonode
*/
== NULL) {
"mark_and_fake_level1_noroot: out of memory");
return (ENOMEM);
}
return (ENOMEM);
if (isdirect) {
*w1 = '\0';
} else {
}
/* set options */
!= PARSE_OK)
return (rc);
"mark_and_fake_level1_noroot: out of memory");
return (ENOMEM);
}
if (*faked_mapents == NULL)
*faked_mapents = me;
else { /* attach to the head */
*faked_mapents = me;
}
}
}
return (rc);
}
/*
* convert_mapent_to_automount(struct mapent *me, char *mapname,
* char *mapopts)
* change the mapentry me to an automount - free fields first and NULL them
* to avoid freeing again, while freeing the mapentry at a later stage.
* Could have avoided freeing entries here as we don't really look at them.
* Give the converted mapent entry the options that came with the map using
* automount_opts(). Returns PARSE_OK or appropriate error value.
*/
static int
char *mapopts)
{
/* free relevant entries */
}
}
/* replace relevant entries */
if (me->map_fstype)
goto alloc_failed;
if (me->map_mounter)
goto alloc_failed;
goto alloc_failed;
/* set options */
if (me->map_mntopts)
return (rc);
/* mucked with this entry, set the map_modified field to TRUE */
return (rc);
"convert_mapent_to_automount: Memory allocation failed");
return (ENOMEM);
}
/*
* automount_opts(char **map_mntopts, char *mapopts)
* modifies automount opts - gets rid of all "indirect" and "direct" strings
* if they exist, and then adds a direct string to force a direct automount.
* Rest of the mapopts stay intact. Returns PARSE_OK or appropriate error.
*/
static int
{
char *opts;
char *opt;
int len;
char *placeholder;
if (len > AUTOFS_MAXOPTSLEN) {
"option string %s too long (max=%d)", mapopts,
return (PARSE_ERROR);
}
return (ENOMEM);
}
/* remove trailing and leading spaces */
opt++;
/*
* if direct or indirect found, get rid of it, else put it
* back
*/
continue;
if (*map_mntopts[0] != '\0')
}
/* add the direct string at the end */
if (*map_mntopts[0] != '\0')
return (PARSE_OK);
}
/*
* parse_fsinfo(char *mapname, struct mapent *mapents)
* parses the filesystem information stored in me->map_fsw and me->map_fswq
* and calls appropriate filesystem parser.
* Returns PARSE_OK or an appropriate error value.
*/
static int
{
char *bufp;
char *bufq;
int err = 0;
bufp = "";
bufq = "";
} else {
}
/* sanity check */
if (verbose)
"parse_fsinfo: mount location error %s",
return (PARSE_ERROR);
}
}
if (trace > 3) {
}
return (PARSE_OK);
}
/*
* This function parses the map entry for a nfs type file system
* The input is the string lp (and lq) which can be one of the
* following forms:
* a) host[(penalty)][,host[(penalty)]]... :/directory
* b) host[(penalty)]:/directory[ host[(penalty)]:/directory]...
* This routine constructs a mapfs link-list for each of
* the hosts and the corresponding file system. The list
* is then attatched to the mapent struct passed in.
*/
int
int wsize;
{
int penalty;
char w[MAXPATHLEN];
int host_cnt;
/*
* there may be more than one entry in the map list. Get the
* first one. Use temps to handle the word information and
* copy back into fsw and fswq fields when done.
*/
return (PARSE_ERROR);
while (*w && *w != '/') {
sizeof (hostlist)) == -1)
return (PARSE_ERROR);
if (!*hostlist)
goto bad_entry;
sizeof (dirname)) == -1)
return (PARSE_ERROR);
if (*dirname == '\0')
goto bad_entry;
/*
* See the next block comment ("Once upon a time ...") to
* understand this. It turns the deprecated concept
* of "subdir mounts" produced some useful code for handling
* the possibility of a ":port#" in the URL.
*/
*subdir = '/';
else
*subdir = ':';
*qbuff = ' ';
/*
* Once upon time, before autofs, there was support for
* "subdir mounts". The idea was to "economize" the
* number of mounts, so if you had a number of entries
* all referring to a common subdirectory, e.g.
*
*
* then you could tell the automounter to mount a
* common mountpoint which was delimited by the second
* colon:
*
*
* then for any other map entry that referenced the same
* directory it would build a symbolic link that
* appended the remainder of the path after the second
* colon, i.e. once the common subdir was mounted, then
* other directories could be accessed just by link
* building - no further mounts required.
*
* In theory the "mount saving" idea sounded good. In
* practice the saving didn't amount to much and the
* symbolic links confused people because the common
* mountpoint had to have a pseudonym.
*
* To remain backward compatible with the existing
* maps, we interpret a second colon as a slash.
*/
sizeof (subdir)) == -1)
return (PARSE_ERROR);
if (*(subdir+1))
host_cnt = 0;
for (;;) {
sizeof (hostname_and_penalty)) == -1)
return (PARSE_ERROR);
if (!*hostname_and_penalty)
break;
host_cnt++;
if (host_cnt > 1)
sizeof (hostname)) == -1)
return (PARSE_ERROR);
if (hostname[0] == '\0')
goto bad_entry;
penalty = 0;
} else {
sizeof (pbuff)) == -1)
return (PARSE_ERROR);
if (!*pbuff)
penalty = 0;
else
}
"parse_nfs: Memory allocation failed");
return (PARSE_ERROR);
}
char *host;
char *path;
char *sport;
"parse_nfs: illegal nfs url syntax: %s",
host);
return (PARSE_ERROR);
}
*path = '\0';
*sport = '\0';
"parse_nfs: invalid "
"port number (%d) in "
"NFS URL",
return (PARSE_ERROR);
}
}
path++;
if (*path == '\0')
path = ".";
} else {
}
"parse_nfs: Memory allocation failed");
return (PARSE_ERROR);
}
}
/*
* We check host_cnt to make sure we haven't parsed an entry
* with no host information.
*/
if (host_cnt == 0) {
"parse_nfs: invalid host specified - bad entry "
"in map %s \"%s\"",
mapname, w);
return (PARSE_ERROR);
}
return (PARSE_ERROR);
}
return (PARSE_OK);
return (PARSE_ERROR);
}
static int
int wsize;
{
wlp = w;
return (PARSE_ERROR);
if (devname[0] == '\0')
return (PARSE_ERROR);
return (PARSE_ERROR);
/*
* A device name that begins with a slash could
* be confused with a mountpoint path, hence use
* a colon to escape a device string that begins
* with a slash, e.g.
*
* foo -ro /bar foo:/bar
* and
*
* would confuse the parser. The second instance
* must use a colon:
*
*/
return (PARSE_ERROR);
return (PARSE_ERROR);
return (0);
}
/*
* get_dir_from_path(char *dir, char **path, int dirsz)
* gets the directory name dir from path for max string of length dirsz.
* A modification of the getword routine. Assumes the delimiter is '/'
* and that excess /'s are redundant.
* Returns PARSE_OK or PARSE_ERROR
*/
static int
{
if (dirsz <= 0) {
if (verbose)
"get_dir_from_path: invalid directory size %d", dirsz);
return (PARSE_ERROR);
}
/* get rid of leading /'s in path */
while (**path == '/')
(*path)++;
/* now at a word or at the end of path */
if (--count <= 0) {
*tmp = '\0';
"get_dir_from_path: max pathlength exceeded %d", dirsz);
return (PARSE_ERROR);
}
}
*dir = '\0';
/* get rid of trailing /'s in path */
while (**path == '/')
(*path)++;
return (PARSE_OK);
}
/*
* alloc_hiernode(hiernode **newnode, char *dirname)
* allocates a new hiernode corresponding to a new directory entry
* in the hierarchical structure, and passes a pointer to it back
* to the calling program.
* Returns PARSE_OK or appropriate error value.
*/
static int
{
return (ENOMEM);
}
return (PARSE_OK);
}
/*
* free_hiernode(hiernode *node)
* frees the allocated hiernode given the head of the structure
* recursively calls itself until it frees entire structure.
* Returns nothing.
*/
static void
{
}
}
/*
* free_mapent(struct mapent *)
* free the mapentry and its fields
*/
void
{
struct mapent *m;
while (me) {
}
if (me->map_mntpnt)
if (me->map_mntopts)
if (me->map_fstype)
if (me->map_mounter)
m = me;
free((char *)m);
}
}
/*
* trace_mapents(struct mapent *mapents)
* traces through the mapentry structure and prints it element by element
* returns nothing
*/
static void
{
trace_prt(0, "\t\t%s:%s\n",
}
}
/*
* trace_hierarchy(hiernode *node)
* traces the allocated hiernode given the head of the structure
* recursively calls itself until it traces entire structure.
* the first call made at the root is made with a zero level.
* nodelevel is simply used to print tab and make the tracing clean.
* Returns nothing.
*/
static void
{
int i;
for (i = 0; i < nodelevel; i++)
trace_prt(0, "\t");
trace_prt(0, "\t(%s, ",
trace_prt(0, "%d, %s)\n",
}
else
trace_prt(0, " ,)\n");
nodelevel++;
} else {
for (i = 0; i < nodelevel; i++)
trace_prt(0, "\t");
trace_prt(0, "\t(%s, ",
trace_prt(0, "%d, %s)\n",
}
else
trace_prt(0, ", )\n");
}
}
}
struct mapent *
{
int foundvers;
if (trace > 1)
/* check for special case: host is me */
if (self_check(host)) {
goto alloc_failed;
goto alloc_failed;
goto alloc_failed;
goto alloc_failed;
if (isdirect)
name[0] = '\0';
else {
}
goto alloc_failed;
goto alloc_failed;
goto alloc_failed;
goto alloc_failed;
goto alloc_failed;
/* initialize mntlevel and modify */
if (trace > 1)
trace_prt(1,
" do_mapent_hosts: self-host %s OK\n", host);
return (ms);
}
/*
* Call pingnfs. Note that we can't have replicated hosts in /net.
* XXX - we would like to avoid duplicating the across the wire calls
* made here in nfsmount(). The pingnfs cache should help avoid it.
*/
if (!foundvers)
nfsvers = 0;
}
/* get export list of host */
}
}
#ifdef MALLOC_DEBUG
#endif
if (retries-- > 0) {
goto retry;
}
"do_mapent_hosts: %s: export list: %s",
#ifdef MALLOC_DEBUG
#endif
}
#ifdef MALLOC_DEBUG
#endif
if (trace > 1)
trace_prt(1,
gettext(" getmapent_hosts: null export list\n"));
}
/* now sort by length of names - to get mount order right */
#ifdef lint
#endif
duplicate = 0;
break;
if (duplicate) {
/* disregard duplicate entry */
freeex_ent(ex);
break;
}
}
if (!duplicate) {
}
}
/* Now create a mapent from the export list */
goto alloc_failed;
else
if (isdirect)
name[0] = '\0';
else {
}
goto alloc_failed;
*name = '\0';
}
goto alloc_failed;
goto alloc_failed;
goto alloc_failed;
goto alloc_failed;
goto alloc_failed;
goto alloc_failed;
goto alloc_failed;
/* initialize mntlevel and modify values */
}
if (trace > 1)
return (ms);
}
static void
struct exportnode *ex;
{
while (groups) {
}
}
static void
struct exportnode *ex;
{
while (ex) {
freeex_ent(ex);
}
}
/*
* dump_mapent_err(struct mapent *me, char *key, char *mapname)
* syslog appropriate error in mapentries.
*/
{
case MAPENT_NOERR:
if (verbose)
"map=%s key=%s mntpnt=%s: no error");
break;
case MAPENT_UATFS:
"mountpoint %s in map %s key %s not mounted: %s",
break;
default:
if (verbose)
"map=%s key=%s mntpnt=%s: unknown mapentry error");
}
}