79d9bba063e1f319e7a60e784826061f6005ffce
[openafs.git] / src / libadmin / bos / afs_bosAdmin.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 #ifndef OPENAFS_BOS_ADMIN_H
11 #define OPENAFS_BOS_ADMIN_H
12
13 #include <afs/param.h>
14 #include <afs/afs_Admin.h>
15 #include <afs/afs_vosAdmin.h>
16 #include <afs/afs_kasAdmin.h>
17
18 #define BOS_MAX_NAME_LEN 256
19 #define BOS_MAX_PROCESS_PARAMETERS 6
20 #define BOS_ENCRYPTION_KEY_LEN 8
21
22 typedef enum {
23     BOS_PROCESS_SIMPLE,
24     BOS_PROCESS_FS,
25     BOS_PROCESS_CRON
26 } bos_ProcessType_t, *bos_ProcessType_p;
27
28 /*
29  * ASSUMPTION
30  * These execution state flags are defined to be == the BOZO BSTAT_
31  * values.  This allows us to directly map from one to the other.
32  * If the BOZO BSTAT_ flags are ever modified, these guys need to
33  * be changed as well.
34  */
35
36 typedef enum {
37     BOS_PROCESS_STOPPED,
38     BOS_PROCESS_RUNNING,
39     BOS_PROCESS_STOPPING,
40     BOS_PROCESS_STARTING
41 } bos_ProcessExecutionState_t, *bos_ProcessExecutionState_p;
42
43 typedef enum {
44     BOS_PROCESS_OK = 0x0,
45     BOS_PROCESS_CORE_DUMPED = 0x1,
46     BOS_PROCESS_TOO_MANY_ERRORS = 0x2,
47     BOS_PROCESS_BAD_FILE_ACCESS = 0x4
48 } bos_ProcessState_t, *bos_ProcessState_p;
49
50 typedef enum {
51     BOS_AUTH_REQUIRED,
52     BOS_NO_AUTH
53 } bos_Auth_t, *bos_Auth_p;
54
55 typedef enum {
56     BOS_PRUNE,
57     BOS_DONT_PRUNE
58 } bos_Prune_t, *bos_Prune_p;
59
60 typedef enum {
61     BOS_RESTART_WEEKLY,
62     BOS_RESTART_DAILY
63 } bos_Restart_t, *bos_Restart_p;
64
65 typedef struct bos_ProcessInfo {
66     bos_ProcessExecutionState_t processGoal;
67     unsigned long processStartTime;
68     unsigned long numberProcessStarts;
69     unsigned long processExitTime;
70     unsigned long processExitErrorTime;
71     unsigned long processErrorCode;
72     unsigned long processErrorSignal;
73     bos_ProcessState_t state;
74 } bos_ProcessInfo_t, *bos_ProcessInfo_p;
75
76 typedef struct bos_encryptionKeyStatus {
77     int lastModificationDate;
78     int lastModificationMicroSeconds;
79     unsigned int checkSum;
80 } bos_encryptionKeyStatus_t, *bos_encryptionKeyStatus_p;
81
82 typedef struct bos_KeyInfo {
83     int keyVersionNumber;
84     kas_encryptionKey_t key;
85     bos_encryptionKeyStatus_t keyStatus;
86 } bos_KeyInfo_t, *bos_KeyInfo_p;
87
88 typedef enum {
89     BOS_RESTART_TIME_HOUR = 0x1,
90     BOS_RESTART_TIME_MINUTE = 0x2,
91     BOS_RESTART_TIME_SECOND = 0x4,
92     BOS_RESTART_TIME_DAY = 0x8,
93     BOS_RESTART_TIME_NEVER = 0x10,
94     BOS_RESTART_TIME_NOW = 0x20
95 } bos_RestartTimeFields_t, *bos_RestartTimeFields_p;
96
97 typedef struct bos_RestartTime {
98     bos_RestartTimeFields_t mask;
99     short hour;
100     short min;
101     short sec;
102     short day;
103 } bos_RestartTime_t, *bos_RestartTime_p;
104
105 typedef enum {
106     BOS_RESTART_BOS_SERVER,
107     BOS_DONT_RESTART_BOS_SERVER
108 } bos_RestartBosServer_t, *bos_RestartBosServer_p;
109
110 typedef enum {
111     BOS_SALVAGE_DAMAGED_VOLUMES,
112     BOS_DONT_SALVAGE_DAMAGED_VOLUMES
113 } bos_SalvageDamagedVolumes_t, *bos_SalvageDamagedVolumes_p;
114
115 typedef enum {
116     BOS_SALVAGE_WRITE_INODES,
117     BOS_SALVAGE_DONT_WRITE_INODES
118 } bos_WriteInodes_t, *bos_WriteInodes_p;
119
120 typedef enum {
121     BOS_SALVAGE_WRITE_ROOT_INODES,
122     BOS_SALVAGE_DONT_WRITE_ROOT_INODES
123 } bos_WriteRootInodes_t, *bos_WriteRootInodes_p;
124
125 typedef enum {
126     BOS_SALVAGE_FORCE_DIRECTORIES,
127     BOS_SALVAGE_DONT_FORCE_DIRECTORIES
128 } bos_ForceDirectory_t, *bos_ForceDirectory_p;
129
130 typedef enum {
131     BOS_SALVAGE_FORCE_BLOCK_READS,
132     BOS_SALVAGE_DONT_FORCE_BLOCK_READS
133 } bos_ForceBlockRead_t, *bos_ForceBlockRead_p;
134
135 extern int ADMINAPI bos_ServerOpen(const void *cellHandle,
136                                    const char *serverName,
137                                    void **serverHandleP, afs_status_p st);
138
139 extern int ADMINAPI bos_ServerClose(const void *serverHandle,
140                                     afs_status_p st);
141
142 extern int ADMINAPI bos_ProcessCreate(const void *serverHandle,
143                                       char *processName,
144                                       bos_ProcessType_t processType,
145                                       char *process,
146                                       char *cronTime,
147                                       char *notifier, afs_status_p st);
148
149 extern int ADMINAPI bos_FSProcessCreate(const void *serverHandle,
150                                         char *processName,
151                                         char *fileserverPath,
152                                         char *volserverPath,
153                                         char *salvagerPath,
154                                         char *notifier,
155                                         afs_status_p st);
156
157 extern int ADMINAPI bos_ProcessDelete(const void *serverHandle,
158                                       char *processName,
159                                       afs_status_p st);
160
161 extern int ADMINAPI bos_ProcessExecutionStateGet(const void *serverHandle,
162                                                  char *processName,
163                                                  bos_ProcessExecutionState_p
164                                                  processStatusP,
165                                                  char *auxiliaryProcessStatus,
166                                                  afs_status_p st);
167
168 extern int ADMINAPI bos_ProcessExecutionStateSet(const void *serverHandle,
169                                                  const char *processName,
170                                                  const bos_ProcessExecutionState_t
171                                                  processStatus,
172                                                  afs_status_p st);
173
174 extern int ADMINAPI bos_ProcessExecutionStateSetTemporary(const void
175                                                           *serverHandle, char
176                                                           *processName,
177                                                           bos_ProcessExecutionState_t
178                                                           processStatus,
179                                                           afs_status_p st);
180
181 extern int ADMINAPI bos_ProcessNameGetBegin(const void *serverHandle,
182                                             void **iterationIdP,
183                                             afs_status_p st);
184
185 extern int ADMINAPI bos_ProcessNameGetNext(const void *iterationId,
186                                            char *processName,
187                                            afs_status_p st);
188
189 extern int ADMINAPI bos_ProcessNameGetDone(const void *iterationId,
190                                            afs_status_p st);
191
192 extern int ADMINAPI bos_ProcessInfoGet(const void *serverHandle,
193                                        char *processName,
194                                        bos_ProcessType_p processTypeP,
195                                        bos_ProcessInfo_p processInfoP,
196                                        afs_status_p st);
197
198 extern int ADMINAPI bos_ProcessParameterGetBegin(const void *serverHandle,
199                                                  const char *processName,
200                                                  void **iterationIdP,
201                                                  afs_status_p st);
202
203 extern int ADMINAPI bos_ProcessParameterGetNext(const void *iterationId,
204                                                 char *parameter,
205                                                 afs_status_p st);
206
207 extern int ADMINAPI bos_ProcessParameterGetDone(const void *iterationId,
208                                                 afs_status_p st);
209
210 extern int ADMINAPI bos_ProcessNotifierGet(const void *serverHandle,
211                                            const char *processName,
212                                            char *notifier, afs_status_p st);
213
214 extern int ADMINAPI bos_ProcessRestart(const void *serverHandle,
215                                        const char *processName,
216                                        afs_status_p st);
217
218 extern int ADMINAPI bos_ProcessAllStop(const void *serverHandle,
219                                        afs_status_p st);
220
221 extern int ADMINAPI bos_ProcessAllStart(const void *serverHandle,
222                                         afs_status_p st);
223
224 extern int ADMINAPI bos_ProcessAllWaitStop(const void *serverHandle,
225                                            afs_status_p st);
226
227 extern int ADMINAPI bos_ProcessAllWaitTransition(const void *serverHandle,
228                                                  afs_status_p st);
229
230 extern int ADMINAPI bos_ProcessAllStopAndRestart(const void *serverHandle,
231                                                  bos_RestartBosServer_t
232                                                  restartBosServer,
233                                                  afs_status_p st);
234
235 extern int ADMINAPI bos_AdminCreate(const void *serverHandle,
236                                     const char *adminName, afs_status_p st);
237
238 extern int ADMINAPI bos_AdminDelete(const void *serverHandle,
239                                     const char *adminName, afs_status_p st);
240
241 extern int ADMINAPI bos_AdminGetBegin(const void *serverHandle,
242                                       void **iterationIdP, afs_status_p st);
243
244 extern int ADMINAPI bos_AdminGetNext(const void *iterationId, char *adminName,
245                                      afs_status_p st);
246
247 extern int ADMINAPI bos_AdminGetDone(const void *iterationId,
248                                      afs_status_p st);
249
250 extern int ADMINAPI bos_KeyCreate(const void *serverHandle,
251                                   int keyVersionNumber,
252                                   const kas_encryptionKey_p key,
253                                   afs_status_p st);
254
255 extern int ADMINAPI bos_KeyDelete(const void *serverHandle,
256                                   int keyVersionNumber, afs_status_p st);
257
258 extern int ADMINAPI bos_KeyGetBegin(const void *serverHandle,
259                                     void **iterationIdP, afs_status_p st);
260
261 extern int ADMINAPI bos_KeyGetNext(const void *iterationId,
262                                    bos_KeyInfo_p keyP, afs_status_p st);
263
264 extern int ADMINAPI bos_KeyGetDone(const void *iterationId, afs_status_p st);
265
266 extern int ADMINAPI bos_CellSet(const void *serverHandle,
267                                 const char *cellName, afs_status_p st);
268
269 extern int ADMINAPI bos_CellGet(const void *serverHandle, char *cellName,
270                                 afs_status_p st);
271
272 extern int ADMINAPI bos_HostCreate(const void *serverHandle,
273                                    const char *hostName, afs_status_p st);
274
275 extern int ADMINAPI bos_HostDelete(const void *serverHandle,
276                                    const char *hostName, afs_status_p st);
277
278 extern int ADMINAPI bos_HostGetBegin(const void *serverHandle,
279                                      void **iterationIdP, afs_status_p st);
280
281 extern int ADMINAPI bos_HostGetNext(const void *iterationId, char *hostName,
282                                     afs_status_p st);
283
284 extern int ADMINAPI bos_HostGetDone(const void *iterationId, afs_status_p st);
285
286 extern int ADMINAPI bos_ExecutableCreate(const void *serverHandle,
287                                          const char *sourceFile,
288                                          const char *destFile,
289                                          afs_status_p st);
290
291 extern int ADMINAPI bos_ExecutableRevert(const void *serverHandle,
292                                          const char *execFile,
293                                          afs_status_p st);
294
295 extern int ADMINAPI bos_ExecutableTimestampGet(const void *serverHandle,
296                                                const char *execFile,
297                                                unsigned long *newTime,
298                                                unsigned long *oldTime,
299                                                unsigned long *bakTime,
300                                                afs_status_p st);
301
302 extern int ADMINAPI bos_ExecutablePrune(const void *serverHandle,
303                                         bos_Prune_t oldFiles,
304                                         bos_Prune_t bakFiles,
305                                         bos_Prune_t coreFiles,
306                                         afs_status_p st);
307
308 extern int ADMINAPI bos_ExecutableRestartTimeSet(const void *serverHandle,
309                                                  bos_Restart_t type,
310                                                  bos_RestartTime_t time,
311                                                  afs_status_p st);
312
313 extern int ADMINAPI bos_ExecutableRestartTimeGet(const void *serverHandle,
314                                                  bos_Restart_t type,
315                                                  bos_RestartTime_p timeP,
316                                                  afs_status_p st);
317
318 extern int ADMINAPI bos_LogGet(const void *serverHandle, const char *log,
319                                unsigned long *logBufferSizeP, char *logData,
320                                afs_status_p st);
321
322 extern int ADMINAPI bos_AuthSet(const void *serverHandle, bos_Auth_t auth,
323                                 afs_status_p st);
324
325 extern int ADMINAPI bos_CommandExecute(const void *serverHandle,
326                                        const char *command, afs_status_p st);
327
328 extern int ADMINAPI bos_Salvage(const void *cellHandle,
329                                 const void *serverHandle,
330                                 const char *partitionName,
331                                 const char *volumeName, int numSalvagers,
332                                 const char *tmpDir, const char *logFile,
333                                 vos_force_t force,
334                                 bos_SalvageDamagedVolumes_t
335                                 salvageDamagedVolumes,
336                                 bos_WriteInodes_t writeInodes,
337                                 bos_WriteRootInodes_t writeRootInodes,
338                                 bos_ForceDirectory_t forceDirectory,
339                                 bos_ForceBlockRead_t forceBlockRead,
340                                 afs_status_p st);
341
342 static_inline struct bozo_key *
343 kas_to_bozoptr(kas_encryptionKey_p key)
344 {
345     return (struct bozo_key *)key;
346 }
347 #endif /* OPENAFS_BOS_ADMIN_H */