2 * Copyright 2000, International Business Machines Corporation and others.
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
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 #define BOP_PROCSTARTED(bnode,p) ((*(bnode)->ops->procstarted)((bnode),(p)))
24 struct bnode *(*create) ( char *, char *, char *, char *, char *, char *);
25 int (*timeout) ( struct bnode * );
26 int (*getstat) ( struct bnode *, afs_int32 * );
27 int (*setstat) ( struct bnode *, afs_int32 );
28 int (*delete) ( struct bnode * );
29 int (*procexit) ( struct bnode *, struct bnode_proc * );
30 int (*getstring) ( struct bnode *, char *abuffer, afs_int32 alen );
31 int (*getparm) ( struct bnode *, afs_int32 aindex, char *abuffer,
33 int (*restartp) ( struct bnode *);
34 int (*hascore) ( struct bnode *);
35 int (*procstarted) ( struct bnode *, struct bnode_proc * );
39 struct bnode_type *next;
41 struct bnode_ops *ops;
45 struct bnode_token *next;
50 struct bnode *next; /* next pointer in top-level's list */
51 char *name; /* instance name */
52 afs_int32 nextTimeout; /* next time this guy should be woken */
53 afs_int32 period; /* period between calls */
54 afs_int32 rsTime; /* time we started counting restarts */
55 afs_int32 rsCount; /* count of restarts since rsTime */
56 struct bnode_type *type; /* type object */
57 struct bnode_ops *ops; /* functions implementing bnode class */
58 afs_int32 procStartTime; /* last time a process was started */
59 afs_int32 procStarts; /* number of process starts */
60 afs_int32 lastAnyExit; /* last time a process exited, for any reason */
61 afs_int32 lastErrorExit; /* last time a process exited unexpectedly */
62 afs_int32 errorCode; /* last exit return code */
63 afs_int32 errorSignal; /* last proc terminating signal */
64 char *lastErrorName; /* name of proc that failed last */
65 char *notifier; /* notifier program to be executed on exits */
66 short refCount; /* reference count */
67 short flags; /* random flags */
68 char goal; /* 1=running or 0=not running */
69 char fileGoal; /* same, but to be stored in file */
73 struct bnode_proc *next; /* next guy in top-level's list */
74 struct bnode *bnode; /* bnode creating this process */
75 char *comLine; /* command line used to start this process */
76 char *coreName; /* optional core file component name */
77 afs_int32 pid; /* pid if created */
78 afs_int32 lastExit; /* last termination code */
79 afs_int32 lastSignal; /* last signal that killed this guy */
80 afs_int32 flags; /* flags giving process state */
85 afs_int32 zapTime; /* time we sent a sigterm */
87 struct bnode_proc *proc;
88 afs_int32 lastStart; /* time last started process */
89 char waitingForShutdown; /* have we started any shutdown procedure? */
90 char running; /* is process running? */
91 char killSent; /* have we tried sigkill signal? */
94 /* this struct is used to construct a list of dirpaths, along with
95 * their recommended permissions
97 struct bozo_bosEntryStats {
98 const char *path; /* pathname to check */
99 int dir; /* 1=>dir or 0=>file */
100 int rootOwner; /* 1=>root must own */
101 int reqPerm; /* required permissions */
102 int proPerm; /* prohibited permissions */
105 #define BNODE_NEEDTIMEOUT 1 /* timeouts are active */
106 #define BNODE_ACTIVE 2 /* in generic lists */
107 #define BNODE_WAIT 4 /* someone waiting for status change */
108 #define BNODE_DELETE 8 /* delete this bnode asap */
109 #define BNODE_ERRORSTOP 0x10 /* stopped due to errors */
111 /* flags for bnode_proc */
112 #define BPROC_STARTED 1 /* ever started */
113 #define BPROC_EXITED 2 /* exited */
115 #define NONOTIFIER "__NONOTIFIER__"
117 /* status values for bnodes, and goals */
118 #define BSTAT_SHUTDOWN 0 /* shutdown normally */
119 #define BSTAT_NORMAL 1 /* running normally */
120 #define BSTAT_SHUTTINGDOWN 2 /* normal --> shutdown */
121 #define BSTAT_STARTINGUP 3 /* shutdown --> normal */
123 /* exit values indicating that NT SCM integrator should restart bosserver */
125 #define BOSEXIT_RESTART 0xA0
126 #define BOSEXIT_DORESTART(code) (((code) & ~(0xF)) == BOSEXIT_RESTART)
127 #define BOSEXIT_NOAUTH_FLAG 0x01
128 #define BOSEXIT_LOGGING_FLAG 0x02
129 #define BOSEXIT_RXBIND_FLAG 0x04
132 /* max time to wait for fileserver shutdown */
133 #define FSSDTIME (30 * 60) /* seconds */
135 /* calls back up to the generic bnode layer */
136 extern int bnode_SetTimeout(struct bnode *abnode, afs_int32 atimeout);
137 extern int bnode_Init(void);
138 extern int bnode_NewProc(struct bnode *abnode, char *aexecString, char *coreName, struct bnode_proc **aproc);
139 extern int bnode_InitBnode(struct bnode *abnode, struct bnode_ops *abnodeops, char *aname);
140 extern afs_int32 bnode_Create(char *atype, char *ainstance, struct bnode ** abp, char *ap1, char *ap2, char *ap3, char *ap4, char *ap5, char *notifier, int fileGoal, int rewritefile);
141 extern struct bnode *bnode_FindInstance(char *aname);
142 extern int bnode_WaitStatus(struct bnode *abnode, int astatus);
143 extern int bnode_SetStat(struct bnode *abnode, int agoal);
144 extern int bnode_CreatePidFile(struct bnode *abnode, struct bnode_proc *aproc, char *name);
145 extern int bnode_DestroyPidFile(struct bnode *abnode, struct bnode_proc *aproc);