1*31bdb48aSchristos /* $NetBSD: amd.h,v 1.1.1.3 2015/01/17 16:34:15 christos Exp $ */ 2a53f50b9Schristos 3a53f50b9Schristos /* 4*31bdb48aSchristos * Copyright (c) 1997-2014 Erez Zadok 5a53f50b9Schristos * Copyright (c) 1990 Jan-Simon Pendry 6a53f50b9Schristos * Copyright (c) 1990 Imperial College of Science, Technology & Medicine 7a53f50b9Schristos * Copyright (c) 1990 The Regents of the University of California. 8a53f50b9Schristos * All rights reserved. 9a53f50b9Schristos * 10a53f50b9Schristos * This code is derived from software contributed to Berkeley by 11a53f50b9Schristos * Jan-Simon Pendry at Imperial College, London. 12a53f50b9Schristos * 13a53f50b9Schristos * Redistribution and use in source and binary forms, with or without 14a53f50b9Schristos * modification, are permitted provided that the following conditions 15a53f50b9Schristos * are met: 16a53f50b9Schristos * 1. Redistributions of source code must retain the above copyright 17a53f50b9Schristos * notice, this list of conditions and the following disclaimer. 18a53f50b9Schristos * 2. Redistributions in binary form must reproduce the above copyright 19a53f50b9Schristos * notice, this list of conditions and the following disclaimer in the 20a53f50b9Schristos * documentation and/or other materials provided with the distribution. 21*31bdb48aSchristos * 3. Neither the name of the University nor the names of its contributors 22a53f50b9Schristos * may be used to endorse or promote products derived from this software 23a53f50b9Schristos * without specific prior written permission. 24a53f50b9Schristos * 25a53f50b9Schristos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26a53f50b9Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27a53f50b9Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28a53f50b9Schristos * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29a53f50b9Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30a53f50b9Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31a53f50b9Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32a53f50b9Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33a53f50b9Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34a53f50b9Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35a53f50b9Schristos * SUCH DAMAGE. 36a53f50b9Schristos * 37a53f50b9Schristos * 38a53f50b9Schristos * File: am-utils/amd/amd.h 39a53f50b9Schristos * 40a53f50b9Schristos */ 41a53f50b9Schristos 42a53f50b9Schristos #ifndef _AMD_H 43a53f50b9Schristos #define _AMD_H 44a53f50b9Schristos 45a53f50b9Schristos 46a53f50b9Schristos /* 47a53f50b9Schristos * MACROS: 48a53f50b9Schristos */ 49a53f50b9Schristos 50a53f50b9Schristos /* 51a53f50b9Schristos * Define a default debug mtab path for systems 52a53f50b9Schristos * that support mtab on file. 53a53f50b9Schristos */ 54a53f50b9Schristos #ifdef MOUNT_TABLE_ON_FILE 55a53f50b9Schristos # define DEBUG_MNTTAB_FILE "/tmp/mtab" 56a53f50b9Schristos #endif /* MOUNT_TABLE_ON_FILE */ 57a53f50b9Schristos 58a53f50b9Schristos /* Max line length that info services can handle */ 59a53f50b9Schristos #define INFO_MAX_LINE_LEN 1500 60a53f50b9Schristos 61a53f50b9Schristos /* options for amd.conf */ 62a53f50b9Schristos #define CFM_BROWSABLE_DIRS 0x00000001 63a53f50b9Schristos #define CFM_MOUNT_TYPE_AUTOFS 0x00000002 /* use kernel autofs support */ 64a53f50b9Schristos #define CFM_SELECTORS_IN_DEFAULTS 0x00000004 65a53f50b9Schristos #define CFM_NORMALIZE_HOSTNAMES 0x00000008 66a53f50b9Schristos #define CFM_PROCESS_LOCK 0x00000010 67a53f50b9Schristos #define CFM_PRINT_PID 0x00000020 68a53f50b9Schristos #define CFM_RESTART_EXISTING_MOUNTS 0x00000040 69a53f50b9Schristos #define CFM_SHOW_STATFS_ENTRIES 0x00000080 70a53f50b9Schristos #define CFM_FULLY_QUALIFIED_HOSTS 0x00000100 71a53f50b9Schristos #define CFM_BROWSABLE_DIRS_FULL 0x00000200 /* allow '/' in readdir() */ 72a53f50b9Schristos #define CFM_UNMOUNT_ON_EXIT 0x00000400 /* when amd finishing */ 73a53f50b9Schristos #define CFM_USE_TCPWRAPPERS 0x00000800 74a53f50b9Schristos #define CFM_AUTOFS_USE_LOFS 0x00001000 75a53f50b9Schristos #define CFM_NFS_INSECURE_PORT 0x00002000 76a53f50b9Schristos #define CFM_DOMAIN_STRIP 0x00004000 77a53f50b9Schristos #define CFM_NORMALIZE_SLASHES 0x00008000 /* normalize slashes? */ 78a53f50b9Schristos #define CFM_FORCED_UNMOUNTS 0x00010000 /* forced unmounts? */ 79a53f50b9Schristos #define CFM_TRUNCATE_LOG 0x00020000 /* truncate log file? */ 80a53f50b9Schristos #define CFM_SUN_MAP_SYNTAX 0x00040000 /* Sun map syntax? */ 81a53f50b9Schristos #define CFM_NFS_ANY_INTERFACE 0x00080000 /* all interfaces are acceptable */ 82a53f50b9Schristos 83a53f50b9Schristos /* defaults global flags: plock, tcpwrappers, and autofs/lofs */ 84a53f50b9Schristos #define CFM_DEFAULT_FLAGS (CFM_PROCESS_LOCK|CFM_USE_TCPWRAPPERS|CFM_AUTOFS_USE_LOFS|CFM_DOMAIN_STRIP|CFM_NORMALIZE_SLASHES) 85a53f50b9Schristos 86a53f50b9Schristos /* 87a53f50b9Schristos * macro definitions for automounter vfs/vnode operations. 88a53f50b9Schristos */ 89a53f50b9Schristos #define VLOOK_CREATE 0x1 90a53f50b9Schristos #define VLOOK_DELETE 0x2 91a53f50b9Schristos #define VLOOK_LOOKUP 0x3 92a53f50b9Schristos 93a53f50b9Schristos /* 94a53f50b9Schristos * macro definitions for automounter vfs capabilities 95a53f50b9Schristos */ 96a53f50b9Schristos #define FS_DIRECTORY 0x0001 /* This looks like a dir, not a link */ 97a53f50b9Schristos #define FS_MBACKGROUND 0x0002 /* Should background this mount */ 98a53f50b9Schristos #define FS_NOTIMEOUT 0x0004 /* Don't bother with timeouts */ 99a53f50b9Schristos #define FS_MKMNT 0x0008 /* Need to make the mount point */ 100a53f50b9Schristos #define FS_UBACKGROUND 0x0010 /* Unmount in background */ 101a53f50b9Schristos #define FS_BACKGROUND (FS_MBACKGROUND|FS_UBACKGROUND) 102a53f50b9Schristos #define FS_DISCARD 0x0020 /* Discard immediately on last reference */ 103a53f50b9Schristos #define FS_AMQINFO 0x0040 /* Amq is interested in this fs type */ 104a53f50b9Schristos #define FS_AUTOFS 0x0080 /* This filesystem can be an autofs f/s */ 105a53f50b9Schristos #define FS_DIRECT 0x0100 /* Direct mount */ 106a53f50b9Schristos #define FS_ON_AUTOFS 0x0200 /* This filesystem can be mounted directly 107a53f50b9Schristos onto an autofs mountpoint */ 108a53f50b9Schristos 109a53f50b9Schristos /* 110a53f50b9Schristos * macros for struct am_node (map of auto-mount points). 111a53f50b9Schristos */ 112a53f50b9Schristos #define AMF_NOTIMEOUT 0x0001 /* This node never times out */ 113a53f50b9Schristos #define AMF_ROOT 0x0002 /* This is a root node */ 114a53f50b9Schristos #define AMF_AUTOFS 0x0004 /* This node is part of an autofs filesystem */ 115a53f50b9Schristos #define AMF_REMOUNT 0x0008 /* This node needs to be remounted */ 116a53f50b9Schristos #define AMF_SOFTLOOKUP 0x0010 /* This node returns EIO if server is down */ 117a53f50b9Schristos 118a53f50b9Schristos /* 119a53f50b9Schristos * macros for struct mntfs (list of mounted filesystems) 120a53f50b9Schristos */ 121a53f50b9Schristos #define MFF_MOUNTED 0x0001 /* Node is mounted */ 122a53f50b9Schristos #define MFF_MOUNTING 0x0002 /* Mount is in progress */ 123a53f50b9Schristos #define MFF_UNMOUNTING 0x0004 /* Unmount is in progress */ 124a53f50b9Schristos #define MFF_RESTART 0x0008 /* Restarted node */ 125a53f50b9Schristos #define MFF_MKMNT 0x0010 /* Delete this node's am_mount */ 126a53f50b9Schristos #define MFF_ERROR 0x0020 /* This node failed to mount */ 127a53f50b9Schristos #define MFF_LOGDOWN 0x0040 /* Logged that this mount is down */ 128a53f50b9Schristos #define MFF_RSTKEEP 0x0080 /* Don't timeout this filesystem - restarted */ 129a53f50b9Schristos #define MFF_WANTTIMO 0x0100 /* Need a timeout call when not busy */ 130a53f50b9Schristos #define MFF_NFSLINK 0x0200 /* nfsl type, and deemed a link */ 131a53f50b9Schristos #define MFF_IS_AUTOFS 0x0400 /* this filesystem is of type autofs */ 132a53f50b9Schristos #define MFF_NFS_SCALEDOWN 0x0800 /* the mount failed, retry with v2/UDP */ 133a53f50b9Schristos #define MFF_ON_AUTOFS 0x1000 /* autofs has a lofs/link to this f/s */ 134a53f50b9Schristos #define MFF_WEBNFS 0x2000 /* use public filehandle */ 135a53f50b9Schristos 136a53f50b9Schristos /* 137a53f50b9Schristos * macros for struct fserver. 138a53f50b9Schristos */ 139a53f50b9Schristos #define FSF_VALID 0x0001 /* Valid information available */ 140a53f50b9Schristos #define FSF_DOWN 0x0002 /* This fileserver is thought to be down */ 141a53f50b9Schristos #define FSF_ERROR 0x0004 /* Permanent error has occurred */ 142a53f50b9Schristos #define FSF_WANT 0x0008 /* Want a wakeup call */ 143a53f50b9Schristos #define FSF_PINGING 0x0010 /* Already doing pings */ 144a53f50b9Schristos #define FSF_WEBNFS 0x0020 /* Don't try to contact portmapper */ 145a53f50b9Schristos #define FSF_PING_UNINIT 0x0040 /* ping values have not been initilized */ 146a53f50b9Schristos #define FSF_FORCE_UNMOUNT 0x0080 /* force umount of this fserver */ 147a53f50b9Schristos #define FSRV_ERROR(fs) ((fs) && (((fs)->fs_flags & FSF_ERROR) == FSF_ERROR)) 148a53f50b9Schristos #define FSRV_ISDOWN(fs) ((fs) && (((fs)->fs_flags & (FSF_DOWN|FSF_VALID)) == (FSF_DOWN|FSF_VALID))) 149a53f50b9Schristos #define FSRV_ISUP(fs) (!(fs) || (((fs)->fs_flags & (FSF_DOWN|FSF_VALID)) == (FSF_VALID))) 150a53f50b9Schristos 151a53f50b9Schristos /* some systems (SunOS 4.x) neglect to define the mount null message */ 152a53f50b9Schristos #ifndef MOUNTPROC_NULL 153a53f50b9Schristos # define MOUNTPROC_NULL ((u_long)(0)) 154a53f50b9Schristos #endif /* not MOUNTPROC_NULL */ 155a53f50b9Schristos 156a53f50b9Schristos /* 157a53f50b9Schristos * Error to return if remote host is not available. 158a53f50b9Schristos * Try, in order, "host down", "host unreachable", "invalid argument". 159a53f50b9Schristos */ 160a53f50b9Schristos #ifdef EHOSTDOWN 161a53f50b9Schristos # define AM_ERRNO_HOST_DOWN EHOSTDOWN 162a53f50b9Schristos #else /* not EHOSTDOWN */ 163a53f50b9Schristos # ifdef EHOSTUNREACH 164a53f50b9Schristos # define AM_ERRNO_HOST_DOWN EHOSTUNREACH 165a53f50b9Schristos # else /* not EHOSTUNREACH */ 166a53f50b9Schristos # define AM_ERRNO_HOST_DOWN EINVAL 167a53f50b9Schristos # endif /* not EHOSTUNREACH */ 168a53f50b9Schristos #endif /* not EHOSTDOWN */ 169a53f50b9Schristos 170a53f50b9Schristos /* Hash table size */ 171a53f50b9Schristos #define NKVHASH (1 << 2) /* Power of two */ 172a53f50b9Schristos 173a53f50b9Schristos /* Max entries to return in one call */ 174a53f50b9Schristos #define MAX_READDIR_ENTRIES 16 175a53f50b9Schristos 176a53f50b9Schristos /* 177a53f50b9Schristos * default amfs_auto retrans - 1/10th seconds 178a53f50b9Schristos */ 179a53f50b9Schristos #define AMFS_AUTO_RETRANS(x) ((ALLOWED_MOUNT_TIME*10+5*gopt.amfs_auto_timeo[(x)])/gopt.amfs_auto_timeo[(x)] * 2) 180a53f50b9Schristos 181a53f50b9Schristos /* 182a53f50b9Schristos * The following values can be tuned... 183a53f50b9Schristos */ 184a53f50b9Schristos #define AM_TTL (300) /* Default cache period (5 min) */ 185a53f50b9Schristos #define AM_TTL_W (120) /* Default unmount interval (2 min) */ 186a53f50b9Schristos #define AM_PINGER 30 /* NFS ping interval for live systems */ 187a53f50b9Schristos #define AMFS_AUTO_TIMEO 8 /* Default amfs_auto timeout - .8s */ 188a53f50b9Schristos #define AMFS_EXEC_MAP_TIMEOUT 10 /* default 10sec exec map timeout */ 189a53f50b9Schristos 190a53f50b9Schristos /* interval between forced retries of a mount */ 191a53f50b9Schristos #define RETRY_INTERVAL 2 192a53f50b9Schristos 193a53f50b9Schristos #ifndef ROOT_MAP 194a53f50b9Schristos # define ROOT_MAP "\"root\"" 195a53f50b9Schristos #endif /* not ROOT_MAP */ 196a53f50b9Schristos 197a53f50b9Schristos #define ereturn(x) do { *error_return = x; return 0; } while (0) 198a53f50b9Schristos 199a53f50b9Schristos #define NEVER (time_t) 0 200a53f50b9Schristos 201a53f50b9Schristos #if defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) 202a53f50b9Schristos # define AMD_SERVICE_NAME "amd" /* for tcpwrappers */ 203a53f50b9Schristos #endif /* defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) */ 204a53f50b9Schristos 205a53f50b9Schristos /* 206a53f50b9Schristos * TYPEDEFS: 207a53f50b9Schristos */ 208a53f50b9Schristos 209a53f50b9Schristos typedef struct cf_map cf_map_t; 210a53f50b9Schristos typedef struct kv kv; 211a53f50b9Schristos typedef struct am_node am_node; 212a53f50b9Schristos typedef struct mntfs mntfs; 213*31bdb48aSchristos typedef struct am_loc am_loc; 214a53f50b9Schristos typedef struct am_opts am_opts; 215a53f50b9Schristos typedef struct am_ops am_ops; 216a53f50b9Schristos typedef struct am_stats am_stats; 217a53f50b9Schristos typedef struct fserver fserver; 218a53f50b9Schristos 219a53f50b9Schristos typedef voidp wchan_t; 220a53f50b9Schristos typedef voidp opaque_t; 221a53f50b9Schristos 222a53f50b9Schristos /* 223a53f50b9Schristos * Cache map operations 224a53f50b9Schristos */ 225a53f50b9Schristos typedef void add_fn(mnt_map *, char *, char *); 226a53f50b9Schristos typedef int init_fn(mnt_map *, char *, time_t *); 227a53f50b9Schristos typedef int mtime_fn(mnt_map *, char *, time_t *); 228a53f50b9Schristos typedef int isup_fn(mnt_map *, char *); 229a53f50b9Schristos typedef int reload_fn(mnt_map *, char *, add_fn *); 230a53f50b9Schristos typedef int search_fn(mnt_map *, char *, char *, char **, time_t *); 231a53f50b9Schristos typedef int task_fun(opaque_t); 232a53f50b9Schristos typedef void cb_fun(int, int, opaque_t); 233a53f50b9Schristos typedef void fwd_fun(voidp, int, struct sockaddr_in *, 234a53f50b9Schristos struct sockaddr_in *, opaque_t, int); 235a53f50b9Schristos typedef int key_fun(char *, opaque_t); 236a53f50b9Schristos typedef void callout_fun(opaque_t); 237a53f50b9Schristos 238a53f50b9Schristos /* 239a53f50b9Schristos * automounter vfs/vnode operations. 240a53f50b9Schristos */ 241a53f50b9Schristos typedef char *(*vfs_match) (am_opts *); 242a53f50b9Schristos typedef int (*vfs_init) (mntfs *); 243a53f50b9Schristos typedef int (*vmount_fs) (am_node *, mntfs *); 244a53f50b9Schristos typedef int (*vumount_fs) (am_node *, mntfs *); 245a53f50b9Schristos typedef am_node *(*vlookup_child) (am_node *, char *, int *, int); 246a53f50b9Schristos typedef am_node *(*vmount_child) (am_node *, int *); 247*31bdb48aSchristos typedef int (*vreaddir) (am_node *, voidp, voidp, voidp, u_int); 248a53f50b9Schristos typedef am_node *(*vreadlink) (am_node *, int *); 249a53f50b9Schristos typedef void (*vmounted) (mntfs *); 250a53f50b9Schristos typedef void (*vumounted) (mntfs *); 251a53f50b9Schristos typedef fserver *(*vffserver) (mntfs *); 252a53f50b9Schristos typedef wchan_t (*vget_wchan) (mntfs *); 253a53f50b9Schristos 254*31bdb48aSchristos /* 255*31bdb48aSchristos * NFS progran dispatcher 256*31bdb48aSchristos */ 257*31bdb48aSchristos typedef void (*dispatcher_t)(struct svc_req *rqstp, SVCXPRT *transp); 258a53f50b9Schristos 259a53f50b9Schristos 260a53f50b9Schristos /* 261a53f50b9Schristos * STRUCTURES: 262a53f50b9Schristos */ 263a53f50b9Schristos 264a53f50b9Schristos /* global amd options that are manipulated by conf.c */ 265a53f50b9Schristos struct amu_global_options { 266a53f50b9Schristos char *arch; /* name of current architecture */ 267a53f50b9Schristos char *auto_dir; /* automounter temp dir */ 268a53f50b9Schristos int auto_attrcache; /* attribute cache timeout for auto dirs */ 269a53f50b9Schristos char *cluster; /* cluster name */ 270a53f50b9Schristos char *karch; /* kernel architecture */ 271a53f50b9Schristos char *logfile; /* amd log file */ 272a53f50b9Schristos char *op_sys; /* operating system name ${os} */ 273a53f50b9Schristos char *op_sys_ver; /* OS version ${osver} */ 274a53f50b9Schristos char *op_sys_full; /* full OS name ${full_os} */ 275a53f50b9Schristos char *op_sys_vendor; /* name of OS vendor ${vendor} */ 276a53f50b9Schristos char *pid_file; /* PID file */ 277a53f50b9Schristos char *sub_domain; /* local domain */ 278a53f50b9Schristos char *localhost_address; /* localhost address (NULL means use 127.0.0.1) */ 279a53f50b9Schristos char *map_defaults; /* global map /default options */ 280a53f50b9Schristos char *map_options; /* global map options */ 281a53f50b9Schristos int map_reload_interval; /* map reload interval */ 282a53f50b9Schristos char *map_type; /* global map type */ 283a53f50b9Schristos char *search_path; /* search path for maps */ 284a53f50b9Schristos char *mount_type; /* mount type for map */ 285a53f50b9Schristos char *debug_mtab_file; /* path for the mtab file during debug mode */ 286a53f50b9Schristos u_int flags; /* various CFM_* flags */ 287a53f50b9Schristos 288a53f50b9Schristos #define AMU_TYPE_NONE -1 /* for amfs_auto_{timeo,retrans,toplvl} */ 289a53f50b9Schristos #define AMU_TYPE_UDP 0 /* for amfs_auto_{timeo,retrans,toplvl} */ 290a53f50b9Schristos #define AMU_TYPE_TCP 1 /* for amfs_auto_{timeo,retrans,toplvl} */ 291a53f50b9Schristos /* 292a53f50b9Schristos * Note: toplvl is only UDP, but we want to separate it from regular 293a53f50b9Schristos * NFS mounts which Amd makes, because the toplvl mount is a localhost 294a53f50b9Schristos * mount for which different timeo/retrans parameters may be desired. 295a53f50b9Schristos */ 296a53f50b9Schristos #define AMU_TYPE_TOPLVL 2 /* for amfs_auto_{timeo,retrans,toplvl} */ 297a53f50b9Schristos #define AMU_TYPE_MAX 3 /* for amfs_auto_{timeo,retrans,toplvl} */ 298a53f50b9Schristos int amfs_auto_retrans[AMU_TYPE_MAX]; /* NFS retransmit counter */ 299a53f50b9Schristos int amfs_auto_timeo[AMU_TYPE_MAX]; /* NFS retry interval */ 300a53f50b9Schristos 301a53f50b9Schristos int am_timeo; /* cache duration */ 302a53f50b9Schristos int am_timeo_w; /* dismount interval */ 303a53f50b9Schristos u_long portmap_program; /* amd RPC program number */ 304a53f50b9Schristos u_short preferred_amq_port; /* preferred amq service RPC port number (0 means "any") */ 305a53f50b9Schristos #ifdef HAVE_MAP_HESIOD 306a53f50b9Schristos char *hesiod_base; /* Hesiod rhs */ 307a53f50b9Schristos #endif /* HAVE_MAP_HESIOD */ 308a53f50b9Schristos #ifdef HAVE_MAP_LDAP 309a53f50b9Schristos char *ldap_base; /* LDAP base */ 310a53f50b9Schristos char *ldap_hostports; /* LDAP host ports */ 311a53f50b9Schristos long ldap_cache_seconds; /* LDAP internal cache - keep seconds */ 312a53f50b9Schristos long ldap_cache_maxmem; /* LDAP internal cache - max memory (bytes) */ 313a53f50b9Schristos long ldap_proto_version; /* LDAP protocol version */ 314a53f50b9Schristos #endif /* HAVE_MAP_LDAP */ 315a53f50b9Schristos #ifdef HAVE_MAP_NIS 316a53f50b9Schristos char *nis_domain; /* YP domain name */ 317a53f50b9Schristos #endif /* HAVE_MAP_NIS */ 318a53f50b9Schristos char *nfs_proto; /* NFS protocol (NULL, udp, tcp) */ 319a53f50b9Schristos int nfs_vers; /* NFS version (0, 2, 3, 4) */ 320*31bdb48aSchristos int nfs_vers_ping; /* NFS rpc ping version (0, 2, 3, 4) */ 321a53f50b9Schristos u_int exec_map_timeout; /* timeout (seconds) for executable maps */ 322a53f50b9Schristos }; 323a53f50b9Schristos 324a53f50b9Schristos /* if you add anything here, update conf.c:reset_cf_map() */ 325a53f50b9Schristos struct cf_map { 326a53f50b9Schristos char *cfm_dir; /* /home, /u, /src */ 327a53f50b9Schristos char *cfm_name; /* amd.home, /etc/amd.home ... */ 328a53f50b9Schristos char *cfm_type; /* file, hesiod, ndbm, nis ... */ 329a53f50b9Schristos char *cfm_defaults; /* map /defaults options in amd.conf */ 330a53f50b9Schristos char *cfm_opts; /* -cache:=all, etc. */ 331a53f50b9Schristos char *cfm_search_path; /* /etc/local:/etc/amdmaps:/misc/yp */ 332a53f50b9Schristos char *cfm_tag; /* optional map tag for amd -T */ 333a53f50b9Schristos u_int cfm_flags; /* browsable_dirs? mount_type? */ 334a53f50b9Schristos struct cf_map *cfm_next; /* pointer to next in list (if any) */ 335a53f50b9Schristos }; 336a53f50b9Schristos 337a53f50b9Schristos /* 338a53f50b9Schristos * Key-value pair 339a53f50b9Schristos */ 340a53f50b9Schristos struct kv { 341a53f50b9Schristos kv *next; 342a53f50b9Schristos char *key; 343a53f50b9Schristos #ifdef HAVE_REGEXEC 344a53f50b9Schristos regex_t re; /* store the regexp from regcomp() */ 345a53f50b9Schristos #endif /* HAVE_REGEXEC */ 346a53f50b9Schristos char *val; 347a53f50b9Schristos }; 348a53f50b9Schristos 349a53f50b9Schristos struct mnt_map { 350a53f50b9Schristos qelem hdr; 351a53f50b9Schristos int refc; /* Reference count */ 352a53f50b9Schristos short flags; /* Allocation flags */ 353a53f50b9Schristos short alloc; /* Allocation mode */ 354a53f50b9Schristos time_t modify; /* Modify time of map */ 355a53f50b9Schristos u_int reloads; /* Number of times map was reloaded */ 356*31bdb48aSchristos u_int nentries; /* Number of entries in the map */ 357a53f50b9Schristos char *map_name; /* Name of this map */ 358a53f50b9Schristos char *wildcard; /* Wildcard value */ 359a53f50b9Schristos reload_fn *reload; /* Function to be used for reloads */ 360a53f50b9Schristos isup_fn *isup; /* Is service up or not? (1=up, 0=down) */ 361a53f50b9Schristos search_fn *search; /* Function to be used for searching */ 362a53f50b9Schristos mtime_fn *mtime; /* Modify time function */ 363a53f50b9Schristos kv *kvhash[NKVHASH]; /* Cached data */ 364a53f50b9Schristos cf_map_t *cfm; /* pointer to per-map amd.conf opts, if any */ 365a53f50b9Schristos void *map_data; /* Map data black box */ 366a53f50b9Schristos }; 367a53f50b9Schristos 368a53f50b9Schristos /* 369a53f50b9Schristos * Options 370a53f50b9Schristos */ 371a53f50b9Schristos struct am_opts { 372a53f50b9Schristos char *fs_glob; /* Smashed copy of global options */ 373a53f50b9Schristos char *fs_local; /* Expanded copy of local options */ 374a53f50b9Schristos char *fs_mtab; /* Mount table entry */ 375a53f50b9Schristos /* Other options ... */ 376a53f50b9Schristos char *opt_dev; 377a53f50b9Schristos char *opt_delay; 378a53f50b9Schristos char *opt_dir; 379a53f50b9Schristos char *opt_fs; 380a53f50b9Schristos char *opt_group; 381a53f50b9Schristos char *opt_mount; 382a53f50b9Schristos char *opt_opts; 383a53f50b9Schristos char *opt_remopts; 384a53f50b9Schristos char *opt_pref; 385a53f50b9Schristos char *opt_cache; 386a53f50b9Schristos char *opt_rfs; 387a53f50b9Schristos char *opt_rhost; 388a53f50b9Schristos char *opt_sublink; 389a53f50b9Schristos char *opt_type; 390a53f50b9Schristos char *opt_mount_type; /* "nfs" or "autofs" */ 391a53f50b9Schristos char *opt_unmount; 392a53f50b9Schristos char *opt_umount; /* an "alias" for opt_unmount (type:=program) */ 393a53f50b9Schristos char *opt_user; 394a53f50b9Schristos char *opt_maptype; /* map type: file, nis, hesiod, etc. */ 395a53f50b9Schristos char *opt_cachedir; /* cache directory */ 396a53f50b9Schristos char *opt_addopts; /* options to add to opt_opts */ 397a53f50b9Schristos }; 398a53f50b9Schristos 399a53f50b9Schristos struct am_ops { 400a53f50b9Schristos char *fs_type; /* type of filesystems e.g. "nfsx" */ 401a53f50b9Schristos vfs_match fs_match; /* fxn: match */ 402a53f50b9Schristos vfs_init fs_init; /* fxn: initialization */ 403a53f50b9Schristos vmount_fs mount_fs; /* fxn: mount my own vnode */ 404a53f50b9Schristos vumount_fs umount_fs; /* fxn: unmount my own vnode */ 405a53f50b9Schristos vlookup_child lookup_child; /* fxn: lookup path-name */ 406a53f50b9Schristos vmount_child mount_child; /* fxn: mount path-name */ 407a53f50b9Schristos vreaddir readdir; /* fxn: read directory */ 408a53f50b9Schristos vreadlink readlink; /* fxn: read link */ 409a53f50b9Schristos vmounted mounted; /* fxn: after-mount extra actions */ 410a53f50b9Schristos vumounted umounted; /* fxn: after-umount extra actions */ 411a53f50b9Schristos vffserver ffserver; /* fxn: find a file server */ 412a53f50b9Schristos vget_wchan get_wchan; /* fxn: get the waiting channel */ 413a53f50b9Schristos int nfs_fs_flags; /* filesystem flags FS_* for nfs mounts */ 414a53f50b9Schristos #ifdef HAVE_FS_AUTOFS 415a53f50b9Schristos int autofs_fs_flags;/* filesystem flags FS_* for autofs mounts */ 416a53f50b9Schristos #endif /* HAVE_FS_AUTOFS */ 417a53f50b9Schristos }; 418a53f50b9Schristos 419a53f50b9Schristos /* 420a53f50b9Schristos * List of mounted filesystems 421a53f50b9Schristos */ 422a53f50b9Schristos struct mntfs { 423a53f50b9Schristos qelem mf_q; /* List of mounted filesystems */ 424a53f50b9Schristos am_ops *mf_ops; /* Operations on this mountpoint */ 425a53f50b9Schristos am_opts *mf_fo; /* File opts */ 426a53f50b9Schristos char *mf_mount; /* "/a/kiska/home/kiska" */ 427a53f50b9Schristos char *mf_info; /* Mount info */ 428*31bdb48aSchristos char *mf_auto; /* Mount info */ 429a53f50b9Schristos char *mf_mopts; /* FS mount opts */ 430a53f50b9Schristos char *mf_remopts; /* Remote FS mount opts */ 431a53f50b9Schristos char *mf_loopdev; /* loop device name for /dev/loop mounts */ 432a53f50b9Schristos fserver *mf_server; /* File server */ 433a53f50b9Schristos int mf_fsflags; /* Flags FS_* copied from mf_ops->*_fs_flags */ 434a53f50b9Schristos int mf_flags; /* Flags MFF_* */ 435a53f50b9Schristos int mf_error; /* Error code from background mount */ 436a53f50b9Schristos int mf_refc; /* Number of references to this node */ 437a53f50b9Schristos int mf_cid; /* Callout id */ 438a53f50b9Schristos void (*mf_prfree) (opaque_t); /* Free private space */ 439a53f50b9Schristos opaque_t mf_private; /* Private - per-fs data */ 440a53f50b9Schristos }; 441a53f50b9Schristos 442a53f50b9Schristos /* 443*31bdb48aSchristos * Locations: bindings between keys and mntfs 444*31bdb48aSchristos */ 445*31bdb48aSchristos struct am_loc { 446*31bdb48aSchristos am_opts *al_fo; 447*31bdb48aSchristos mntfs *al_mnt; 448*31bdb48aSchristos int al_refc; 449*31bdb48aSchristos }; 450*31bdb48aSchristos 451*31bdb48aSchristos 452*31bdb48aSchristos /* 453a53f50b9Schristos * List of fileservers 454a53f50b9Schristos */ 455a53f50b9Schristos struct fserver { 456a53f50b9Schristos qelem fs_q; /* List of fileservers */ 457a53f50b9Schristos int fs_refc; /* Number of references to this server */ 458a53f50b9Schristos char *fs_host; /* Normalized hostname of server */ 459a53f50b9Schristos struct sockaddr_in *fs_ip; /* Network address of server */ 460a53f50b9Schristos int fs_cid; /* Callout id */ 461a53f50b9Schristos int fs_pinger; /* Ping (keepalive) interval */ 462a53f50b9Schristos int fs_flags; /* Flags */ 463a53f50b9Schristos char *fs_type; /* File server type */ 464a53f50b9Schristos u_long fs_version; /* NFS version of server (2, 3, etc.)*/ 465a53f50b9Schristos char *fs_proto; /* NFS protocol of server (tcp, udp, etc.) */ 466a53f50b9Schristos opaque_t fs_private; /* Private data */ 467a53f50b9Schristos void (*fs_prfree) (opaque_t); /* Free private data */ 468a53f50b9Schristos }; 469a53f50b9Schristos 470a53f50b9Schristos /* 471a53f50b9Schristos * Per-mountpoint statistics 472a53f50b9Schristos */ 473a53f50b9Schristos struct am_stats { 474a53f50b9Schristos time_t s_mtime; /* Mount time */ 475a53f50b9Schristos u_short s_uid; /* Uid of mounter */ 476a53f50b9Schristos int s_getattr; /* Count of getattrs */ 477a53f50b9Schristos int s_lookup; /* Count of lookups */ 478a53f50b9Schristos int s_readdir; /* Count of readdirs */ 479a53f50b9Schristos int s_readlink; /* Count of readlinks */ 480a53f50b9Schristos int s_statfs; /* Count of statfs */ 481*31bdb48aSchristos int s_fsinfo; /* Count of fsinfo */ 482*31bdb48aSchristos int s_pathconf; /* Count of pathconf */ 483a53f50b9Schristos }; 484a53f50b9Schristos 485a53f50b9Schristos /* 486a53f50b9Schristos * System statistics 487a53f50b9Schristos */ 488a53f50b9Schristos struct amd_stats { 489a53f50b9Schristos int d_drops; /* Dropped requests */ 490a53f50b9Schristos int d_stale; /* Stale NFS handles */ 491a53f50b9Schristos int d_mok; /* Successful mounts */ 492a53f50b9Schristos int d_merr; /* Failed mounts */ 493a53f50b9Schristos int d_uerr; /* Failed unmounts */ 494a53f50b9Schristos }; 495a53f50b9Schristos extern struct amd_stats amd_stats; 496a53f50b9Schristos 497a53f50b9Schristos /* 498a53f50b9Schristos * Map of auto-mount points. 499a53f50b9Schristos */ 500a53f50b9Schristos struct am_node { 501a53f50b9Schristos int am_mapno; /* Map number */ 502*31bdb48aSchristos am_loc *am_al; /* Mounted filesystem */ 503*31bdb48aSchristos am_loc **am_alarray; /* Filesystem sources to try to mount */ 504a53f50b9Schristos char *am_name; /* "kiska": name of this node */ 505a53f50b9Schristos char *am_path; /* "/home/kiska": path of this node's mount point */ 506a53f50b9Schristos char *am_link; /* "/a/kiska/home/kiska/this/that": link to sub-dir */ 507a53f50b9Schristos am_node *am_parent; /* Parent of this node */ 508a53f50b9Schristos am_node *am_ysib; /* Younger sibling of this node */ 509a53f50b9Schristos am_node *am_osib; /* Older sibling of this node */ 510a53f50b9Schristos am_node *am_child; /* First child of this node */ 511a53f50b9Schristos nfsattrstat am_attr; /* File attributes */ 512a53f50b9Schristos #define am_fattr am_attr.ns_u.ns_attr_u 513a53f50b9Schristos int am_flags; /* Boolean flags AMF_* */ 514a53f50b9Schristos int am_error; /* Specific mount error */ 515a53f50b9Schristos time_t am_ttl; /* Time to live */ 516a53f50b9Schristos int am_timeo_w; /* Dismount wait interval */ 517a53f50b9Schristos int am_timeo; /* Cache timeout interval */ 518a53f50b9Schristos u_int am_gen; /* Generation number */ 519a53f50b9Schristos char *am_pref; /* Mount info prefix */ 520a53f50b9Schristos am_stats am_stats; /* Statistics gathering */ 521a53f50b9Schristos SVCXPRT *am_transp; /* Info for quick reply */ 522a53f50b9Schristos dev_t am_dev; /* Device number */ 523a53f50b9Schristos dev_t am_rdev; /* Remote/real device number */ 524a53f50b9Schristos #ifdef HAVE_FS_AUTOFS 525a53f50b9Schristos autofs_fh_t *am_autofs_fh; 526a53f50b9Schristos time_t am_autofs_ttl; /* Time to expire autofs nodes */ 527a53f50b9Schristos #endif /* HAVE_FS_AUTOFS */ 5284bcd344eSchristos int am_fd[2]; /* parent child pipe fd's for sync umount */ 529a53f50b9Schristos }; 530a53f50b9Schristos 531a53f50b9Schristos /* 532a53f50b9Schristos * EXTERNALS: 533a53f50b9Schristos */ 534a53f50b9Schristos 535a53f50b9Schristos /* 536a53f50b9Schristos * Amq server global functions 537a53f50b9Schristos */ 538a53f50b9Schristos extern amq_mount_info_list *amqproc_getmntfs_1_svc(voidp argp, struct svc_req *rqstp); 539a53f50b9Schristos extern amq_mount_stats *amqproc_stats_1_svc(voidp argp, struct svc_req *rqstp); 540a53f50b9Schristos extern amq_mount_tree_list *amqproc_export_1_svc(voidp argp, struct svc_req *rqstp); 541a53f50b9Schristos extern amq_mount_tree_p *amqproc_mnttree_1_svc(voidp argp, struct svc_req *rqstp); 542a53f50b9Schristos extern amq_string *amqproc_getvers_1_svc(voidp argp, struct svc_req *rqstp); 543a53f50b9Schristos extern amq_string *amqproc_pawd_1_svc(voidp argp, struct svc_req *rqstp); 544a53f50b9Schristos extern int *amqproc_getpid_1_svc(voidp argp, struct svc_req *rqstp); 545a53f50b9Schristos extern int *amqproc_mount_1_svc(voidp argp, struct svc_req *rqstp); 546a53f50b9Schristos extern int *amqproc_setopt_1_svc(voidp argp, struct svc_req *rqstp); 547a53f50b9Schristos extern voidp amqproc_null_1_svc(voidp argp, struct svc_req *rqstp); 5484bcd344eSchristos extern int *amqproc_umnt_1_svc(voidp argp, struct svc_req *rqstp); 5494bcd344eSchristos extern int *amqproc_sync_umnt_1_svc_parent(voidp argp, struct svc_req *rqstp); 5504bcd344eSchristos extern amq_sync_umnt *amqproc_sync_umnt_1_svc_child(voidp argp, struct svc_req *rqstp); 5514bcd344eSchristos extern amq_sync_umnt *amqproc_sync_umnt_1_svc_async(voidp argp, struct svc_req *rqstp); 552*31bdb48aSchristos extern amq_map_info_list *amqproc_getmapinfo_1_svc(voidp argp, struct svc_req *rqstp); 553a53f50b9Schristos 554a53f50b9Schristos /* other external definitions */ 555*31bdb48aSchristos extern am_nfs_handle_t *get_root_nfs_fh(char *dir, am_nfs_handle_t *nfh); 556a53f50b9Schristos extern am_node *find_ap(char *); 557a53f50b9Schristos extern am_node *get_ap_child(am_node *, char *); 558a53f50b9Schristos extern bool_t xdr_amq_mount_info_qelem(XDR *xdrs, qelem *qhead); 559*31bdb48aSchristos extern bool_t xdr_amq_map_info_qelem(XDR *xdrs, qelem *qhead); 560a53f50b9Schristos extern fserver *find_nfs_srvr(mntfs *mf); 561a53f50b9Schristos extern int mount_nfs_fh(am_nfs_handle_t *fhp, char *mntdir, char *fs_name, mntfs *mf); 562a53f50b9Schristos extern int process_all_regular_maps(void); 563a53f50b9Schristos extern cf_map_t *find_cf_map(const char *name); 564a53f50b9Schristos extern int set_conf_kv(const char *section, const char *k, const char *v); 565a53f50b9Schristos extern int mount_node(opaque_t arg); 566a53f50b9Schristos extern int unmount_mp(am_node *mp); 567a53f50b9Schristos extern int conf_parse(void); /* "yyparse" renamed */ 568a53f50b9Schristos extern FILE *conf_in; /* "yyin" renamed */ 569a53f50b9Schristos 570a53f50b9Schristos extern void amfs_mkcacheref(mntfs *mf); 571a53f50b9Schristos extern int amfs_mount(am_node *mp, mntfs *mf, char *opts); 572a53f50b9Schristos extern void assign_error_mntfs(am_node *mp); 573a53f50b9Schristos extern am_node *next_nonerror_node(am_node *xp); 574a53f50b9Schristos extern void flush_srvr_nfs_cache(fserver *fs); 575a53f50b9Schristos extern void am_mounted(am_node *); 576a53f50b9Schristos extern void mf_mounted(mntfs *mf, bool_t call_free_opts); 577a53f50b9Schristos extern void am_unmounted(am_node *); 578a53f50b9Schristos extern am_node *get_exported_ap(int index); 579a53f50b9Schristos extern am_node *get_first_exported_ap(int *index); 580a53f50b9Schristos extern am_node *get_next_exported_ap(int *index); 581a53f50b9Schristos extern am_node *path_to_exported_ap(char *path); 582a53f50b9Schristos extern am_node *exported_ap_alloc(void); 583a53f50b9Schristos extern am_node *find_mf(mntfs *); 584a53f50b9Schristos extern am_node *next_map(int *); 585a53f50b9Schristos extern am_ops *ops_match(am_opts *, char *, char *, char *, char *, char *); 586a53f50b9Schristos extern am_ops *ops_search(char *); 587a53f50b9Schristos extern fserver *dup_srvr(fserver *); 588a53f50b9Schristos extern void srvrlog(fserver *, char *); 589a53f50b9Schristos extern int get_mountd_port(fserver *, u_short *, wchan_t); 590a53f50b9Schristos extern void flush_nfs_fhandle_cache(fserver *); 591a53f50b9Schristos 592a53f50b9Schristos extern mntfs *dup_mntfs(mntfs *); 593*31bdb48aSchristos extern am_loc *dup_loc(am_loc *); 594a53f50b9Schristos extern mntfs *find_mntfs(am_ops *, am_opts *, char *, char *, char *, char *, char *); 595a53f50b9Schristos extern mntfs *locate_mntfs(am_ops *, am_opts *, char *, char *, char *, char *, char *); 596*31bdb48aSchristos extern am_loc *new_loc(void); 597a53f50b9Schristos extern mntfs *new_mntfs(void); 598a53f50b9Schristos extern mntfs *realloc_mntfs(mntfs *, am_ops *, am_opts *, char *, char *, char *, char *, char *); 599a53f50b9Schristos extern void flush_mntfs(void); 600a53f50b9Schristos extern void free_mntfs(voidp); 601*31bdb48aSchristos extern void free_loc(voidp); 602a53f50b9Schristos 603a53f50b9Schristos 604a53f50b9Schristos extern void amq_program_1(struct svc_req *rqstp, SVCXPRT *transp); 605a53f50b9Schristos extern int background(void); 606a53f50b9Schristos extern void deslashify(char *); 607a53f50b9Schristos extern void do_task_notify(void); 608a53f50b9Schristos extern int eval_fs_opts(am_opts *, char *, char *, char *, char *, char *); 609a53f50b9Schristos extern int file_read_line(char *, int, FILE *); 610a53f50b9Schristos extern void forcibly_timeout_mp(am_node *); 611a53f50b9Schristos extern void free_map(am_node *); 612a53f50b9Schristos extern void free_opts(am_opts *); 613*31bdb48aSchristos extern am_opts *copy_opts(am_opts *); 614a53f50b9Schristos extern void free_srvr(fserver *); 615a53f50b9Schristos extern int fwd_init(void); 616a53f50b9Schristos extern int fwd_packet(int, char *, int, struct sockaddr_in *, struct sockaddr_in *, opaque_t, fwd_fun *); 617a53f50b9Schristos extern void fwd_reply(void); 618a53f50b9Schristos extern void get_args(int argc, char *argv[]); 619a53f50b9Schristos extern wchan_t get_mntfs_wchan(mntfs *mf); 620a53f50b9Schristos extern void host_normalize(char **); 621a53f50b9Schristos extern void init_map(am_node *, char *); 622a53f50b9Schristos extern void ins_que(qelem *, qelem *); 623a53f50b9Schristos extern void insert_am(am_node *, am_node *); 624a53f50b9Schristos extern int make_nfs_auth(void); 625a53f50b9Schristos extern void make_root_node(void); 626a53f50b9Schristos extern void map_flush_srvr(fserver *); 627a53f50b9Schristos extern void mapc_add_kv(mnt_map *, char *, char *); 628a53f50b9Schristos extern mnt_map *mapc_find(char *, char *, const char *, const char *); 629a53f50b9Schristos extern void mapc_free(opaque_t); 630a53f50b9Schristos extern int mapc_keyiter(mnt_map *, key_fun, opaque_t); 631a53f50b9Schristos extern void mapc_reload(void); 632a53f50b9Schristos extern int mapc_search(mnt_map *, char *, char **); 633a53f50b9Schristos extern void mapc_showtypes(char *buf, size_t l); 634a53f50b9Schristos extern int mapc_type_exists(const char *type); 635a53f50b9Schristos extern void mk_fattr(nfsfattr *, nfsftype); 636a53f50b9Schristos extern int mount_auto_node(char *, opaque_t); 637a53f50b9Schristos extern int mount_automounter(int); 638a53f50b9Schristos extern int mount_exported(void); 639a53f50b9Schristos extern void mp_to_fh(am_node *, am_nfs_fh *); 640*31bdb48aSchristos extern void mp_to_fh3(am_node *mp, am_nfs_fh3 *fhp); 641a53f50b9Schristos extern void new_ttl(am_node *); 642a53f50b9Schristos extern void nfs_quick_reply(am_node *mp, int error); 643a53f50b9Schristos extern void normalize_slash(char *); 6444bcd344eSchristos extern void notify_child(am_node *, au_etype, int, int); 645a53f50b9Schristos extern void ops_showamfstypes(char *buf, size_t l); 646a53f50b9Schristos extern void ops_showfstypes(char *outbuf, size_t l); 647a53f50b9Schristos extern void rem_que(qelem *); 648a53f50b9Schristos extern void reschedule_timeout_mp(void); 649a53f50b9Schristos extern void restart(void); 650a53f50b9Schristos extern void restart_automounter_nodes(void); 651a53f50b9Schristos extern int root_keyiter(key_fun *, opaque_t); 652a53f50b9Schristos extern void root_newmap(const char *, const char *, const char *, const cf_map_t *); 653a53f50b9Schristos extern void run_task(task_fun *, opaque_t, cb_fun *, opaque_t); 654a53f50b9Schristos extern void sched_task(cb_fun *, opaque_t, wchan_t); 655a53f50b9Schristos extern int softclock(void); 656a53f50b9Schristos extern int timeout(u_int, void (*fn)(opaque_t), opaque_t); 657a53f50b9Schristos extern void timeout_mp(opaque_t); 658a53f50b9Schristos extern void untimeout(int); 659a53f50b9Schristos extern void umount_exported(void); 660a53f50b9Schristos extern int valid_key(char *); 661a53f50b9Schristos extern void wakeup(wchan_t); 662a53f50b9Schristos extern void wakeup_srvr(fserver *); 663a53f50b9Schristos extern void wakeup_task(int, int, wchan_t); 664a53f50b9Schristos #define SIZEOF_PID_FSNAME (16 + MAXHOSTNAMELEN) 665a53f50b9Schristos extern char pid_fsname[SIZEOF_PID_FSNAME]; /* "kiska.southseas.nz:(pid%d)" */ 666a53f50b9Schristos #define SIZEOF_HOSTD (2 * MAXHOSTNAMELEN + 1) 667a53f50b9Schristos extern char hostd[SIZEOF_HOSTD]; /* Host+domain */ 668a53f50b9Schristos #define SIZEOF_OPTS 256 /* used for char opts[] and preopts[] */ 669a53f50b9Schristos 670a53f50b9Schristos /* 671a53f50b9Schristos * Global variables. 672a53f50b9Schristos */ 673a53f50b9Schristos extern SVCXPRT *current_transp; /* For nfs_quick_reply() */ 674*31bdb48aSchristos extern dispatcher_t nfs_dispatcher; 675a53f50b9Schristos extern char *conf_tag; 676a53f50b9Schristos #define SIZEOF_UID_STR 12 677a53f50b9Schristos #define SIZEOF_GID_STR 12 678a53f50b9Schristos extern char *opt_gid, gid_str[SIZEOF_GID_STR]; 679a53f50b9Schristos extern char *opt_uid, uid_str[SIZEOF_UID_STR]; 680a53f50b9Schristos extern int NumChildren; 681a53f50b9Schristos extern int fwd_sock; 682a53f50b9Schristos extern int select_intr_valid; 683a53f50b9Schristos extern int immediate_abort; /* Should close-down unmounts be retried */ 684a53f50b9Schristos extern int usage; 685a53f50b9Schristos extern int use_conf_file; /* use amd configuration file */ 686a53f50b9Schristos extern int task_notify_todo; /* Task notifier needs running */ 687a53f50b9Schristos extern jmp_buf select_intr; 688a53f50b9Schristos extern qelem mfhead; 689a53f50b9Schristos extern struct amu_global_options gopt; /* where global options are stored */ 690a53f50b9Schristos extern time_t do_mapc_reload; /* Flush & reload mount map cache */ 691a53f50b9Schristos extern time_t next_softclock; /* Time to call softclock() */ 692a53f50b9Schristos 693a53f50b9Schristos #ifdef HAVE_SIGACTION 694a53f50b9Schristos extern sigset_t masked_sigs; 695a53f50b9Schristos #endif /* HAVE_SIGACTION */ 696a53f50b9Schristos 697a53f50b9Schristos #if defined(HAVE_AMU_FS_LINK) || defined(HAVE_AMU_FS_LINKX) 698a53f50b9Schristos extern char *amfs_link_match(am_opts *fo); 699a53f50b9Schristos #endif /* defined(HAVE_AMU_FS_LINK) || defined(HAVE_AMU_FS_LINKX) */ 700a53f50b9Schristos 701a53f50b9Schristos #ifdef HAVE_FS_AUTOFS 702a53f50b9Schristos extern int amd_use_autofs; 703a53f50b9Schristos 704a53f50b9Schristos extern int autofs_get_fh(am_node *mp); 705a53f50b9Schristos extern void autofs_release_fh(am_node *mp); 706a53f50b9Schristos extern void autofs_get_mp(am_node *mp); 707a53f50b9Schristos extern void autofs_release_mp(am_node *mp); 708a53f50b9Schristos extern void autofs_add_fdset(fd_set *readfds); 709a53f50b9Schristos extern int autofs_handle_fdset(fd_set *readfds, int nsel); 710a53f50b9Schristos extern void autofs_mounted(am_node *mp); 711a53f50b9Schristos extern void autofs_mount_succeeded(am_node *mp); 712a53f50b9Schristos extern void autofs_mount_failed(am_node *mp); 713a53f50b9Schristos extern int autofs_umount_succeeded(am_node *mp); 714a53f50b9Schristos extern int autofs_umount_failed(am_node *mp); 715a53f50b9Schristos extern int autofs_mount_fs(am_node *mp, mntfs *mf); 716a53f50b9Schristos extern int autofs_umount_fs(am_node *mp, mntfs *mf); 717a53f50b9Schristos extern void autofs_get_opts(char *opts, size_t l, autofs_fh_t *fh); 718a53f50b9Schristos extern int autofs_compute_mount_flags(mntent_t *); 719a53f50b9Schristos extern void autofs_timeout_mp(am_node *); 720a53f50b9Schristos extern int create_autofs_service(void); 721a53f50b9Schristos extern int destroy_autofs_service(void); 722a53f50b9Schristos #endif /* HAVE_FS_AUTOFS */ 723a53f50b9Schristos 724a53f50b9Schristos /**************************************************************************/ 725a53f50b9Schristos /*** Generic file-system types, implemented as part of the native O/S. ***/ 726a53f50b9Schristos /**************************************************************************/ 727a53f50b9Schristos 728a53f50b9Schristos /* 729a53f50b9Schristos * Loopback File System 730a53f50b9Schristos * Many systems can't support this, and in any case most of the 731a53f50b9Schristos * functionality is available with Symlink FS. 732a53f50b9Schristos */ 733a53f50b9Schristos #ifdef HAVE_FS_LOFS 734a53f50b9Schristos extern am_ops lofs_ops; 735a53f50b9Schristos extern int mount_lofs(char *mntdir, char *fs_name, char *opts, int on_autofs); 736a53f50b9Schristos #endif /* HAVE_FS_LOFS */ 737a53f50b9Schristos 738a53f50b9Schristos /* 739a53f50b9Schristos * CD-ROM File System (CD-ROM) 740a53f50b9Schristos * (HSFS: High Sierra F/S on some machines) 741a53f50b9Schristos * Many systems can't support this, and in any case most of the 742a53f50b9Schristos * functionality is available with program FS. 743a53f50b9Schristos */ 744a53f50b9Schristos #ifdef HAVE_FS_CDFS 745a53f50b9Schristos extern am_ops cdfs_ops; 746a53f50b9Schristos #endif /* HAVE_FS_CDFS */ 747a53f50b9Schristos 748a53f50b9Schristos /* 749a53f50b9Schristos * PC File System (MS-DOS) 750a53f50b9Schristos * Many systems can't support this, and in any case most of the 751a53f50b9Schristos * functionality is available with program FS. 752a53f50b9Schristos */ 753a53f50b9Schristos #ifdef HAVE_FS_PCFS 754a53f50b9Schristos extern am_ops pcfs_ops; 755a53f50b9Schristos #endif /* HAVE_FS_PCFS */ 756a53f50b9Schristos 757a53f50b9Schristos /* 7584bcd344eSchristos * UDF File System 7594bcd344eSchristos * Many systems can't support this, and in any case most of the 7604bcd344eSchristos * functionality is available with program FS. 7614bcd344eSchristos */ 7624bcd344eSchristos #ifdef HAVE_FS_UDF 7634bcd344eSchristos extern am_ops udf_ops; 7644bcd344eSchristos #endif /* HAVE_FS_UDF */ 7654bcd344eSchristos 766*31bdb48aSchristos #ifdef HAVE_FS_LUSTRE 767*31bdb48aSchristos extern am_ops lustre_ops; 768*31bdb48aSchristos #endif /* HAVE_FS_LUSTRE */ 769*31bdb48aSchristos 7704bcd344eSchristos /* 771a53f50b9Schristos * Caching File System (Solaris) 772a53f50b9Schristos */ 773a53f50b9Schristos #ifdef HAVE_FS_CACHEFS 774a53f50b9Schristos extern am_ops cachefs_ops; 775a53f50b9Schristos #endif /* HAVE_FS_CACHEFS */ 776a53f50b9Schristos 777a53f50b9Schristos /* 778a53f50b9Schristos * In memory /tmp filesystem (Linux, NetBSD) 779a53f50b9Schristos */ 780a53f50b9Schristos #ifdef HAVE_FS_TMPFS 781a53f50b9Schristos extern am_ops tmpfs_ops; 782a53f50b9Schristos #endif /* HAVE_FS_TMPFS */ 783a53f50b9Schristos /* 784a53f50b9Schristos * Network File System 785a53f50b9Schristos * Good, slow, NFS V.2. 786a53f50b9Schristos */ 787a53f50b9Schristos #ifdef HAVE_FS_NFS 788a53f50b9Schristos extern am_ops nfs_ops; /* NFS */ 789a53f50b9Schristos extern fserver *find_nfs_srvr (mntfs *); 790a53f50b9Schristos extern qelem nfs_srvr_list; 791a53f50b9Schristos #endif /* HAVE_FS_NFS */ 792a53f50b9Schristos 793a53f50b9Schristos /* 794a53f50b9Schristos * Un*x File System 795a53f50b9Schristos * Normal local disk file system. 796a53f50b9Schristos */ 797a53f50b9Schristos #ifdef HAVE_FS_UFS 798a53f50b9Schristos extern am_ops ufs_ops; /* Un*x file system */ 799a53f50b9Schristos #endif /* HAVE_FS_UFS */ 800a53f50b9Schristos 801a53f50b9Schristos /* Unix file system (irix) */ 802a53f50b9Schristos #ifdef HAVE_FS_XFS 803a53f50b9Schristos extern am_ops xfs_ops; /* Un*x file system */ 804a53f50b9Schristos #endif /* HAVE_FS_XFS */ 805a53f50b9Schristos 806*31bdb48aSchristos /* Unix file system (ext*) */ 807*31bdb48aSchristos #ifdef HAVE_FS_EXT 808*31bdb48aSchristos extern am_ops ext2_ops; /* Un*x file system */ 809*31bdb48aSchristos extern am_ops ext3_ops; /* Un*x file system */ 810*31bdb48aSchristos extern am_ops ext4_ops; /* Un*x file system */ 811*31bdb48aSchristos #endif /* HAVE_FS_EXT */ 812*31bdb48aSchristos 813a53f50b9Schristos /* Unix file system (irix) */ 814a53f50b9Schristos #ifdef HAVE_FS_EFS 815a53f50b9Schristos extern am_ops efs_ops; /* Un*x file system */ 816a53f50b9Schristos #endif /* HAVE_FS_EFS */ 817a53f50b9Schristos 818a53f50b9Schristos /**************************************************************************/ 819a53f50b9Schristos /*** Automounter file-system types, implemented by amd. ***/ 820a53f50b9Schristos /**************************************************************************/ 821a53f50b9Schristos 822a53f50b9Schristos /* 823a53f50b9Schristos * Root AMD File System 824a53f50b9Schristos */ 825a53f50b9Schristos extern am_ops amfs_root_ops; /* Root file system */ 826a53f50b9Schristos 827a53f50b9Schristos /* 828a53f50b9Schristos * Generic amfs helper methods 829a53f50b9Schristos */ 830a53f50b9Schristos extern am_node *amfs_generic_lookup_child(am_node *mp, char *fname, int *error_return, int op); 831a53f50b9Schristos extern am_node *amfs_generic_mount_child(am_node *ap, int *error_return); 832*31bdb48aSchristos extern int amfs_generic_readdir(am_node *mp, voidp cookie, voidp dp, voidp ep, u_int count); 833a53f50b9Schristos extern int amfs_generic_umount(am_node *mp, mntfs *mf); 834a53f50b9Schristos extern void amfs_generic_mounted(mntfs *mf); 835a53f50b9Schristos extern char *amfs_generic_match(am_opts *fo); 836a53f50b9Schristos extern fserver *amfs_generic_find_srvr(mntfs *); 837a53f50b9Schristos 838a53f50b9Schristos /* 839a53f50b9Schristos * Automount File System 840a53f50b9Schristos */ 841a53f50b9Schristos #ifdef HAVE_AMU_FS_AUTO 842a53f50b9Schristos extern am_ops amfs_auto_ops; /* Automount file system (this!) */ 843a53f50b9Schristos #endif /* HAVE_AMU_FS_AUTO */ 844a53f50b9Schristos 845a53f50b9Schristos /* 846a53f50b9Schristos * Toplvl Automount File System 847a53f50b9Schristos */ 848a53f50b9Schristos #ifdef HAVE_AMU_FS_TOPLVL 849a53f50b9Schristos extern am_ops amfs_toplvl_ops; /* Toplvl Automount file system */ 850a53f50b9Schristos extern int amfs_toplvl_mount(am_node *mp, mntfs *mf); 851a53f50b9Schristos extern int amfs_toplvl_umount(am_node *mp, mntfs *mf); 852a53f50b9Schristos #endif /* HAVE_AMU_FS_TOPLVL */ 853a53f50b9Schristos 854a53f50b9Schristos /* 855a53f50b9Schristos * Direct Automount File System 856a53f50b9Schristos */ 857a53f50b9Schristos #ifdef HAVE_AMU_FS_DIRECT 858a53f50b9Schristos extern am_ops amfs_direct_ops; /* Direct Automount file system (this too) */ 859a53f50b9Schristos #endif /* HAVE_AMU_FS_DIRECT */ 860a53f50b9Schristos 861a53f50b9Schristos /* 862a53f50b9Schristos * Error File System 863a53f50b9Schristos */ 864a53f50b9Schristos #ifdef HAVE_AMU_FS_ERROR 865a53f50b9Schristos extern am_ops amfs_error_ops; /* Error file system */ 866a53f50b9Schristos extern am_node *amfs_error_lookup_child(am_node *mp, char *fname, int *error_return, int op); 867a53f50b9Schristos extern am_node *amfs_error_mount_child(am_node *ap, int *error_return); 868*31bdb48aSchristos extern int amfs_error_readdir(am_node *mp, voidp cookie, voidp dp, voidp ep, u_int count); 869*31bdb48aSchristos 870a53f50b9Schristos #endif /* HAVE_AMU_FS_ERROR */ 871a53f50b9Schristos 872a53f50b9Schristos /* 873a53f50b9Schristos * NFS mounts with local existence check. 874a53f50b9Schristos */ 875a53f50b9Schristos #ifdef HAVE_AMU_FS_NFSL 876a53f50b9Schristos extern am_ops amfs_nfsl_ops; /* NFSL */ 877a53f50b9Schristos #endif /* HAVE_AMU_FS_NFSL */ 878a53f50b9Schristos 879a53f50b9Schristos /* 880a53f50b9Schristos * Multi-nfs mounts. 881a53f50b9Schristos */ 882a53f50b9Schristos #ifdef HAVE_AMU_FS_NFSX 883a53f50b9Schristos extern am_ops amfs_nfsx_ops; /* NFSX */ 884a53f50b9Schristos #endif /* HAVE_AMU_FS_NFSX */ 885a53f50b9Schristos 886a53f50b9Schristos /* 887a53f50b9Schristos * NFS host - a whole tree. 888a53f50b9Schristos */ 889a53f50b9Schristos #ifdef HAVE_AMU_FS_HOST 890a53f50b9Schristos extern am_ops amfs_host_ops; /* NFS host */ 891a53f50b9Schristos #endif /* HAVE_AMU_FS_HOST */ 892a53f50b9Schristos 893a53f50b9Schristos /* 894a53f50b9Schristos * Program File System 895a53f50b9Schristos * This is useful for things like RVD. 896a53f50b9Schristos */ 897a53f50b9Schristos #ifdef HAVE_AMU_FS_PROGRAM 898a53f50b9Schristos extern am_ops amfs_program_ops; /* Program File System */ 899a53f50b9Schristos #endif /* HAVE_AMU_FS_PROGRAM */ 900a53f50b9Schristos 901a53f50b9Schristos /* 902a53f50b9Schristos * Symbolic-link file system. 903a53f50b9Schristos * A "filesystem" which is just a symbol link. 904a53f50b9Schristos */ 905a53f50b9Schristos #ifdef HAVE_AMU_FS_LINK 906a53f50b9Schristos extern am_ops amfs_link_ops; /* Symlink FS */ 907a53f50b9Schristos #endif /* HAVE_AMU_FS_LINK */ 908a53f50b9Schristos 909a53f50b9Schristos /* 910a53f50b9Schristos * Symbolic-link file system, which also checks that the target of 911a53f50b9Schristos * the symlink exists. 912a53f50b9Schristos * A "filesystem" which is just a symbol link. 913a53f50b9Schristos */ 914a53f50b9Schristos #ifdef HAVE_AMU_FS_LINKX 915a53f50b9Schristos extern am_ops amfs_linkx_ops; /* Symlink FS with existence check */ 916a53f50b9Schristos #endif /* HAVE_AMU_FS_LINKX */ 917a53f50b9Schristos 918a53f50b9Schristos /* 919a53f50b9Schristos * Union file system 920a53f50b9Schristos */ 921a53f50b9Schristos #ifdef HAVE_AMU_FS_UNION 922a53f50b9Schristos extern am_ops amfs_union_ops; /* Union FS */ 923a53f50b9Schristos #endif /* HAVE_AMU_FS_UNION */ 924a53f50b9Schristos 925a53f50b9Schristos #endif /* not _AMD_H */ 926