]> git.decadent.org.uk Git - nfs-utils.git/blob - utils/statd/statd.h
statd - keep persistent state in sm/* files.
[nfs-utils.git] / utils / statd / statd.h
1 /* 
2  * Copyright (C) 1995-1997, 1999 Jeffrey A. Uphoff
3  * Modified by Olaf Kirch, Dec. 1996.
4  *
5  * NSM for Linux.
6  */
7
8 #ifdef HAVE_CONFIG_H
9 #include <config.h>
10 #endif
11
12 #include "sm_inter.h"
13 #include "system.h"
14 #include "log.h"
15
16 /*
17  * Paths and filenames.
18  */
19 #if defined(NFS_STATEDIR)
20 # define DEFAULT_DIR_BASE       NFS_STATEDIR "/"
21 #else
22 # define DEFAULT_DIR_BASE       "/var/lib/nfs/"
23 #endif
24
25 #define DEFAULT_SM_DIR          DEFAULT_DIR_BASE "sm"
26 #define DEFAULT_SM_BAK_DIR      DEFAULT_DIR_BASE "sm.bak"
27 #define DEFAULT_SM_STAT_PATH    DEFAULT_DIR_BASE "state"
28
29 /* Added to support run-time specification of state directory path.
30  * j_carlos_gomez@yahoo.com
31  */
32
33 extern char * DIR_BASE;
34 extern char *  SM_DIR;
35 extern char *  SM_BAK_DIR;
36 extern char *  SM_STAT_PATH;
37
38 /*
39  * Status definitions.
40  */
41 #define STAT_FAIL       stat_fail
42 #define STAT_SUCC       stat_succ
43
44 /*
45  * Function prototypes.
46  */
47 extern void     change_state(void);
48 extern void     do_regist(u_long, void (*)());
49 extern void     my_svc_run(void);
50 extern void     notify_hosts(void);
51 extern void     shuffle_dirs(void);
52 extern int      process_notify_list(void);
53 extern int      process_reply(FD_SET_TYPE *);
54 extern char *   xstrdup(const char *);
55 extern void *   xmalloc(size_t);
56 extern void     xunlink (char *, char *, short int);
57 extern void     load_state(void);
58
59 /*
60  * Host status structure and macros.
61  */
62 stat_chge               SM_stat_chge;
63 #define MY_NAME         SM_stat_chge.mon_name
64 #define MY_STATE        SM_stat_chge.state
65
66 /*
67  * Some timeout values.  (Timeout values are in whole seconds.)
68  */
69 #define CALLBACK_TIMEOUT         3 /* For client call-backs. */
70 #define NOTIFY_TIMEOUT           5 /* For status-change notifications. */
71 #define SELECT_TIMEOUT          10 /* Max select() timeout when work to do. */
72 #define MAX_TRIES                5 /* Max number of tries for any host. */
73
74 /*
75  * Modes of operation - Lon
76  */
77 extern int run_mode;
78 #define MODE_NODAEMON 1         /* No-daemon/foreground mode. */
79 #define MODE_LOG_STDERR 2       /* in foreground mode, log to stderr */
80 #define MODE_NOTIFY_ONLY 4      /* Send SM_NOTIFY to everyone monitored on
81                                    a single interface/alias */
82 /* LH - notify_only mode would be for notifying hosts on an IP alias
83  * that just came back up, for ex, when failing over a HA service to
84  * another host.... */
85 #define STATIC_HOSTNAME 8       /* Always use the hostname set by -n */
86 #define MODE_NO_NOTIFY  16      /* Don't notify peers of a reboot */
87 /*
88  * Program name and version pointers -- See statd.c for the reasoning
89  * as to why they're global.
90  */
91 extern char *name_p;            /* program basename */
92 extern const char *version_p;   /* program version */
93