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
* );
41 struct bnode_ops
*ops
;
45 struct bnode_token
*next
;
50 struct opr_queue q
; /* prev/next entry 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 */
70 afs_int32 errorStopCount
; /* number of recent error stops */
71 afs_int32 errorStopDelay
; /* seconds to wait before retrying start */
75 struct opr_queue q
; /* prev/next entry in top-level's list */
76 struct bnode
*bnode
; /* bnode creating this process */
77 char *comLine
; /* command line used to start this process */
78 char *coreName
; /* optional core file component name */
79 afs_int32 pid
; /* pid if created */
80 afs_int32 lastExit
; /* last termination code */
81 afs_int32 lastSignal
; /* last signal that killed this guy */
82 afs_int32 flags
; /* flags giving process state */
87 afs_int32 zapTime
; /* time we sent a sigterm */
89 struct bnode_proc
*proc
;
90 afs_int32 lastStart
; /* time last started process */
91 char waitingForShutdown
; /* have we started any shutdown procedure? */
92 char running
; /* is process running? */
93 char killSent
; /* have we tried sigkill signal? */
96 /* this struct is used to construct a list of dirpaths, along with
97 * their recommended permissions
99 struct bozo_bosEntryStats
{
100 const char *path
; /* pathname to check */
101 int dir
; /* 1=>dir or 0=>file */
102 int rootOwner
; /* 1=>root must own */
103 int reqPerm
; /* required permissions */
104 int proPerm
; /* prohibited permissions */
107 #define BNODE_NEEDTIMEOUT 1 /* timeouts are active */
108 #define BNODE_ACTIVE 2 /* in generic lists */
109 #define BNODE_WAIT 4 /* someone waiting for status change */
110 #define BNODE_DELETE 8 /* delete this bnode asap */
111 #define BNODE_ERRORSTOP 0x10 /* stopped due to errors */
113 /* flags for bnode_proc */
114 #define BPROC_STARTED 1 /* ever started */
115 #define BPROC_EXITED 2 /* exited */
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 /* calls back up to the generic bnode layer */
124 extern int bnode_SetTimeout(struct bnode
*abnode
, afs_int32 atimeout
);
125 extern int bnode_Init(void);
126 extern int bnode_NewProc(struct bnode
*abnode
, char *aexecString
, char *coreName
, struct bnode_proc
**aproc
);
127 extern int bnode_InitBnode(struct bnode
*abnode
, struct bnode_ops
*abnodeops
, char *aname
);
128 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
);
129 extern struct bnode
*bnode_FindInstance(char *aname
);
130 extern int bnode_WaitStatus(struct bnode
*abnode
, int astatus
);
131 extern int bnode_SetStat(struct bnode
*abnode
, int agoal
);
132 extern int bnode_CreatePidFile(struct bnode
*abnode
, struct bnode_proc
*aproc
, char *name
);
133 extern int bnode_DestroyPidFile(struct bnode
*abnode
, struct bnode_proc
*aproc
);
134 extern int bnode_ResetErrorCount(struct bnode
*abnode
);