home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.sbin / amd / include / am.h next >
Encoding:
C/C++ Source or Header  |  1991-05-12  |  18.5 KB  |  564 lines

  1. /*
  2.  * Copyright (c) 1990 Jan-Simon Pendry
  3.  * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
  4.  * Copyright (c) 1990 The Regents of the University of California.
  5.  * All rights reserved.
  6.  *
  7.  * This code is derived from software contributed to Berkeley by
  8.  * Jan-Simon Pendry at Imperial College, London.
  9.  *
  10.  * Redistribution and use in source and binary forms, with or without
  11.  * modification, are permitted provided that the following conditions
  12.  * are met:
  13.  * 1. Redistributions of source code must retain the above copyright
  14.  *    notice, this list of conditions and the following disclaimer.
  15.  * 2. Redistributions in binary form must reproduce the above copyright
  16.  *    notice, this list of conditions and the following disclaimer in the
  17.  *    documentation and/or other materials provided with the distribution.
  18.  * 3. All advertising materials mentioning features or use of this software
  19.  *    must display the following acknowledgement:
  20.  *    This product includes software developed by the University of
  21.  *    California, Berkeley and its contributors.
  22.  * 4. Neither the name of the University nor the names of its contributors
  23.  *    may be used to endorse or promote products derived from this software
  24.  *    without specific prior written permission.
  25.  *
  26.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  27.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  30.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  32.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  33.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  34.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  35.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  36.  * SUCH DAMAGE.
  37.  *
  38.  *    @(#)am.h    5.3 (Berkeley) 5/12/91
  39.  *
  40.  * $Id: am.h,v 5.2.1.8 91/05/07 22:19:18 jsp Alpha $
  41.  *
  42.  */
  43.  
  44. #include "config.h"
  45.  
  46. /*
  47.  * Global declarations
  48.  */
  49. #include <sys/param.h>
  50. #include <sys/socket.h>
  51. #include <rpc/rpc.h>
  52. #include "nfs_prot.h"
  53. #ifdef MNTENT_HDR
  54. #include MNTENT_HDR
  55. #endif /* MNTENT_HDR */
  56. #include <assert.h>
  57.  
  58. #ifdef DEBUG_MEM
  59. #include <malloc.h>
  60. #endif /* DEBUG_MEM */
  61.  
  62. #ifndef MAXHOSTNAMELEN
  63. #define MAXHOSTNAMELEN 64
  64. #endif /* MAXHOSTNAMELEN */
  65.  
  66. #ifndef MNTTYPE_AUTO
  67. #define MNTTYPE_AUTO "auto"
  68. #endif /* MNTTYPE_AUTO */
  69.  
  70. #ifndef FALSE
  71. #define FALSE 0
  72. #define TRUE 1
  73. #endif /* FALSE */
  74.  
  75. #ifndef ROOT_MAP
  76. #define    ROOT_MAP "\"root\""
  77. #endif /* ROOT_MAP */
  78.  
  79. /*
  80.  * Flags from command line
  81.  */
  82. extern int print_pid;        /* Print pid to stdout */
  83. extern int normalize_hosts;    /* Normalize host names before use */
  84. extern int restart_existing_mounts;
  85. #ifdef HAS_NIS_MAPS
  86. extern char *domain;        /* NIS domain to use */
  87. #endif /* HAS_NIS_MAPS */
  88. extern int am_timeo;        /* Cache period */
  89. extern int afs_timeo;        /* AFS timeout */
  90. extern int afs_retrans;        /* AFS retrans */
  91. extern int am_timeo_w;        /* Unmount timeout */
  92. extern char *mtab;        /* Mount table */
  93.  
  94. typedef enum {
  95.     Start,
  96.     Run,
  97.     Finishing,
  98.     Quit,
  99.     Done
  100. } serv_state;
  101.  
  102. extern serv_state amd_state;    /* Should we go now */
  103. extern int immediate_abort;    /* Should close-down unmounts be retried */
  104. extern time_t do_mapc_reload;    /* Flush & reload mount map cache */
  105.  
  106. /*
  107.  * Useful constants
  108.  */
  109. extern char pid_fsname[];    /* kiska.southseas.nz:(pid%d) */
  110. extern char hostd[];        /* "kiska.southseas.nz" */
  111. extern char *hostdomain;    /* "southseas.nz" */
  112. extern char *op_sys;        /* "sos4" */
  113. extern char *arch;        /* "sun4" */
  114. extern char *karch;        /* "sun4c" */
  115. extern char *cluster;        /* "r+d-kluster" */
  116. extern char *endian;        /* "big" */
  117. extern char *auto_dir;        /* "/a" */
  118. extern char copyright[];    /* Copyright info */
  119. extern char version[];        /* Version info */
  120.  
  121. typedef struct am_ops am_ops;
  122. typedef struct am_node am_node;
  123. typedef struct am_opts am_opts;
  124. typedef struct mntfs mntfs;
  125. typedef struct fserver fserver;
  126. typedef struct fsrvinfo fsrvinfo;
  127.  
  128. /*
  129.  * Debug defns.
  130.  */
  131. #ifdef DEBUG
  132. #define    DEBUG_MTAB    "./mtab"
  133.  
  134. extern int debug_flags;        /* Debug options */
  135.  
  136. #define    D_DAEMON    0x0001    /* Enter daemon mode */
  137. #define    D_TRACE        0x0002    /* Do protocol trace */
  138. #define    D_FULL        0x0004    /* Do full trace */
  139. #define    D_MTAB        0x0008    /* Use local mtab */
  140. #define    D_AMQ        0x0010    /* Register amq program */
  141. #define    D_STR        0x0020    /* Debug string munging */
  142. #define    D_MEM        0x0040    /* Trace memory allocations */
  143.  
  144. /*
  145.  * Normally, don't enter daemon mode, and don't register amq
  146.  */
  147. #define    D_TEST    (~(D_DAEMON|D_MEM|D_STR))
  148. #endif /* DEBUG */
  149.  
  150. /*
  151.  * Global variables.
  152.  */
  153. extern unsigned short nfs_port;    /* Our NFS service port */
  154. extern struct in_addr myipaddr;    /* (An) IP address of this host */
  155.  
  156. extern int foreground;        /* Foreground process */
  157. extern time_t next_softclock;    /* Time to call softclock() */
  158. extern int task_notify_todo;    /* Task notifier needs running */
  159. #ifdef HAS_TFS
  160. extern int nfs_server_code_available;
  161. #endif /* HAS_TFS */
  162. extern int last_used_map;    /* Last map being used for mounts */
  163. extern AUTH *nfs_auth;        /* Dummy uthorisation for remote servers */
  164. extern am_node **exported_ap;    /* List of nodes */
  165. extern int first_free_map;    /* First free node */
  166. extern am_node *root_node;    /* Node for "root" */
  167. extern char *wire;        /* Name of primary connected network */
  168. #define    NEXP_AP    (254)
  169. #define NEXP_AP_MARGIN (128)
  170.  
  171. typedef int (*task_fun)P((voidp));
  172. typedef void (*cb_fun)P((int, int, voidp));
  173. typedef void (*fwd_fun)P((voidp, int, struct sockaddr_in *,
  174.                 struct sockaddr_in *, voidp, int));
  175.  
  176. /*
  177.  * String comparison macros
  178.  */
  179. #define STREQ(s1, s2) (strcmp((s1), (s2)) == 0)
  180. #define FSTREQ(s1, s2) ((*(s1) == *(s2)) && STREQ((s1),(s2)))
  181.  
  182. /*
  183.  * Linked list
  184.  */
  185. typedef struct qelem qelem;
  186. struct qelem {
  187.     qelem *q_forw;
  188.     qelem *q_back;
  189. };
  190. #define    FIRST(ty, q)    ((ty *) ((q)->q_forw))
  191. #define    LAST(ty, q)    ((ty *) ((q)->q_back))
  192. #define    NEXT(ty, q)    ((ty *) (((qelem *) q)->q_forw))
  193. #define    PREV(ty, q)    ((ty *) (((qelem *) q)->q_back))
  194. #define    HEAD(ty, q)    ((ty *) q)
  195. #define    ITER(v, ty, q) \
  196.     for ((v) = FIRST(ty,(q)); (v) != HEAD(ty,(q)); (v) = NEXT(ty,(v)))
  197.  
  198. /*
  199.  * List of mount table entries
  200.  */
  201. typedef struct mntlist mntlist;
  202. struct mntlist {
  203.     struct mntlist *mnext;
  204.     struct mntent *mnt;
  205. };
  206.  
  207. /*
  208.  * Mount map
  209.  */
  210. typedef struct mnt_map mnt_map;
  211.  
  212. /*
  213.  * Global routines
  214.  */
  215. extern int atoi P((Const char *)); /* C */
  216. extern void am_mounted P((am_node*));
  217. extern void am_unmounted P((am_node*));
  218. extern int background(P_void);
  219. extern int bind_resv_port P((int, unsigned short*));
  220. extern int compute_mount_flags P((struct mntent *));
  221. extern int softclock(P_void);
  222. #ifdef DEBUG
  223. extern int debug_option P((char*));
  224. #endif /* DEBUG */
  225. extern void deslashify P((char*));
  226. /*extern void domain_strip P((char*, char*));*/
  227. extern mntfs* dup_mntfs P((mntfs*));
  228. extern fserver* dup_srvr P((fserver*));
  229. extern int eval_fs_opts P((am_opts*, char*, char*, char*, char*, char*));
  230. extern char* expand_key P((char*));
  231. extern am_node* exported_ap_alloc(P_void);
  232. extern am_node* find_ap P((char*));
  233. extern am_node* find_mf P((mntfs*));
  234. extern mntfs* find_mntfs P((am_ops*, am_opts*, char*, char*, char*, char*));
  235. extern void flush_mntfs(P_void);
  236. extern void flush_nfs_fhandle_cache P((fserver*));
  237. extern void forcibly_timeout_mp P((am_node*));
  238. extern FREE_RETURN_TYPE free P((voidp)); /* C */
  239. extern void free_mntfs P((mntfs*));
  240. extern void free_opts P((am_opts*));
  241. extern void free_map P((am_node*));
  242. extern void free_mntlist P((mntlist*));
  243. extern void free_srvr P((fserver*));
  244. extern int fwd_init(P_void);
  245. extern int fwd_packet P((int, voidp, int, struct sockaddr_in *,
  246.         struct sockaddr_in *, voidp, fwd_fun));
  247. extern void fwd_reply(P_void);
  248. extern void get_args P((int, char*[]));
  249. extern char *getwire P((void));
  250. #ifdef NEED_MNTOPT_PARSER
  251. extern char *hasmntopt P((struct mntent*, char*));
  252. #endif /* NEED_MNTOPT_PARSER */
  253. extern int hasmntval P((struct mntent*, char*));
  254. extern void host_normalize P((char **));
  255. extern char *inet_dquad P((char*, unsigned long));
  256. extern void init_map P((am_node*, char*));
  257. extern void insert_am P((am_node*, am_node*));
  258. extern void ins_que P((qelem*, qelem*));
  259. extern int make_nfs_auth P((void));
  260. extern void make_root_node(P_void);
  261. extern int make_rpc_packet P((char*, int, u_long, struct rpc_msg*, voidp, xdrproc_t, AUTH*));
  262. extern void map_flush_srvr P((fserver*));
  263. extern void mapc_add_kv P((mnt_map*, char*, char*));
  264. extern mnt_map* mapc_find P((char*, char*));
  265. extern void mapc_free P((mnt_map*));
  266. extern int mapc_keyiter P((mnt_map*, void (*)(char*,voidp), voidp));
  267. extern int mapc_search P((mnt_map*, char*, char**));
  268. extern void mapc_reload(P_void);
  269. extern void mapc_showtypes P((FILE*));
  270. extern int mkdirs P((char*, int));
  271. extern void mk_fattr P((am_node*, enum ftype));
  272. extern void mnt_free P((struct mntent*));
  273. extern int mount_auto_node P((char*, voidp));
  274. extern int mount_automounter P((int));
  275. extern int mount_exported(P_void);
  276. extern int mount_fs P((struct mntent*, int, caddr_t, int, MTYPE_TYPE));
  277. extern int mount_node P((am_node*));
  278. extern mntfs* new_mntfs(P_void);
  279. extern void new_ttl P((am_node*));
  280. extern am_node* next_map P((int*));
  281. extern int nfs_srvr_port P((fserver*, u_short*, voidp));
  282. extern void normalize_slash P((char*));
  283. extern void ops_showfstypes P((FILE*));
  284. extern int pickup_rpc_reply P((voidp, int, voidp, xdrproc_t));
  285. extern mntlist* read_mtab P((char*));
  286. extern mntfs* realloc_mntfs  P((mntfs*, am_ops*, am_opts*, char*, char*, char*, char*));
  287. extern void rem_que P((qelem*));
  288. extern void reschedule_timeout_mp(P_void);
  289. extern void restart(P_void);
  290. #ifdef UPDATE_MTAB
  291. extern void rewrite_mtab P((mntlist *));
  292. #endif /* UPDATE_MTAB */
  293. extern void rmdirs P((char*));
  294. extern am_node* root_ap P((char*, int));
  295. extern int root_keyiter P((void (*)(char*,voidp), voidp));
  296. extern void root_newmap P((char*, char*, char*));
  297. extern void rpc_msg_init P((struct rpc_msg*, u_long, u_long, u_long));
  298. extern void run_task P((task_fun, voidp, cb_fun, voidp));
  299. extern void sched_task P((cb_fun, voidp, voidp));
  300. extern void show_rcs_info P((Const char*, char*));
  301. extern void sigchld P((int));
  302. extern void srvrlog P((fserver*, char*));
  303. extern char* str3cat P((char*, char*, char*, char*));
  304. extern char* strcat P((char*, Const char*)); /* C */
  305. extern int strcmp P((Const char*, Const char*)); /* C */
  306. extern char* strdup P((Const char*));
  307. extern int strlen P((Const char*)); /* C */
  308. extern char* strnsave P((Const char*, int));
  309. extern char* strrchr P((Const char*, int)); /* C */
  310. extern char* strealloc P((char*, char *));
  311. extern char** strsplit P((char*, int, int));
  312. extern int switch_option P((char*));
  313. extern int switch_to_logfile P((char*));
  314. extern void do_task_notify(P_void);
  315. extern int timeout P((unsigned int, void (*fn)(), voidp));
  316. extern void timeout_mp(P_void);
  317. extern void umount_exported(P_void);
  318. extern int umount_fs P((char*));
  319. /*extern int unmount_node P((am_node*));
  320. extern int unmount_node_wrap P((voidp));*/
  321. extern void unregister_amq(P_void);
  322. extern void untimeout P((int));
  323. extern int valid_key P((char*));
  324. extern void wakeup P((voidp));
  325. extern void wakeup_task P((int,int,voidp));
  326. extern void wakeup_srvr P((fserver*));
  327. extern void write_mntent P((struct mntent*));
  328. #ifdef UPDATE_MTAB
  329. extern void unlock_mntlist P((void));
  330. #else
  331. #define    unlock_mntlist()
  332. #endif /* UPDATE_MTAB */
  333.  
  334.  
  335. #define    ALLOC(ty)    ((struct ty *) xmalloc(sizeof(struct ty)))
  336.  
  337. /*
  338.  * Options
  339.  */
  340. struct am_opts {
  341.     char    *fs_glob;        /* Smashed copy of global options */
  342.     char    *fs_local;        /* Expanded copy of local options */
  343.     char    *fs_mtab;        /* Mount table entry */
  344.     /* Other options ... */
  345.     char    *opt_dev;
  346.     char    *opt_delay;
  347.     char    *opt_dir;
  348.     char    *opt_fs;
  349.     char    *opt_group;
  350.     char    *opt_mount;
  351.     char    *opt_opts;
  352.     char    *opt_pref;
  353.     char    *opt_cache;
  354.     char    *opt_rfs;
  355.     char    *opt_rhost;
  356.     char    *opt_sublink;
  357.     char    *opt_type;
  358.     char    *opt_unmount;
  359.     char    *opt_user;
  360. };
  361.  
  362. /*
  363.  * File Handle
  364.  *
  365.  * This is interpreted by indexing the exported array
  366.  * by fhh_id.
  367.  *
  368.  * The whole structure is mapped onto a standard fhandle_t
  369.  * when transmitted.
  370.  */
  371. struct am_fh {
  372.     int    fhh_pid;        /* process id */
  373.     int    fhh_id;            /* map id */
  374.     int    fhh_gen;        /* generation number */
  375. };
  376.  
  377. extern am_node *fh_to_mp P((nfs_fh*));
  378. extern am_node *fh_to_mp3 P((nfs_fh*,int*,int));
  379. extern void mp_to_fh P((am_node*, nfs_fh*));
  380. #define    fh_to_mp2(fhp, rp) fh_to_mp3(fhp, rp, VLOOK_CREATE)
  381. extern int auto_fmount P((am_node *mp));
  382. extern int auto_fumount P((am_node *mp));
  383.  
  384. #define    MAX_READDIR_ENTRIES    16
  385.  
  386. typedef char*    (*vfs_match)P((am_opts*));
  387. typedef int    (*vfs_init)P((mntfs*));
  388. typedef int    (*vmount_fs)P((am_node*));
  389. typedef int    (*vfmount_fs)P((mntfs*));
  390. typedef int    (*vumount_fs)P((am_node*));
  391. typedef int    (*vfumount_fs)P((mntfs*));
  392. typedef am_node*(*vlookuppn)P((am_node*, char*, int*, int));
  393. typedef int    (*vreaddir)P((am_node*, nfscookie, dirlist*, entry*, int));
  394. typedef am_node*(*vreadlink)P((am_node*, int*));
  395. typedef void    (*vmounted)P((mntfs*));
  396. typedef void    (*vumounted)P((am_node*));
  397. typedef fserver*(*vffserver)P((mntfs*));
  398.  
  399. struct am_ops {
  400.     char        *fs_type;
  401.     vfs_match    fs_match;
  402.     vfs_init    fs_init;
  403.     vmount_fs    mount_fs;
  404.     vfmount_fs    fmount_fs;
  405.     vumount_fs    umount_fs;
  406.     vfumount_fs    fumount_fs;
  407.     vlookuppn    lookuppn;
  408.     vreaddir    readdir;
  409.     vreadlink    readlink;
  410.     vmounted    mounted;
  411.     vumounted    umounted;
  412.     vffserver    ffserver;
  413.     int        fs_flags;
  414. };
  415. extern am_node *efs_lookuppn P((am_node*, char*, int*, int));
  416. extern int efs_readdir P((am_node*, nfscookie, dirlist*, entry*, int));
  417.  
  418. #define    VLOOK_CREATE    0x1
  419. #define    VLOOK_DELETE    0x2
  420.  
  421. #define FS_DIRECTORY    0x0001        /* This looks like a dir, not a link */
  422. #define    FS_MBACKGROUND    0x0002        /* Should background this mount */
  423. #define    FS_NOTIMEOUT    0x0004        /* Don't bother with timeouts */
  424. #define FS_MKMNT    0x0008        /* Need to make the mount point */
  425. #define FS_UBACKGROUND    0x0010        /* Unmount in background */
  426. #define    FS_BACKGROUND    (FS_MBACKGROUND|FS_UBACKGROUND)
  427. #define    FS_DISCARD    0x0020        /* Discard immediately on last reference */
  428. #define    FS_AMQINFO    0x0040        /* Amq is interested in this fs type */
  429.  
  430. #ifdef SUNOS4_COMPAT
  431. extern am_ops *sunos4_match P((am_opts*, char*, char*, char*, char*, char*));
  432. #endif /* SUNOS4_COMPAT */
  433. extern am_ops *ops_match P((am_opts*, char*, char*, char*, char*, char*));
  434. #include "fstype.h"
  435.  
  436. /*
  437.  * Per-mountpoint statistics
  438.  */
  439. struct am_stats {
  440.     time_t    s_mtime;    /* Mount time */
  441.     u_short    s_uid;        /* Uid of mounter */
  442.     int    s_getattr;    /* Count of getattrs */
  443.     int    s_lookup;    /* Count of lookups */
  444.     int    s_readdir;    /* Count of readdirs */
  445.     int    s_readlink;    /* Count of readlinks */
  446.     int    s_statfs;    /* Count of statfs */
  447. };
  448. typedef struct am_stats am_stats;
  449.  
  450. /*
  451.  * System statistics
  452.  */
  453. struct amd_stats {
  454.     int    d_drops;    /* Dropped requests */
  455.     int    d_stale;    /* Stale NFS handles */
  456.     int    d_mok;        /* Succesful mounts */
  457.     int    d_merr;        /* Failed mounts */
  458.     int    d_uerr;        /* Failed unmounts */
  459. };
  460. extern struct amd_stats amd_stats;
  461.  
  462. /*
  463.  * List of fileservers
  464.  */
  465. struct fserver {
  466.     qelem        fs_q;        /* List of fileservers */
  467.     int        fs_refc;    /* Number of references to this node */
  468.     char        *fs_host;    /* Normalized hostname of server */
  469.     struct sockaddr_in *fs_ip;    /* Network address of server */
  470.     int        fs_cid;        /* Callout id */
  471.     int        fs_pinger;    /* Ping (keepalive) interval */
  472.     int        fs_flags;    /* Flags */
  473.     char        *fs_type;    /* File server type */
  474.     voidp        fs_private;    /* Private data */
  475.     void        (*fs_prfree)();    /* Free private data */
  476. };
  477. #define    FSF_VALID    0x0001        /* Valid information available */
  478. #define    FSF_DOWN    0x0002        /* This fileserver is thought to be down */
  479. #define    FSF_ERROR    0x0004        /* Permanent error has occured */
  480. #define    FSF_WANT    0x0008        /* Want a wakeup call */
  481. #define    FSF_PINGING    0x0010        /* Already doing pings */
  482. #define    FSRV_ISDOWN(fs)    (((fs)->fs_flags & (FSF_DOWN|FSF_VALID)) == (FSF_DOWN|FSF_VALID))
  483. #define    FSRV_ISUP(fs)    (((fs)->fs_flags & (FSF_DOWN|FSF_VALID)) == (FSF_VALID))
  484.  
  485. /*
  486.  * List of mounted filesystems
  487.  */
  488. struct mntfs {
  489.     qelem        mf_q;        /* List of mounted filesystems */
  490.     am_ops        *mf_ops;    /* Operations on this mountpoint */
  491.     am_opts        *mf_fo;        /* File opts */
  492.     char        *mf_mount;    /* "/a/kiska/home/kiska" */
  493.     char        *mf_info;    /* Mount info */
  494.     char        *mf_auto;    /* Automount opts */
  495.     char        *mf_mopts;    /* FS mount opts */
  496.     fserver        *mf_server;    /* File server */
  497.     int        mf_flags;    /* Flags */
  498.     int        mf_error;    /* Error code from background mount */
  499.     int        mf_refc;    /* Number of references to this node */
  500.     int        mf_cid;        /* Callout id */
  501.     void        (*mf_prfree)();    /* Free private space */
  502.     voidp        mf_private;    /* Private - per-fs data */
  503. };
  504.  
  505. #define    MFF_MOUNTED    0x0001        /* Node is mounted */
  506. #define    MFF_MOUNTING    0x0002        /* Mount is in progress */
  507. #define    MFF_UNMOUNTING    0x0004        /* Unmount is in progress */
  508. #define    MFF_RESTART    0x0008        /* Restarted node */
  509. #define MFF_MKMNT    0x0010        /* Delete this node's am_mount */
  510. #define    MFF_ERROR    0x0020        /* This node failed to mount */
  511. #define    MFF_LOGDOWN    0x0040        /* Logged that this mount is down */
  512. #define    MFF_RSTKEEP    0x0080        /* Don't timeout this filesystem - restarted */
  513. #define    MFF_WANTTIMO    0x0100        /* Need a timeout call when not busy */
  514.  
  515. /*
  516.  * Map of auto-mount points.
  517.  */
  518. struct am_node {
  519.     int        am_mapno;    /* Map number */
  520.     mntfs        *am_mnt;    /* Mounted filesystem */
  521.     char        *am_name;    /* "kiska"
  522.                        Name of this node */
  523.     char        *am_path;    /* "/home/kiska"
  524.                        Path of this node's mount point */
  525.     char        *am_link;    /* "/a/kiska/home/kiska/this/that"
  526.                        Link to sub-directory */
  527.     am_node        *am_parent,    /* Parent of this node */
  528.             *am_ysib,    /* Younger sibling of this node */
  529.             *am_osib,    /* Older sibling of this node */
  530.             *am_child;    /* First child of this node */
  531.     struct attrstat    am_attr;    /* File attributes */
  532. #define am_fattr    am_attr.attrstat_u.attributes
  533.     int        am_flags;    /* Boolean flags */
  534.     int        am_error;    /* Specific mount error */
  535.     time_t        am_ttl;        /* Time to live */
  536.     int        am_timeo_w;    /* Wait interval */
  537.     int        am_timeo;    /* Timeout interval */
  538.     unsigned int    am_gen;        /* Generation number */
  539.     char        *am_pref;    /* Mount info prefix */
  540.     am_stats    am_stats;    /* Statistics gathering */
  541. };
  542.  
  543. #define    AMF_NOTIMEOUT    0x0001        /* This node never times out */
  544. #define    AMF_ROOT    0x0002        /* This is a root node */
  545.  
  546. #define    ONE_HOUR    (60 * 60)    /* One hour in seconds */
  547.  
  548. /*
  549.  * The following values can be tuned...
  550.  */
  551. #define    ALLOWED_MOUNT_TIME    40        /* 40s for a mount */
  552. #define    AM_TTL            (5 * 60)    /* Default cache period */
  553. #define    AM_TTL_W        (2 * 60)    /* Default unmount interval */
  554. #define    AM_PINGER        30        /* NFS ping interval for live systems */
  555. #define    AFS_TIMEO        8        /* Default afs timeout - .8s */
  556. #define    AFS_RETRANS        ((ALLOWED_MOUNT_TIME*10+5*afs_timeo)/afs_timeo * 2)
  557.                         /* Default afs retrans - 1/10th seconds */
  558.  
  559. #define    RPC_XID_PORTMAP        0
  560. #define    RPC_XID_MOUNTD        1
  561. #define    RPC_XID_NFSPING        2
  562. #define    RPC_XID_MASK        (0x0f)        /* 16 id's for now */
  563. #define    MK_RPC_XID(type_id, uniq)    ((type_id) | ((uniq) << 4))
  564.