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