Standardize License information
[openafs.git] / src / bozo / bnode.p.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #define BOP_TIMEOUT(bnode)      ((*(bnode)->ops->timeout)((bnode)))
11 #define BOP_GETSTAT(bnode, a)   ((*(bnode)->ops->getstat)((bnode),(a)))
12 #define BOP_SETSTAT(bnode, a)   ((*(bnode)->ops->setstat)((bnode),(a)))
13 #define BOP_DELETE(bnode)       ((*(bnode)->ops->delete)((bnode)))
14 #define BOP_PROCEXIT(bnode, a)  ((*(bnode)->ops->procexit)((bnode),(a)))
15 #define BOP_GETSTRING(bnode, a, b)      ((*(bnode)->ops->getstring)((bnode),(a), (b)))
16 #define BOP_GETPARM(bnode, n, b, l)     ((*(bnode)->ops->getparm)((bnode),(n),(b),(l)))
17 #define BOP_RESTARTP(bnode)     ((*(bnode)->ops->restartp)((bnode)))
18 #define BOP_HASCORE(bnode)      ((*(bnode)->ops->hascore)((bnode)))
19
20 struct bnode_ops {
21     struct bnode *(*create)(/* variable args */);
22     int (*timeout) (/* bnode */);
23     int (*getstat) (/* bnode, status */);
24     int (*setstat) (/* bnode, status */);
25     int (*delete) (/* bnode */);
26     int (*procexit) (/* bnode, proc */);
27     int (*getstring) (/* bnode, buffer, bufLen */);
28     int (*getparm) (/* bnode, parmIndex, buffer, bufLen */);
29     int (*restartp) (/* bnode */);
30     int (*hascore) (/* bnode */);
31 };
32
33 struct bnode_type {
34     struct bnode_type *next;
35     char *name;
36     struct bnode_ops *ops;
37 };
38
39 struct bnode_token {
40     struct bnode_token *next;
41     char *key;
42 };
43
44 struct bnode {
45     struct bnode *next;             /* next pointer in top-level's list */
46     char *name;                     /* instance name */
47     afs_int32 nextTimeout;                  /* next time this guy should be woken */
48     afs_int32 period;               /* period between calls */
49     afs_int32 rsTime;               /* time we started counting restarts */
50     afs_int32 rsCount;              /* count of restarts since rsTime */
51     struct bnode_type *type;        /* type object */
52     struct bnode_ops *ops;          /* functions implementing bnode class */
53     afs_int32 procStartTime;                /* last time a process was started */
54     afs_int32 procStarts;                   /* number of process starts */
55     afs_int32 lastAnyExit;                  /* last time a process exited, for any reason */
56     afs_int32 lastErrorExit;                /* last time a process exited unexpectedly */
57     afs_int32 errorCode;                    /* last exit return code */
58     afs_int32 errorSignal;                  /* last proc terminating signal */
59     char *lastErrorName;            /* name of proc that failed last */
60     char *notifier;                 /* notifier program to be executed on exits */
61     short refCount;                 /* reference count */
62     short flags;                    /* random flags */
63     char goal;                      /* 1=running or 0=not running */
64     char fileGoal;                  /* same, but to be stored in file */
65 };
66
67 struct bnode_proc {
68     struct bnode_proc *next;        /* next guy in top-level's list */
69     struct bnode *bnode;            /* bnode creating this process */
70     char *comLine;                  /* command line used to start this process */
71     char *coreName;                 /* optional core file component name */
72     afs_int32 pid;                          /* pid if created */
73     afs_int32 lastExit;             /* last termination code */
74     afs_int32 lastSignal;                   /* last signal that killed this guy */
75     afs_int32 flags;                        /* flags giving process state */
76 };
77     
78 struct ezbnode {
79     struct bnode b;
80     afs_int32 zapTime;          /* time we sent a sigterm */
81     char *command;
82     struct bnode_proc *proc;
83     afs_int32 lastStart;                /* time last started process */
84     char waitingForShutdown;    /* have we started any shutdown procedure? */
85     char running;   /* is process running? */
86     char killSent;  /* have we tried sigkill signal? */
87 };
88
89 /* this struct is used to construct a list of dirpaths, along with 
90  * their recommended permissions 
91  */
92 struct bozo_bosEntryStats {
93     const char *path;                   /* pathname to check */
94     int dir;                            /* 1=>dir or 0=>file */
95     int rootOwner;                      /* 1=>root must own */
96     int reqPerm;                        /* required permissions */
97     int proPerm;                        /* prohibited permissions */
98 };
99 /* bnode flags */
100 #define BNODE_NEEDTIMEOUT           1       /* timeouts are active */
101 #define BNODE_ACTIVE                2       /* in generic lists */
102 #define BNODE_WAIT                  4       /* someone waiting for status change */
103 #define BNODE_DELETE                8       /* delete this bnode asap */
104 #define BNODE_ERRORSTOP             0x10    /* stopped due to errors */
105
106 /* flags for bnode_proc */
107 #define BPROC_STARTED               1       /* ever started */
108 #define BPROC_EXITED                2       /* exited */
109
110 #define NONOTIFIER                  "__NONOTIFIER__"
111
112 /* status values for bnodes, and goals */
113 #define BSTAT_SHUTDOWN              0       /* shutdown normally */
114 #define BSTAT_NORMAL                1       /* running normally */
115 #define BSTAT_SHUTTINGDOWN          2       /* normal --> shutdown */
116 #define BSTAT_STARTINGUP            3       /* shutdown --> normal */
117
118 /* exit values indicating that NT SCM integrator should restart bosserver */
119 #ifdef AFS_NT40_ENV
120 #define BOSEXIT_RESTART        0xA0
121 #define BOSEXIT_DORESTART(code)  (((code) & ~(0xF)) == BOSEXIT_RESTART)
122 #define BOSEXIT_NOAUTH_FLAG    0x01
123 #define BOSEXIT_LOGGING_FLAG   0x02
124 #endif
125
126 /* max time to wait for fileserver shutdown */
127 #define FSSDTIME        (30 * 60) /* seconds */
128
129
130 /* calls back up to the generic bnode layer */
131 extern int bnode_SetTimeout(/* bnode, timeout */);
132 extern int bnode_Init(/* bnode, bnodeops */);
133 extern int bnode_Activate(/* bnode */);
134 extern int bnode_NewProc(/* bnode, execstring, corename, procaddr */);
135 extern int bnode_Init(/* no parms */);
136 extern afs_int32 bnode_Create();
137 extern struct bnode *bnode_FindInstance();