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 #include <afsconfig.h>
11 #include <afs/param.h>
17 #include <rx/rxstat.h>
18 #include <afs/afs_AdminErrors.h>
19 #include <afs/afs_utilAdmin.h>
20 #include <afs/bosint.h>
21 #include <afs/bnode.h>
22 #include <afs/ktime.h>
23 #include <afs/dirpath.h>
25 #include "afs_bosAdmin.h"
26 #include "../adminutil/afs_AdminInternal.h"
28 typedef struct bos_server {
31 struct rx_connection *server;
32 struct rx_connection *server_encrypt;
33 struct rx_connection *server_stats;
35 } bos_server_t, *bos_server_p;
38 * isValidServerHandle - validate a bos_server_p.
42 * IN serverHandle - the handle to validate
46 * No locks are obtained or released by this function
50 * Returns != 0 upon successful completion.
54 isValidServerHandle(const bos_server_p serverHandle, afs_status_p st)
59 if (serverHandle == NULL) {
60 tst = ADMBOSSERVERHANDLENULL;
61 goto fail_IsValidServerHandle;
64 if ((serverHandle->begin_magic != BEGIN_MAGIC)
65 || (serverHandle->end_magic != END_MAGIC)) {
66 tst = ADMBOSSERVERHANDLEBADMAGIC;
67 goto fail_IsValidServerHandle;
70 if (serverHandle->is_valid == 0) {
71 tst = ADMBOSSERVERHANDLEINVALID;
72 goto fail_IsValidServerHandle;
75 if (serverHandle->server == NULL) {
76 tst = ADMBOSSERVERHANDLENOSERVER;
77 goto fail_IsValidServerHandle;
80 if (serverHandle->server_encrypt == NULL) {
81 tst = ADMBOSSERVERHANDLENOSERVER;
82 goto fail_IsValidServerHandle;
86 fail_IsValidServerHandle:
95 * IsValidCellHandle - verify that a cell handle can be used to make bos
100 * IN cellHandle - the cellHandle to be validated.
104 * No locks are obtained or released by this function
108 * Returns != 0 upon successful completion.
112 IsValidCellHandle(afs_cell_handle_p cellHandle, afs_status_p st)
115 afs_status_t tst = 0;
117 if (!CellHandleIsValid((void *)cellHandle, &tst)) {
118 goto fail_IsValidCellHandle;
121 if (cellHandle->tokens == NULL) {
122 tst = ADMBOSCELLHANDLENOTOKENS;
123 goto fail_IsValidCellHandle;
127 fail_IsValidCellHandle:
136 * bos_ServerOpen - open a bos server for work.
140 * IN cellHandle - a previously opened cellHandle.
142 * IN serverName - the name of the machine that houses the bosserver of
145 * OUT serverHandleP - upon successful completion, this void pointer
146 * will point to a valid server handle for use in future operations.
150 * No locks are obtained or released by this function
154 * Returns != 0 upon successful completion.
158 bos_ServerOpen(const void *cellHandle, const char *serverName,
159 void **serverHandleP, afs_status_p st)
162 afs_status_t tst = 0;
163 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
164 bos_server_p bos_server = (bos_server_p) malloc(sizeof(bos_server_t));
168 * Validate parameters
171 if (!IsValidCellHandle(c_handle, &tst)) {
172 goto fail_bos_ServerOpen;
175 if ((serverName == NULL) || (*serverName == 0)) {
176 tst = ADMBOSSERVERNAMENULL;
177 goto fail_bos_ServerOpen;
180 if (serverHandleP == NULL) {
181 tst = ADMBOSSERVERHANDLEPNULL;
182 goto fail_bos_ServerOpen;
185 if (util_AdminServerAddressGetFromName(serverName, &serverAddress, &tst)
187 goto fail_bos_ServerOpen;
190 if (bos_server == NULL) {
192 goto fail_bos_ServerOpen;
196 rx_GetCachedConnection(htonl(serverAddress), htons(AFSCONF_NANNYPORT),
198 c_handle->tokens->afs_sc[c_handle->tokens->
200 c_handle->tokens->sc_index);
202 bos_server->server_encrypt =
203 rx_GetCachedConnection(htonl(serverAddress), htons(AFSCONF_NANNYPORT),
205 c_handle->tokens->afs_encrypt_sc[c_handle->
208 c_handle->tokens->sc_index);
210 bos_server->server_stats =
211 rx_GetCachedConnection(htonl(serverAddress), htons(AFSCONF_NANNYPORT),
213 c_handle->tokens->afs_sc[c_handle->tokens->
215 c_handle->tokens->sc_index);
217 if ((bos_server->server == NULL) || (bos_server->server_encrypt == NULL)) {
218 tst = ADMBOSSERVERNOCONNECTION;
219 goto fail_bos_ServerOpen;
222 bos_server->begin_magic = BEGIN_MAGIC;
223 bos_server->is_valid = 1;
224 bos_server->end_magic = END_MAGIC;
226 *serverHandleP = (void *)bos_server;
231 if ((rc == 0) && (bos_server != NULL)) {
232 if (bos_server->server) {
233 rx_ReleaseCachedConnection(bos_server->server);
235 if (bos_server->server_encrypt) {
236 rx_ReleaseCachedConnection(bos_server->server_encrypt);
248 * bos_ServerClose - close a bos server handle
252 * IN serverHandle - a bos server handle previously returned by bos_ServerOpen
256 * No locks are obtained or released by this function
260 * Returns != 0 upon successful completion.
264 bos_ServerClose(const void *serverHandle, afs_status_p st)
267 afs_status_t tst = 0;
268 bos_server_p b_handle = (bos_server_p) serverHandle;
270 if (isValidServerHandle(b_handle, &tst)) {
271 rx_ReleaseCachedConnection(b_handle->server);
272 b_handle->is_valid = 0;
284 * bos_ProcessCreate - create a new process to run at a bos server.
288 * IN serverHandle - a previously opened serverHandle.
290 * IN processName - the name of the process to create.
292 * IN processType - the type of process to create.
294 * IN process - the path to the process binary at the bos server.
296 * IN cronTime - the time specification for cron processes.
298 * IN notifier - the path to the notifier binary at the bos server.
302 * No locks are obtained or released by this function
306 * Returns != 0 upon successful completion.
310 * CAUTION - this list must match bos_ProcessType_t definition
313 static char *processTypes[] = { "simple", "fs", "cron", 0 };
316 bos_ProcessCreate(const void *serverHandle, char *processName,
317 bos_ProcessType_t processType, char *process,
318 char *cronTime, char *notifier, afs_status_p st)
321 afs_status_t tst = 0;
322 bos_server_p b_handle = (bos_server_p) serverHandle;
324 if (!isValidServerHandle(b_handle, &tst)) {
325 goto fail_bos_ProcessCreate;
328 if (processType == BOS_PROCESS_FS) {
329 tst = ADMBOSPROCESSCREATEBADTYPE;
330 goto fail_bos_ProcessCreate;
333 if ((processName == NULL) || (*processName == 0)) {
334 tst = ADMBOSPROCESSNAMENULL;
335 goto fail_bos_ProcessCreate;
338 if ((process == NULL) || (*process == 0)) {
339 tst = ADMBOSPROCESSNULL;
340 goto fail_bos_ProcessCreate;
343 if ((processType == BOS_PROCESS_CRON) && (cronTime == NULL)) {
344 tst = ADMBOSCRONTIMENULL;
345 goto fail_bos_ProcessCreate;
348 if ((processType == BOS_PROCESS_SIMPLE) && (cronTime != NULL)) {
349 tst = ADMBOSCRONTIMENOTNULL;
350 goto fail_bos_ProcessCreate;
354 BOZO_CreateBnode(b_handle->server, processTypes[processType],
355 processName, process, (cronTime) ? cronTime : "", "",
356 "", "", (notifier) ? notifier : NONOTIFIER);
361 fail_bos_ProcessCreate:
370 * bos_FSProcessCreate - create the fs group of processes at the boserver.
374 * IN serverHandle - a previously opened serverHandle.
376 * IN processName - the name of the process to create.
378 * IN fileserverPath - the path to the fileserver binary at the bos server.
380 * IN volserverPath - the path to the volserver binary at the bos server.
382 * IN salvagerPath - the path to the salvager binary at the bos server.
384 * IN notifier - the path to the notifier binary at the bos server.
388 * No locks are obtained or released by this function
392 * Returns != 0 upon successful completion.
396 bos_FSProcessCreate(const void *serverHandle, char *processName,
397 char *fileserverPath, char *volserverPath,
398 char *salvagerPath, char *notifier,
402 afs_status_t tst = 0;
403 bos_server_p b_handle = (bos_server_p) serverHandle;
405 if (!isValidServerHandle(b_handle, &tst)) {
406 goto fail_bos_ProcessCreate;
409 if ((processName == NULL) || (*processName == 0)) {
410 tst = ADMBOSPROCESSNAMENULL;
411 goto fail_bos_ProcessCreate;
414 if ((fileserverPath == NULL) || (*fileserverPath == 0)) {
415 tst = ADMBOSFILESERVERPATHNULL;
416 goto fail_bos_ProcessCreate;
419 if ((volserverPath == NULL) || (*volserverPath == 0)) {
420 tst = ADMBOSVOLSERVERPATHNULL;
421 goto fail_bos_ProcessCreate;
424 if ((salvagerPath == NULL) || (*salvagerPath == 0)) {
425 tst = ADMBOSSALVAGERPATHNULL;
426 goto fail_bos_ProcessCreate;
430 BOZO_CreateBnode(b_handle->server, processTypes[BOS_PROCESS_FS],
431 processName, fileserverPath, volserverPath,
432 salvagerPath, "", "",
433 (notifier) ? notifier : NONOTIFIER);
438 fail_bos_ProcessCreate:
447 * bos_ProcessDelete - delete an existing process at a bos server.
451 * IN serverHandle - a previously opened serverHandle.
453 * IN processName - the name of the process to delete.
457 * No locks are obtained or released by this function
461 * Returns != 0 upon successful completion.
465 bos_ProcessDelete(const void *serverHandle, char *processName,
469 afs_status_t tst = 0;
470 bos_server_p b_handle = (bos_server_p) serverHandle;
472 if (!isValidServerHandle(b_handle, &tst)) {
473 goto fail_bos_ProcessDelete;
476 if ((processName == NULL) || (*processName == 0)) {
477 tst = ADMBOSPROCESSNAMENULL;
478 goto fail_bos_ProcessDelete;
481 tst = BOZO_DeleteBnode(b_handle->server, processName);
487 fail_bos_ProcessDelete:
496 * bos_ProcessExecutionStateGet - get the current execution state of a
501 * IN serverHandle - a previously opened serverHandle.
503 * IN processName - the name of the process to retrieve.
505 * OUT processStatusP - upon successful completion the process execution state
507 * OUT auxiliaryProcessStatus - set to point to aux proc status if available.
508 * Pass a pointer to an char array at least BOS_MAX_NAME_LEN long.
512 * No locks are obtained or released by this function
516 * Returns != 0 upon successful completion.
520 bos_ProcessExecutionStateGet(const void *serverHandle,
522 bos_ProcessExecutionState_p processStatusP,
523 char *auxiliaryProcessStatus, afs_status_p st)
526 afs_status_t tst = 0;
527 bos_server_p b_handle = (bos_server_p) serverHandle;
530 if (!isValidServerHandle(b_handle, &tst)) {
531 goto fail_bos_ProcessExecutionStateGet;
534 if ((processName == NULL) || (*processName == 0)) {
535 tst = ADMBOSPROCESSNAMENULL;
536 goto fail_bos_ProcessExecutionStateGet;
539 if (processStatusP == NULL) {
540 tst = ADMBOSPROCESSSTATUSPNULL;
541 goto fail_bos_ProcessExecutionStateGet;
544 if (auxiliaryProcessStatus == NULL) {
545 tst = ADMBOSAUXILIARYPROCESSSTATUSNULL;
546 goto fail_bos_ProcessExecutionStateGet;
550 BOZO_GetStatus(b_handle->server, processName, &state,
551 &auxiliaryProcessStatus);
554 goto fail_bos_ProcessExecutionStateGet;
557 *processStatusP = (bos_ProcessExecutionState_t) state;
560 fail_bos_ProcessExecutionStateGet:
569 * SetExecutionState - set the execution state of a process
573 * IN serverHandle - a previously opened serverHandle.
575 * IN processName - the name of the process to modify.
577 * IN processStatus - the new process state.
579 * IN func - the function to call to set the status.
583 * No locks are obtained or released by this function
587 * Returns != 0 upon successful completion.
591 SetExecutionState(const void *serverHandle, const char *processName,
592 const bos_ProcessExecutionState_t processStatus,
593 int (*func) (struct rx_connection *, char *,
594 afs_int32), afs_status_p st)
597 afs_status_t tst = 0;
598 bos_server_p b_handle = (bos_server_p) serverHandle;
601 if (!isValidServerHandle(b_handle, &tst)) {
602 goto fail_SetExecutionState;
605 if ((processName == NULL) || (*processName == 0)) {
606 tst = ADMBOSPROCESSNAMENULL;
607 goto fail_SetExecutionState;
610 if ((processStatus != BOS_PROCESS_STOPPED)
611 && (processStatus != BOS_PROCESS_RUNNING)) {
612 tst = ADMBOSPROCESSSTATUSSET;
613 goto fail_SetExecutionState;
616 state = (afs_int32) processStatus;
618 tst = func(b_handle->server, (char *)processName, state);
624 fail_SetExecutionState:
633 * bos_ProcessExecutionStateSet - set the execution state of a process
637 * IN serverHandle - a previously opened serverHandle.
639 * IN processName - the name of the process to modify.
641 * IN processStatus - the new process state.
645 * No locks are obtained or released by this function
649 * Returns != 0 upon successful completion.
653 bos_ProcessExecutionStateSet(const void *serverHandle,
654 const char *processName,
655 const bos_ProcessExecutionState_t processStatus,
658 return SetExecutionState(serverHandle, processName, processStatus,
663 * bos_ProcessExecutionStateSetTemporary - set the execution state of a process
668 * IN serverHandle - a previously opened serverHandle.
670 * IN processName - the name of the process to modify.
672 * IN processStatus - the new process state.
676 * No locks are obtained or released by this function
680 * Returns != 0 upon successful completion.
684 bos_ProcessExecutionStateSetTemporary(const void *serverHandle,
686 bos_ProcessExecutionState_t
687 processStatus, afs_status_p st)
689 return SetExecutionState(serverHandle, processName, processStatus,
690 BOZO_SetTStatus, st);
694 * The iterator functions and data for the process name retrieval functions
697 typedef struct process_name_get {
699 struct rx_connection *server;
700 char process[CACHED_ITEMS][BOS_MAX_NAME_LEN];
701 } process_name_get_t, *process_name_get_p;
704 GetProcessNameRPC(void *rpc_specific, int slot, int *last_item,
705 int *last_item_contains_data, afs_status_p st)
708 afs_status_t tst = 0;
709 process_name_get_p proc = (process_name_get_p) rpc_specific;
710 char *ptr = (char *)&proc->process[slot];
712 tst = BOZO_EnumerateInstance(proc->server, proc->next++, &ptr);
716 } else if (tst == BZDOM) {
720 *last_item_contains_data = 0;
730 GetProcessNameFromCache(void *rpc_specific, int slot, void *dest,
734 afs_status_t tst = 0;
735 process_name_get_p proc = (process_name_get_p) rpc_specific;
737 strcpy((char *)dest, (char *)&proc->process[slot]);
747 * bos_ProcessNameGetBegin - begin iterating over the list of processes
748 * at a particular bos server.
752 * IN serverHandle - a previously opened serverHandle.
754 * OUT iter - an iterator that can be passed to bos_ProcessNameGetNext
755 * to retrieve the process names.
759 * No locks are obtained or released by this function
763 * Returns != 0 upon successful completion.
768 bos_ProcessNameGetBegin(const void *serverHandle, void **iterationIdP,
772 afs_status_t tst = 0;
773 bos_server_p b_handle = (bos_server_p) serverHandle;
774 afs_admin_iterator_p iter =
775 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
776 process_name_get_p proc =
777 (process_name_get_p) malloc(sizeof(process_name_get_t));
779 if (!isValidServerHandle(b_handle, &tst)) {
780 goto fail_bos_ProcessNameGetBegin;
783 if (iterationIdP == NULL) {
784 tst = ADMITERATIONIDPNULL;
785 goto fail_bos_ProcessNameGetBegin;
788 if ((iter == NULL) || (proc == NULL)) {
790 goto fail_bos_ProcessNameGetBegin;
794 proc->server = b_handle->server;
797 (iter, (void *)proc, GetProcessNameRPC, GetProcessNameFromCache, NULL,
799 *iterationIdP = (void *)iter;
801 goto fail_bos_ProcessNameGetBegin;
805 fail_bos_ProcessNameGetBegin:
823 * bos_ProcessNameGetNext - retrieve the next process name from the bos server.
827 * IN iterationId - an iterator previously returned by bos_ProcessNameGetBegin
829 * OUT processName - upon successful completion contains the next process name
830 * retrieved from the server.
834 * No locks are obtained or released by this function
838 * Returns != 0 upon successful completion.
843 bos_ProcessNameGetNext(const void *iterationId, char *processName,
847 afs_status_t tst = 0;
848 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
850 if (processName == NULL) {
851 tst = ADMBOSPROCESSNAMENULL;
852 goto fail_bos_ProcessNameGetNext;
855 if (iterationId == NULL) {
856 tst = ADMITERATIONIDPNULL;
857 goto fail_bos_ProcessNameGetNext;
860 rc = IteratorNext(iter, (void *)processName, &tst);
862 fail_bos_ProcessNameGetNext:
871 * bos_ProcessNameGetDone - finish using a process name iterator.
875 * IN iterationId - an iterator previously returned by bos_ProcessNameGetBegin
879 * No locks are obtained or released by this function
883 * Returns != 0 upon successful completion.
888 bos_ProcessNameGetDone(const void *iterationId, afs_status_p st)
891 afs_status_t tst = 0;
892 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
894 if (iterationId == NULL) {
895 tst = ADMITERATIONIDPNULL;
896 goto fail_bos_ProcessNameGetDone;
899 rc = IteratorDone(iter, &tst);
901 fail_bos_ProcessNameGetDone:
910 * bos_ProcessInfoGet - get information about a single process
914 * IN serverHandle - a previously opened serverHandle.
916 * IN processName - the process of interest.
918 * OUT processTypeP - upon successful completion contains the process type
920 * OUT processInfoP - upon successful completion contains the process info
924 * No locks are obtained or released by this function
928 * Returns != 0 upon successful completion.
933 bos_ProcessInfoGet(const void *serverHandle, char *processName,
934 bos_ProcessType_p processTypeP,
935 bos_ProcessInfo_p processInfoP, afs_status_p st)
938 afs_status_t tst = 0;
939 bos_server_p b_handle = (bos_server_p) serverHandle;
940 char type[BOS_MAX_NAME_LEN];
942 struct bozo_status status;
945 if (!isValidServerHandle(b_handle, &tst)) {
946 goto fail_bos_ProcessInfoGet;
949 if ((processName == NULL) || (*processName == 0)) {
950 tst = ADMBOSPROCESSNAMENULL;
951 goto fail_bos_ProcessInfoGet;
954 if (processTypeP == NULL) {
955 tst = ADMBOSPROCESSTYPEPNULL;
956 goto fail_bos_ProcessInfoGet;
959 if (processInfoP == NULL) {
960 tst = ADMBOSPROCESSINFOPNULL;
961 goto fail_bos_ProcessInfoGet;
964 tst = BOZO_GetInstanceInfo(b_handle->server, processName, &ptr, &status);
967 goto fail_bos_ProcessInfoGet;
971 for (i = 0; (processTypes[i] != NULL); i++) {
972 if (!strcmp(processTypes[i], type)) {
973 *processTypeP = (bos_ProcessType_t) i;
978 if (processTypes[i] == NULL) {
979 tst = ADMBOSINVALIDPROCESSTYPE;
980 goto fail_bos_ProcessInfoGet;
983 processInfoP->processGoal = (bos_ProcessExecutionState_t) status.goal;
984 processInfoP->processStartTime = status.procStartTime;
985 processInfoP->numberProcessStarts = status.procStarts;
986 processInfoP->processExitTime = status.lastAnyExit;
987 processInfoP->processExitErrorTime = status.lastErrorExit;
988 processInfoP->processErrorCode = status.errorCode;
989 processInfoP->processErrorSignal = status.errorSignal;
990 processInfoP->state = BOS_PROCESS_OK;
992 if (status.flags & BOZO_ERRORSTOP) {
993 processInfoP->state |= BOS_PROCESS_TOO_MANY_ERRORS;
995 if (status.flags & BOZO_HASCORE) {
996 processInfoP->state |= BOS_PROCESS_CORE_DUMPED;
998 if (status.flags & BOZO_BADDIRACCESS) {
999 processInfoP->state |= BOS_PROCESS_BAD_FILE_ACCESS;
1003 fail_bos_ProcessInfoGet:
1012 * The iterator functions and data for the parameter retrieval functions
1015 typedef struct param_get {
1017 struct rx_connection *server;
1018 char processName[BOS_MAX_NAME_LEN];
1019 char param[CACHED_ITEMS][BOS_MAX_NAME_LEN];
1020 } param_get_t, *param_get_p;
1023 GetParameterRPC(void *rpc_specific, int slot, int *last_item,
1024 int *last_item_contains_data, afs_status_p st)
1027 afs_status_t tst = 0;
1028 param_get_p param = (param_get_p) rpc_specific;
1029 char *ptr = (char *)¶m->param[slot];
1032 BOZO_GetInstanceParm(param->server, param->processName, param->next++,
1037 } else if (tst == BZDOM) {
1041 *last_item_contains_data = 0;
1051 GetParameterFromCache(void *rpc_specific, int slot, void *dest,
1055 afs_status_t tst = 0;
1056 param_get_p param = (param_get_p) rpc_specific;
1058 strcpy((char *)dest, (char *)¶m->param[slot]);
1068 * bos_ProcessParameterGetBegin - begin iterating over the parameters
1069 * of a particular process.
1073 * IN serverHandle - a previously opened serverHandle.
1075 * IN processName - the process whose parameters are returned.
1077 * OUT iter - an iterator that can be passed to bos_ProcessParameterGetNext
1078 * to retrieve the parameters.
1082 * No locks are obtained or released by this function
1086 * Returns != 0 upon successful completion.
1091 bos_ProcessParameterGetBegin(const void *serverHandle,
1092 const char *processName, void **iterationIdP,
1096 afs_status_t tst = 0;
1097 bos_server_p b_handle = (bos_server_p) serverHandle;
1098 afs_admin_iterator_p iter =
1099 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1100 param_get_p param = (param_get_p) malloc(sizeof(param_get_t));
1102 if (!isValidServerHandle(b_handle, &tst)) {
1103 goto fail_bos_ProcessParameterGetBegin;
1106 if ((processName == NULL) || (*processName == 0)) {
1107 tst = ADMBOSPROCESSNAMENULL;
1108 goto fail_bos_ProcessParameterGetBegin;
1111 if (iterationIdP == NULL) {
1112 tst = ADMITERATIONIDPNULL;
1113 goto fail_bos_ProcessParameterGetBegin;
1116 if ((iter == NULL) || (param == NULL)) {
1118 goto fail_bos_ProcessParameterGetBegin;
1122 param->server = b_handle->server;
1123 strcpy(param->processName, processName);
1126 (iter, (void *)param, GetParameterRPC, GetParameterFromCache, NULL,
1128 *iterationIdP = (void *)iter;
1130 goto fail_bos_ProcessParameterGetBegin;
1134 fail_bos_ProcessParameterGetBegin:
1140 if (param != NULL) {
1152 * bos_ProcessParameterGetNext - retrieve the next parameter
1153 * from the bos server.
1157 * IN iterationId - an iterator previously returned by
1158 * bos_ProcessParameterGetBegin
1160 * OUT parameter - upon successful completion contains the next parameter
1161 * retrieved from the server.
1165 * No locks are obtained or released by this function
1169 * Returns != 0 upon successful completion.
1174 bos_ProcessParameterGetNext(const void *iterationId, char *parameter,
1178 afs_status_t tst = 0;
1179 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1181 if (iterationId == NULL) {
1182 tst = ADMITERATIONIDPNULL;
1183 goto fail_bos_ProcessParameterGetNext;
1186 if (parameter == NULL) {
1187 tst = ADMBOSPARAMETERNULL;
1188 goto fail_bos_ProcessParameterGetNext;
1191 rc = IteratorNext(iter, (void *)parameter, &tst);
1193 fail_bos_ProcessParameterGetNext:
1202 * bos_ProcessParameterGetDone - finish using a process name iterator.
1206 * IN iterationId - an iterator previously returned by
1207 * bos_ProcessParameterGetBegin
1211 * No locks are obtained or released by this function
1215 * Returns != 0 upon successful completion.
1220 bos_ProcessParameterGetDone(const void *iterationId, afs_status_p st)
1223 afs_status_t tst = 0;
1224 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1226 if (iterationId == NULL) {
1227 tst = ADMITERATIONIDPNULL;
1228 goto fail_bos_ProcessParameterGetDone;
1231 rc = IteratorDone(iter, &tst);
1233 fail_bos_ProcessParameterGetDone:
1242 * bos_ProcessNotifierGet - retrieve the notifier associated with a
1247 * IN serverHandle - a previously opened serverHandle.
1249 * IN processName - the process whose notifier we are retrieving.
1251 * OUT notifier - upon successful completion contains the notifier.
1255 * No locks are obtained or released by this function
1259 * Returns != 0 upon successful completion.
1264 bos_ProcessNotifierGet(const void *serverHandle, const char *processName,
1265 char *notifier, afs_status_p st)
1268 afs_status_t tst = 0;
1269 bos_server_p b_handle = (bos_server_p) serverHandle;
1271 if (!isValidServerHandle(b_handle, &tst)) {
1272 goto fail_bos_ProcessNotifierGet;
1275 if ((processName == NULL) || (*processName == 0)) {
1276 tst = ADMBOSPROCESSNAMENULL;
1277 goto fail_bos_ProcessNotifierGet;
1280 if (notifier == NULL) {
1281 tst = ADMBOSNOTIFIERNULL;
1282 goto fail_bos_ProcessNotifierGet;
1285 tst = BOZO_GetInstanceParm(b_handle->server, (char *)processName,
1292 fail_bos_ProcessNotifierGet:
1301 * bos_ProcessRestart - restart a particular process.
1305 * IN serverHandle - a previously opened serverHandle.
1307 * IN processName - the process to restart
1311 * No locks are obtained or released by this function
1315 * Returns != 0 upon successful completion.
1320 bos_ProcessRestart(const void *serverHandle, const char *processName,
1324 afs_status_t tst = 0;
1325 bos_server_p b_handle = (bos_server_p) serverHandle;
1327 if (!isValidServerHandle(b_handle, &tst)) {
1328 goto fail_bos_ProcessRestart;
1331 if ((processName == NULL) || (*processName == 0)) {
1332 tst = ADMBOSPROCESSNAMENULL;
1333 goto fail_bos_ProcessRestart;
1336 tst = BOZO_Restart(b_handle->server, (char *)processName);
1342 fail_bos_ProcessRestart:
1351 * bos_ProcessAllStop - stop all running processes at a server.
1355 * IN serverHandle - a previously opened serverHandle.
1359 * No locks are obtained or released by this function
1363 * Returns != 0 upon successful completion.
1368 bos_ProcessAllStop(const void *serverHandle, afs_status_p st)
1371 afs_status_t tst = 0;
1372 bos_server_p b_handle = (bos_server_p) serverHandle;
1374 if (!isValidServerHandle(b_handle, &tst)) {
1375 goto fail_bos_ProcessAllStop;
1378 tst = BOZO_ShutdownAll(b_handle->server);
1384 fail_bos_ProcessAllStop:
1393 * bos_ProcessAllStart - start all processes that should be running at a
1398 * IN serverHandle - a previously opened serverHandle.
1402 * No locks are obtained or released by this function
1406 * Returns != 0 upon successful completion.
1411 bos_ProcessAllStart(const void *serverHandle, afs_status_p st)
1414 afs_status_t tst = 0;
1415 bos_server_p b_handle = (bos_server_p) serverHandle;
1417 if (!isValidServerHandle(b_handle, &tst)) {
1418 goto fail_bos_ProcessAllStart;
1421 tst = BOZO_StartupAll(b_handle->server);
1427 fail_bos_ProcessAllStart:
1436 * bos_ProcessAllWaitStop - stop all processes, and block until they have
1441 * IN serverHandle - a previously opened serverHandle.
1445 * No locks are obtained or released by this function
1449 * Returns != 0 upon successful completion.
1454 bos_ProcessAllWaitStop(const void *serverHandle, afs_status_p st)
1457 afs_status_t tst = 0;
1458 bos_server_p b_handle = (bos_server_p) serverHandle;
1460 if (!isValidServerHandle(b_handle, &tst)) {
1461 goto fail_bos_ProcessAllWaitStop;
1464 if (!bos_ProcessAllStop(serverHandle, &tst)) {
1465 goto fail_bos_ProcessAllWaitStop;
1468 tst = BOZO_WaitAll(b_handle->server);
1474 fail_bos_ProcessAllWaitStop:
1483 * bos_ProcessAllWaitTransition - block until all processes at the bosserver
1484 * have reached their desired state.
1488 * IN serverHandle - a previously opened serverHandle.
1492 * No locks are obtained or released by this function
1496 * Returns != 0 upon successful completion.
1501 bos_ProcessAllWaitTransition(const void *serverHandle, afs_status_p st)
1504 afs_status_t tst = 0;
1505 bos_server_p b_handle = (bos_server_p) serverHandle;
1507 if (!isValidServerHandle(b_handle, &tst)) {
1508 goto fail_bos_ProcessAllWaitTransition;
1511 tst = BOZO_WaitAll(b_handle->server);
1517 fail_bos_ProcessAllWaitTransition:
1526 * bos_ProcessAllStopAndRestart - stop all the running processes, restart
1527 * them, and optionally restart the bosserver itself.
1532 * IN serverHandle - a previously opened serverHandle.
1534 * IN restartBosServer - flag to indicate whether to restart bosserver.
1538 * No locks are obtained or released by this function
1542 * Returns != 0 upon successful completion.
1547 bos_ProcessAllStopAndRestart(const void *serverHandle,
1548 bos_RestartBosServer_t restartBosServer,
1552 afs_status_t tst = 0;
1553 bos_server_p b_handle = (bos_server_p) serverHandle;
1555 if (!isValidServerHandle(b_handle, &tst)) {
1556 goto fail_bos_ProcessAllStopAndRestart;
1559 if (restartBosServer == BOS_RESTART_BOS_SERVER) {
1560 tst = BOZO_ReBozo(b_handle->server);
1562 goto fail_bos_ProcessAllStopAndRestart;
1566 tst = BOZO_RestartAll(b_handle->server);
1572 fail_bos_ProcessAllStopAndRestart:
1581 * bos_AdminCreate - create a new admin.
1585 * IN serverHandle - a previously opened serverHandle.
1587 * IN adminName - the new admin name.
1591 * No locks are obtained or released by this function
1595 * Returns != 0 upon successful completion.
1600 bos_AdminCreate(const void *serverHandle, const char *adminName,
1604 afs_status_t tst = 0;
1605 bos_server_p b_handle = (bos_server_p) serverHandle;
1607 if (!isValidServerHandle(b_handle, &tst)) {
1608 goto fail_bos_AdminCreate;
1611 if ((adminName == NULL) || (*adminName == 0)) {
1612 tst = ADMBOSADMINNAMENULL;
1613 goto fail_bos_AdminCreate;
1616 tst = BOZO_AddSUser(b_handle->server, (char *)adminName);
1622 fail_bos_AdminCreate:
1631 * bos_AdminDelete - delete a new admin.
1635 * IN serverHandle - a previously opened serverHandle.
1637 * IN adminName - the admin name.
1641 * No locks are obtained or released by this function
1645 * Returns != 0 upon successful completion.
1650 bos_AdminDelete(const void *serverHandle, const char *adminName,
1654 afs_status_t tst = 0;
1655 bos_server_p b_handle = (bos_server_p) serverHandle;
1657 if (!isValidServerHandle(b_handle, &tst)) {
1658 goto fail_bos_AdminDelete;
1661 if ((adminName == NULL) || (*adminName == 0)) {
1662 tst = ADMBOSADMINNAMENULL;
1663 goto fail_bos_AdminDelete;
1666 tst = BOZO_DeleteSUser(b_handle->server, (char *)adminName);
1672 fail_bos_AdminDelete:
1681 * The iterator functions and data for the admin retrieval functions
1684 typedef struct admin_get {
1686 struct rx_connection *server;
1687 char admin[CACHED_ITEMS][BOS_MAX_NAME_LEN];
1688 } admin_get_t, *admin_get_p;
1691 GetAdminRPC(void *rpc_specific, int slot, int *last_item,
1692 int *last_item_contains_data, afs_status_p st)
1695 afs_status_t tst = 0;
1696 admin_get_p admin = (admin_get_p) rpc_specific;
1697 char *ptr = (char *)&admin->admin[slot];
1699 tst = BOZO_ListSUsers(admin->server, admin->next++, &ptr);
1702 * There's no way to tell the difference between an rpc failure
1703 * and the end of the list, so we assume that any error means the
1710 *last_item_contains_data = 0;
1721 GetAdminFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
1724 afs_status_t tst = 0;
1725 admin_get_p admin = (admin_get_p) rpc_specific;
1727 strcpy((char *)dest, (char *)&admin->admin[slot]);
1737 * bos_AdminGetBegin - begin iterating over the administrators.
1741 * IN serverHandle - a previously opened serverHandle.
1743 * OUT iter - an iterator that can be passed to bos_AdminGetBegin
1744 * to retrieve the administrators.
1748 * No locks are obtained or released by this function
1752 * Returns != 0 upon successful completion.
1757 bos_AdminGetBegin(const void *serverHandle, void **iterationIdP,
1761 afs_status_t tst = 0;
1762 bos_server_p b_handle = (bos_server_p) serverHandle;
1763 afs_admin_iterator_p iter =
1764 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1765 admin_get_p admin = (admin_get_p) malloc(sizeof(admin_get_t));
1767 if (!isValidServerHandle(b_handle, &tst)) {
1768 goto fail_bos_AdminGetBegin;
1771 if (iterationIdP == NULL) {
1772 tst = ADMITERATIONIDPNULL;
1773 goto fail_bos_AdminGetBegin;
1776 if ((iter == NULL) || (admin == NULL)) {
1778 goto fail_bos_AdminGetBegin;
1782 admin->server = b_handle->server;
1785 (iter, (void *)admin, GetAdminRPC, GetAdminFromCache, NULL, NULL,
1787 *iterationIdP = (void *)iter;
1791 fail_bos_AdminGetBegin:
1797 if (admin != NULL) {
1809 * bos_AdminGetNext - retrieve the next administrator
1810 * from the bos server.
1814 * IN iterationId - an iterator previously returned by
1817 * OUT adminName - upon successful completion contains the next administrator
1818 * retrieved from the server.
1822 * No locks are obtained or released by this function
1826 * Returns != 0 upon successful completion.
1831 bos_AdminGetNext(const void *iterationId, char *adminName, afs_status_p st)
1834 afs_status_t tst = 0;
1835 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1837 if (iterationId == NULL) {
1838 tst = ADMITERATIONIDPNULL;
1839 goto fail_bos_AdminGetNext;
1842 if (adminName == NULL) {
1843 tst = ADMBOSADMINNAMENULL;
1844 goto fail_bos_AdminGetNext;
1847 rc = IteratorNext(iter, (void *)adminName, &tst);
1849 fail_bos_AdminGetNext:
1858 * bos_AdminGetDone - finish using a administrator iterator.
1862 * IN iterationId - an iterator previously returned by
1867 * No locks are obtained or released by this function
1871 * Returns != 0 upon successful completion.
1876 bos_AdminGetDone(const void *iterationId, afs_status_p st)
1879 afs_status_t tst = 0;
1880 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1882 if (iterationId == NULL) {
1883 tst = ADMITERATIONIDPNULL;
1884 goto fail_bos_AdminGetDone;
1887 rc = IteratorDone(iter, &tst);
1889 fail_bos_AdminGetDone:
1898 * bos_KeyCreate - add a new key to the keyfile.
1902 * IN serverHandle - a previously opened serverHandle.
1904 * IN keyVersionNumber - the key version number.
1906 * IN key - the new key.
1910 * No locks are obtained or released by this function
1914 * Returns != 0 upon successful completion.
1919 bos_KeyCreate(const void *serverHandle, int keyVersionNumber,
1920 const kas_encryptionKey_p key, afs_status_p st)
1923 afs_status_t tst = 0;
1924 bos_server_p b_handle = (bos_server_p) serverHandle;
1926 if (!isValidServerHandle(b_handle, &tst)) {
1927 goto fail_bos_KeyCreate;
1931 tst = ADMBOSKEYNULL;
1932 goto fail_bos_KeyCreate;
1935 tst = BOZO_AddKey(b_handle->server_encrypt, keyVersionNumber, kas_to_bozoptr(key));
1950 * bos_KeyDelete - delete an existing key from the keyfile.
1954 * IN serverHandle - a previously opened serverHandle.
1956 * IN keyVersionNumber - the key version number.
1960 * No locks are obtained or released by this function
1964 * Returns != 0 upon successful completion.
1969 bos_KeyDelete(const void *serverHandle, int keyVersionNumber, afs_status_p st)
1972 afs_status_t tst = 0;
1973 bos_server_p b_handle = (bos_server_p) serverHandle;
1975 if (!isValidServerHandle(b_handle, &tst)) {
1976 goto fail_bos_KeyDelete;
1979 tst = BOZO_DeleteKey(b_handle->server, keyVersionNumber);
1994 * The iterator functions and data for the key retrieval functions
1997 typedef struct key_get {
1999 struct rx_connection *server;
2000 bos_KeyInfo_t key[CACHED_ITEMS];
2001 } key_get_t, *key_get_p;
2004 GetKeyRPC(void *rpc_specific, int slot, int *last_item,
2005 int *last_item_contains_data, afs_status_p st)
2008 afs_status_t tst = 0;
2009 key_get_p key = (key_get_p) rpc_specific;
2010 struct bozo_keyInfo keyInfo;
2013 BOZO_ListKeys(key->server, key->next++,
2014 &key->key[slot].keyVersionNumber, kas_to_bozoptr(&key->key[slot].key),
2019 key->key[slot].keyStatus.lastModificationDate = keyInfo.mod_sec;
2020 key->key[slot].keyStatus.lastModificationMicroSeconds =
2022 key->key[slot].keyStatus.checkSum = keyInfo.keyCheckSum;
2024 } else if (tst == BZDOM) {
2028 *last_item_contains_data = 0;
2038 GetKeyFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
2041 afs_status_t tst = 0;
2042 key_get_p key = (key_get_p) rpc_specific;
2044 memcpy(dest, &key->key[slot], sizeof(bos_KeyInfo_t));
2054 * bos_KeyGetBegin - begin iterating over the keys.
2058 * IN serverHandle - a previously opened serverHandle.
2060 * OUT iter - an iterator that can be passed to bos_KeyGetNext
2061 * to retrieve the keys.
2065 * No locks are obtained or released by this function
2069 * Returns != 0 upon successful completion.
2074 bos_KeyGetBegin(const void *serverHandle, void **iterationIdP,
2078 afs_status_t tst = 0;
2079 bos_server_p b_handle = (bos_server_p) serverHandle;
2080 afs_admin_iterator_p iter =
2081 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
2082 key_get_p key = (key_get_p) malloc(sizeof(key_get_t));
2084 if (!isValidServerHandle(b_handle, &tst)) {
2085 goto fail_bos_KeyGetBegin;
2088 if (iterationIdP == NULL) {
2089 tst = ADMITERATIONIDPNULL;
2090 goto fail_bos_KeyGetBegin;
2093 if ((iter == NULL) || (key == NULL)) {
2095 goto fail_bos_KeyGetBegin;
2099 key->server = b_handle->server_encrypt;
2102 (iter, (void *)key, GetKeyRPC, GetKeyFromCache, NULL, NULL, &tst)) {
2103 *iterationIdP = (void *)iter;
2107 fail_bos_KeyGetBegin:
2125 * bos_KeyGetNext - retrieve the next key
2126 * from the bos server.
2130 * IN iterationId - an iterator previously returned by
2133 * OUT keyP - upon successful completion contains the next key
2134 * retrieved from the server.
2138 * No locks are obtained or released by this function
2142 * Returns != 0 upon successful completion.
2147 bos_KeyGetNext(const void *iterationId, bos_KeyInfo_p keyP, afs_status_p st)
2150 afs_status_t tst = 0;
2151 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2153 if (iterationId == NULL) {
2154 tst = ADMITERATIONIDPNULL;
2155 goto fail_bos_KeyGetNext;
2159 tst = ADMBOSKEYPNULL;
2160 goto fail_bos_KeyGetNext;
2163 rc = IteratorNext(iter, (void *)keyP, &tst);
2165 fail_bos_KeyGetNext:
2174 * bos_KeyGetDone - finish using a key iterator.
2178 * IN iterationId - an iterator previously returned by
2183 * No locks are obtained or released by this function
2187 * Returns != 0 upon successful completion.
2192 bos_KeyGetDone(const void *iterationId, afs_status_p st)
2195 afs_status_t tst = 0;
2196 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2198 if (iterationId == NULL) {
2199 tst = ADMITERATIONIDPNULL;
2200 goto fail_bos_KeyGetDone;
2203 rc = IteratorDone(iter, &tst);
2205 fail_bos_KeyGetDone:
2214 * bos_CellSet - set the cell name at a bos server.
2218 * IN serverHandle - a previously opened serverHandle.
2220 * IN cellName - the new cell name.
2224 * No locks are obtained or released by this function
2228 * Returns != 0 upon successful completion.
2232 bos_CellSet(const void *serverHandle, const char *cellName, afs_status_p st)
2235 afs_status_t tst = 0;
2236 bos_server_p b_handle = (bos_server_p) serverHandle;
2238 if (!isValidServerHandle(b_handle, &tst)) {
2239 goto fail_bos_CellSet;
2242 if ((cellName == NULL) || (*cellName == 0)) {
2243 tst = ADMCLIENTCELLNAMENULL;
2244 goto fail_bos_CellSet;
2247 tst = BOZO_SetCellName(b_handle->server, (char *)cellName);
2262 * bos_CellGet - get the cell name at a bos server.
2266 * IN serverHandle - a previously opened serverHandle.
2268 * OUT cellName - the cell name.
2272 * No locks are obtained or released by this function
2276 * Returns != 0 upon successful completion.
2280 bos_CellGet(const void *serverHandle, char *cellName, afs_status_p st)
2283 afs_status_t tst = 0;
2284 bos_server_p b_handle = (bos_server_p) serverHandle;
2286 if (!isValidServerHandle(b_handle, &tst)) {
2287 goto fail_bos_CellGet;
2290 if (cellName == NULL) {
2291 tst = ADMCLIENTCELLNAMENULL;
2292 goto fail_bos_CellGet;
2295 tst = BOZO_GetCellName(b_handle->server, &cellName);
2310 * bos_HostCreate - add a new host to the cell.
2314 * IN serverHandle - a previously opened serverHandle.
2316 * IN hostName - the new host.
2320 * No locks are obtained or released by this function
2324 * Returns != 0 upon successful completion.
2328 bos_HostCreate(const void *serverHandle, const char *hostName,
2332 afs_status_t tst = 0;
2333 bos_server_p b_handle = (bos_server_p) serverHandle;
2335 if (!isValidServerHandle(b_handle, &tst)) {
2336 goto fail_bos_HostCreate;
2339 if ((hostName == NULL) || (*hostName == 0)) {
2340 tst = ADMBOSHOSTNAMENULL;
2341 goto fail_bos_HostCreate;
2344 tst = BOZO_AddCellHost(b_handle->server, (char *)hostName);
2350 fail_bos_HostCreate:
2359 * bos_HostDelete - delete a host from the cell.
2363 * IN serverHandle - a previously opened serverHandle.
2365 * IN hostName - the host.
2369 * No locks are obtained or released by this function
2373 * Returns != 0 upon successful completion.
2377 bos_HostDelete(const void *serverHandle, const char *hostName,
2381 afs_status_t tst = 0;
2382 bos_server_p b_handle = (bos_server_p) serverHandle;
2384 if (!isValidServerHandle(b_handle, &tst)) {
2385 goto fail_bos_HostDelete;
2388 if ((hostName == NULL) || (*hostName == 0)) {
2389 tst = ADMBOSHOSTNAMENULL;
2390 goto fail_bos_HostDelete;
2393 tst = BOZO_DeleteCellHost(b_handle->server, (char *)hostName);
2399 fail_bos_HostDelete:
2408 * The iterator functions and data for the host retrieval functions
2411 typedef struct host_get {
2413 struct rx_connection *server;
2414 char host[CACHED_ITEMS][BOS_MAX_NAME_LEN];
2415 } host_get_t, *host_get_p;
2418 GetHostRPC(void *rpc_specific, int slot, int *last_item,
2419 int *last_item_contains_data, afs_status_p st)
2422 afs_status_t tst = 0;
2423 host_get_p host = (host_get_p) rpc_specific;
2424 char *ptr = (char *)&host->host[slot];
2426 tst = BOZO_GetCellHost(host->server, host->next++, &ptr);
2430 } else if (tst == BZDOM) {
2434 *last_item_contains_data = 0;
2444 GetHostFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
2447 afs_status_t tst = 0;
2448 host_get_p host = (host_get_p) rpc_specific;
2450 strcpy((char *)dest, (char *)&host->host[slot]);
2460 * bos_HostGetBegin - begin iterating over the hosts in a cell
2461 * at a particular bos server.
2465 * IN serverHandle - a previously opened serverHandle.
2467 * OUT iter - an iterator that can be passed to bos_HostGetNext
2468 * to retrieve the process names.
2472 * No locks are obtained or released by this function
2476 * Returns != 0 upon successful completion.
2481 bos_HostGetBegin(const void *serverHandle, void **iterationIdP,
2485 afs_status_t tst = 0;
2486 bos_server_p b_handle = (bos_server_p) serverHandle;
2487 afs_admin_iterator_p iter =
2488 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
2489 host_get_p host = (host_get_p) malloc(sizeof(host_get_t));
2491 if (!isValidServerHandle(b_handle, &tst)) {
2492 goto fail_bos_HostGetBegin;
2495 if (iterationIdP == NULL) {
2496 tst = ADMITERATIONIDPNULL;
2497 goto fail_bos_HostGetBegin;
2500 if ((iter == NULL) || (host == NULL)) {
2502 goto fail_bos_HostGetBegin;
2506 host->server = b_handle->server;
2509 (iter, (void *)host, GetHostRPC, GetHostFromCache, NULL, NULL,
2511 *iterationIdP = (void *)iter;
2515 fail_bos_HostGetBegin:
2533 * bos_HostGetNext - retrieve the next host
2534 * from the bos server.
2538 * IN iterationId - an iterator previously returned by
2541 * OUT hostName - upon successful completion contains the next host
2542 * retrieved from the server.
2546 * No locks are obtained or released by this function
2550 * Returns != 0 upon successful completion.
2555 bos_HostGetNext(const void *iterationId, char *hostName, afs_status_p st)
2558 afs_status_t tst = 0;
2559 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2561 if (iterationId == NULL) {
2562 tst = ADMITERATIONIDPNULL;
2563 goto fail_bos_HostGetNext;
2566 if (hostName == NULL) {
2567 tst = ADMBOSHOSTNAMENULL;
2568 goto fail_bos_HostGetNext;
2571 rc = IteratorNext(iter, (void *)hostName, &tst);
2573 fail_bos_HostGetNext:
2582 * bos_HostGetDone - finish using a host iterator.
2586 * IN iterationId - an iterator previously returned by
2591 * No locks are obtained or released by this function
2595 * Returns != 0 upon successful completion.
2600 bos_HostGetDone(const void *iterationId, afs_status_p st)
2603 afs_status_t tst = 0;
2604 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2606 if (iterationId == NULL) {
2607 tst = ADMITERATIONIDPNULL;
2608 goto fail_bos_HostGetDone;
2611 rc = IteratorDone(iter, &tst);
2613 fail_bos_HostGetDone:
2622 * bos_ExecutableCreate - create a new executable at the bos server.
2626 * IN serverHandle - a previously opened serverHandle.
2628 * IN sourceFile - the executable to install at the bos server.
2630 * IN destFile - the location where the executable will be installed.
2634 * No locks are obtained or released by this function
2638 * Returns != 0 upon successful completion.
2643 bos_ExecutableCreate(const void *serverHandle, const char *sourceFile,
2644 const char *destFile, afs_status_p st)
2647 afs_status_t tst = 0;
2648 bos_server_p b_handle = (bos_server_p) serverHandle;
2651 struct rx_call *tcall;
2654 * Validate arguments
2657 if (!isValidServerHandle(b_handle, &tst)) {
2658 goto fail_bos_ExecutableCreate;
2661 if ((sourceFile == NULL) || (*sourceFile == 0)) {
2662 tst = ADMBOSSOURCEFILENULL;
2663 goto fail_bos_ExecutableCreate;
2666 if ((destFile == NULL) || (*destFile == 0)) {
2667 tst = ADMBOSDESTFILENULL;
2668 goto fail_bos_ExecutableCreate;
2672 * Open the file locally and compute its size
2675 fd = open(sourceFile, O_RDONLY);
2678 tst = ADMBOSCANTOPENSOURCEFILE;
2679 goto fail_bos_ExecutableCreate;
2682 if (fstat(fd, &estat)) {
2683 tst = ADMBOSCANTSTATSOURCEFILE;
2684 goto fail_bos_ExecutableCreate;
2688 * Start a split rpc to the bos server.
2691 tcall = rx_NewCall(b_handle->server);
2694 StartBOZO_Install(tcall, (char *)destFile, estat.st_size,
2695 (afs_int32) estat.st_mode, estat.st_mtime);
2698 rx_EndCall(tcall, tst);
2699 goto fail_bos_ExecutableCreate;
2703 * Copy the data to the server
2709 len = read(fd, tbuffer, sizeof(tbuffer));
2711 tst = ADMBOSCANTREADSOURCEFILE;
2712 rx_EndCall(tcall, len);
2713 goto fail_bos_ExecutableCreate;
2719 tst = rx_Write(tcall, tbuffer, len);
2721 tst = ADMBOSSENDSOURCEFILE;
2722 rx_EndCall(tcall, tst);
2723 goto fail_bos_ExecutableCreate;
2728 * Terminate the rpc to the server
2731 tst = rx_EndCall(tcall, tst);
2737 fail_bos_ExecutableCreate:
2746 * bos_ExecutableRevert - revert an executable to a previous .BAK version.
2750 * IN serverHandle - a previously opened serverHandle.
2752 * IN execFile - the executable to revert at the bos server.
2756 * No locks are obtained or released by this function
2760 * Returns != 0 upon successful completion.
2765 bos_ExecutableRevert(const void *serverHandle, const char *execFile,
2769 afs_status_t tst = 0;
2770 bos_server_p b_handle = (bos_server_p) serverHandle;
2772 if (!isValidServerHandle(b_handle, &tst)) {
2773 goto fail_bos_ExecutableRevert;
2776 if ((execFile == NULL) || (*execFile == 0)) {
2777 tst = ADMBOSEXECFILENULL;
2778 goto fail_bos_ExecutableRevert;
2781 tst = BOZO_UnInstall(b_handle->server, (char *)execFile);
2787 fail_bos_ExecutableRevert:
2796 * bos_ExecutableTimestampGet - get the last mod times for an executable,
2797 * the .BAK version of the executable, and the .OLD version of the
2798 * executable if they exist.
2802 * IN serverHandle - a previously opened serverHandle.
2804 * IN execFile - the executable to revert at the bos server.
2808 * No locks are obtained or released by this function
2812 * Returns != 0 upon successful completion.
2817 bos_ExecutableTimestampGet(const void *serverHandle, const char *execFile,
2818 afs_int32 *newTime, afs_int32 *oldTime,
2819 afs_int32 *bakTime, afs_status_p st)
2822 afs_status_t tst = 0;
2823 bos_server_p b_handle = (bos_server_p) serverHandle;
2825 if (!isValidServerHandle(b_handle, &tst)) {
2826 goto fail_bos_ExecutableTimestampGet;
2829 if ((execFile == NULL) || (*execFile == 0)) {
2830 tst = ADMBOSEXECFILENULL;
2831 goto fail_bos_ExecutableTimestampGet;
2834 if (newTime == NULL) {
2835 tst = ADMBOSNEWTIMENULL;
2836 goto fail_bos_ExecutableTimestampGet;
2839 if (oldTime == NULL) {
2840 tst = ADMBOSOLDTIMENULL;
2841 goto fail_bos_ExecutableTimestampGet;
2844 if (bakTime == NULL) {
2845 tst = ADMBOSBAKTIMENULL;
2846 goto fail_bos_ExecutableTimestampGet;
2850 BOZO_GetDates(b_handle->server, (char *)execFile, newTime, bakTime, oldTime);
2856 fail_bos_ExecutableTimestampGet:
2865 * bos_ExecutablePrune - prune the bak, old, and core files off a server
2870 * IN serverHandle - a previously opened serverHandle.
2872 * IN oldFiles - prune .OLD files.
2874 * IN bakFiles - prune .BAK files.
2876 * IN coreFiles - prune core files.
2880 * No locks are obtained or released by this function
2884 * Returns != 0 upon successful completion.
2889 bos_ExecutablePrune(const void *serverHandle, bos_Prune_t oldFiles,
2890 bos_Prune_t bakFiles, bos_Prune_t coreFiles,
2894 afs_status_t tst = 0;
2895 bos_server_p b_handle = (bos_server_p) serverHandle;
2896 afs_int32 flags = 0;
2898 if (!isValidServerHandle(b_handle, &tst)) {
2899 goto fail_bos_ExecutablePrune;
2902 if (oldFiles == BOS_PRUNE) {
2903 flags |= BOZO_PRUNEOLD;
2906 if (bakFiles == BOS_PRUNE) {
2907 flags |= BOZO_PRUNEBAK;
2910 if (coreFiles == BOS_PRUNE) {
2911 flags |= BOZO_PRUNECORE;
2914 tst = BOZO_Prune(b_handle->server, flags);
2920 fail_bos_ExecutablePrune:
2929 * bos_ExecutableRestartTimeSet - set the restart time of the bos server
2934 * IN serverHandle - a previously opened serverHandle.
2936 * IN type - specifies either weekly restart or daily restart time.
2938 * IN time - the time to begin restarts.
2942 * No locks are obtained or released by this function
2946 * Returns != 0 upon successful completion.
2951 bos_ExecutableRestartTimeSet(const void *serverHandle, bos_Restart_t type,
2952 bos_RestartTime_t time, afs_status_p st)
2955 afs_status_t tst = 0;
2956 bos_server_p b_handle = (bos_server_p) serverHandle;
2957 afs_int32 restartType = 0;
2958 struct bozo_netKTime restartTime;
2960 if (!isValidServerHandle(b_handle, &tst)) {
2961 goto fail_bos_ExecutableRestartTimeSet;
2964 if (type == BOS_RESTART_WEEKLY) {
2970 if ((time.mask & BOS_RESTART_TIME_HOUR)
2971 && ((time.hour < 0) || (time.hour > 23))) {
2972 tst = ADMBOSHOURINVALID;
2973 goto fail_bos_ExecutableRestartTimeSet;
2976 if ((time.mask & BOS_RESTART_TIME_MINUTE)
2977 && ((time.min < 0) || (time.min > 60))) {
2978 tst = ADMBOSMINUTEINVALID;
2979 goto fail_bos_ExecutableRestartTimeSet;
2982 if ((time.mask & BOS_RESTART_TIME_SECOND)
2983 && ((time.sec < 0) || (time.sec > 60))) {
2984 tst = ADMBOSSECONDINVALID;
2985 goto fail_bos_ExecutableRestartTimeSet;
2988 if ((time.mask & BOS_RESTART_TIME_DAY)
2989 && ((time.day < 0) || (time.day > 6))) {
2990 tst = ADMBOSDAYINVALID;
2991 goto fail_bos_ExecutableRestartTimeSet;
2994 restartTime.mask = time.mask;
2995 restartTime.hour = time.hour;
2996 restartTime.min = time.min;
2997 restartTime.sec = time.sec;
2998 restartTime.day = time.day;
3000 tst = BOZO_SetRestartTime(b_handle->server, restartType, &restartTime);
3006 fail_bos_ExecutableRestartTimeSet:
3015 * bos_ExecutableRestartTimeGet - get the restart time of the bos server
3020 * IN serverHandle - a previously opened serverHandle.
3022 * IN type - specifies either weekly restart or daily restart time.
3024 * OUT timeP - the time to begin restarts.
3028 * No locks are obtained or released by this function
3032 * Returns != 0 upon successful completion.
3037 bos_ExecutableRestartTimeGet(const void *serverHandle, bos_Restart_t type,
3038 bos_RestartTime_p timeP, afs_status_p st)
3041 afs_status_t tst = 0;
3042 bos_server_p b_handle = (bos_server_p) serverHandle;
3043 afs_int32 restartType = 0;
3044 struct bozo_netKTime restartTime;
3046 if (!isValidServerHandle(b_handle, &tst)) {
3047 goto fail_bos_ExecutableRestartTimeGet;
3050 if (timeP == NULL) {
3051 tst = ADMBOSTIMEPNULL;
3052 goto fail_bos_ExecutableRestartTimeGet;
3055 if (type == BOS_RESTART_WEEKLY) {
3061 tst = BOZO_GetRestartTime(b_handle->server, restartType, &restartTime);
3064 goto fail_bos_ExecutableRestartTimeGet;
3067 timeP->mask = restartTime.mask;
3068 timeP->hour = restartTime.hour;
3069 timeP->min = restartTime.min;
3070 timeP->sec = restartTime.sec;
3071 timeP->day = restartTime.day;
3074 fail_bos_ExecutableRestartTimeGet:
3083 * bos_LogGet - get a log file from the bos server machine.
3087 * IN serverHandle - a previously opened serverHandle.
3089 * IN log - the log file to retrieve.
3091 * IN/OUT logBufferSizeP - the length of the logData buffer on input,
3092 * and upon successful completion, the length of data stored in the buffer.
3094 * OUT logData - the retrieved data upon successful completion.
3098 * No locks are obtained or released by this function
3102 * Returns != 0 upon successful completion.
3107 bos_LogGet(const void *serverHandle, const char *log,
3108 unsigned long *logBufferSizeP, char *logData, afs_status_p st)
3111 afs_status_t tst = 0;
3112 bos_server_p b_handle = (bos_server_p) serverHandle;
3113 struct rx_call *tcall = NULL;
3117 unsigned long bytes_read = 0;
3120 * Validate parameters
3123 if (!isValidServerHandle(b_handle, &tst)) {
3124 goto fail_bos_LogGet;
3127 if ((log == NULL) || (*log == 0)) {
3128 tst = ADMBOSLOGNULL;
3129 goto fail_bos_LogGet;
3132 if (logBufferSizeP == NULL) {
3133 tst = ADMBOSLOGBUFFERSIZEPNULL;
3134 goto fail_bos_LogGet;
3137 if (logData == NULL) {
3138 tst = ADMBOSLOGDATANULL;
3139 goto fail_bos_LogGet;
3143 * Begin to retrieve the data
3146 tcall = rx_NewCall(b_handle->server);
3148 tst = StartBOZO_GetLog(tcall, (char *) log);
3151 goto fail_bos_LogGet;
3155 * Read the log file data
3159 error = rx_Read(tcall, &buffer, 1);
3161 tst = ADMBOSLOGFILEERROR;
3162 goto fail_bos_LogGet;
3166 * check for the end of the log
3170 *logBufferSizeP = bytes_read;
3175 * We've successfully read another byte, copy it to logData
3180 if (bytes_read <= *logBufferSizeP) {
3181 *logData++ = buffer;
3193 rx_EndCall(tcall, 0);
3203 * bos_AuthSet - set the authorization level required at the bos server.
3207 * IN serverHandle - a previously opened serverHandle.
3209 * IN auth - specifies the new auth level.
3213 * No locks are obtained or released by this function
3217 * Returns != 0 upon successful completion.
3222 bos_AuthSet(const void *serverHandle, bos_Auth_t auth, afs_status_p st)
3225 afs_status_t tst = 0;
3226 bos_server_p b_handle = (bos_server_p) serverHandle;
3227 afs_int32 level = 0;
3229 if (!isValidServerHandle(b_handle, &tst)) {
3230 goto fail_bos_AuthSet;
3233 if (auth == BOS_AUTH_REQUIRED) {
3239 tst = BOZO_SetNoAuthFlag(b_handle->server, level);
3254 * bos_CommandExecute - execute a command at the bos server.
3258 * IN serverHandle - a previously opened serverHandle.
3260 * IN command - the command to execute.
3264 * No locks are obtained or released by this function
3268 * Returns != 0 upon successful completion.
3273 bos_CommandExecute(const void *serverHandle, const char *command,
3277 afs_status_t tst = 0;
3278 bos_server_p b_handle = (bos_server_p) serverHandle;
3280 if (!isValidServerHandle(b_handle, &tst)) {
3281 goto fail_bos_CommandExecute;
3284 if ((command == NULL) || (*command == 0)) {
3285 tst = ADMBOSCOMMANDNULL;
3286 goto fail_bos_CommandExecute;
3289 tst = BOZO_Exec(b_handle->server, (char *) command);
3295 fail_bos_CommandExecute:
3304 * bos_Salvage - perform a remote salvage operation.
3308 * IN cellHandle - a previously opened cellHandle.
3310 * IN serverHandle - a previously opened serverHandle.
3312 * IN partitionName - the partition to salvage. Can be null.
3314 * IN volumeName - the volume to salvage. Can be null, if non-null,
3315 * partitionName cannot be null.
3317 * IN numSalvagers - the number of salvage processes to run in parallel.
3319 * IN tmpDir - directory to place temporary files. Can be null.
3321 * IN logFile - file where salvage log will be written. Can be null.
3323 * IN force - sets salvager -force flag.
3325 * IN salvageDamagedVolumes - sets salvager -oktozap flag.
3327 * IN writeInodes - sets salvager -inodes flag.
3329 * IN writeRootInodes - sets salvager -rootinodes flag.
3331 * IN forceDirectory - sets salvager -salvagedirs flag.
3333 * IN forceBlockRead - sets salvager -blockread flag.
3337 * No locks are obtained or released by this function
3341 * Returns != 0 upon successful completion.
3345 #define INITIAL_LOG_LEN 4096
3348 bos_Salvage(const void *cellHandle, const void *serverHandle,
3349 const char *partitionName, const char *volumeName,
3350 int numSalvagers, const char *tmpDir, const char *logFile,
3352 bos_SalvageDamagedVolumes_t salvageDamagedVolumes,
3353 bos_WriteInodes_t writeInodes,
3354 bos_WriteRootInodes_t writeRootInodes,
3355 bos_ForceDirectory_t forceDirectory,
3356 bos_ForceBlockRead_t forceBlockRead, afs_status_p st)
3359 afs_status_t tst = 0;
3360 bos_server_p b_handle = (bos_server_p) serverHandle;
3361 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3362 int have_partition = 0;
3363 int have_volume = 0;
3364 unsigned int part = 0;
3365 int try_to_stop_fileserver = 0;
3366 bos_ProcessType_t procType;
3367 bos_ProcessInfo_t procInfo;
3369 char command[BOS_MAX_NAME_LEN];
3370 int command_len = 0;
3372 char *logData = NULL;
3373 unsigned long logLen = INITIAL_LOG_LEN;
3376 * Validate arguments
3379 if (!IsValidCellHandle(c_handle, &tst)) {
3380 goto fail_bos_Salvage;
3383 if (!isValidServerHandle(b_handle, &tst)) {
3384 goto fail_bos_Salvage;
3387 if (c_handle->vos_valid == 0) {
3388 tst = ADMBOSCELLHANDLENOVOS;
3389 goto fail_bos_Salvage;
3392 if ((partitionName != NULL) && (*partitionName != 0)) {
3393 if (!vos_PartitionNameToId(partitionName, &part, &tst)) {
3394 goto fail_bos_Salvage;
3399 if ((volumeName != NULL) && (*volumeName != 0)) {
3400 if (!have_partition) {
3401 tst = ADMBOSSALVAGEVOLUME;
3402 goto fail_bos_Salvage;
3407 if ((logFile != NULL) && (*logFile != 0)) {
3408 log = fopen(logFile, "w");
3410 tst = ADMBOSSALVAGEBADLOG;
3411 goto fail_bos_Salvage;
3416 * If we are salvaging more than a single volume, stop the fileserver
3420 try_to_stop_fileserver = 1;
3424 * Only try to stop the fileserver if it is running
3427 if (try_to_stop_fileserver) {
3428 if (bos_ProcessInfoGet
3429 (serverHandle, "fs", &procType, &procInfo, &tst)) {
3430 if (procInfo.processGoal != BOS_PROCESS_RUNNING) {
3431 try_to_stop_fileserver = 0;
3437 * Make the call to stop the fileserver and wait for it to shutdown
3440 if (try_to_stop_fileserver) {
3441 if (!bos_ProcessExecutionStateSetTemporary
3442 (serverHandle, "fs", BOS_PROCESS_STOPPED, &tst)) {
3443 goto fail_bos_Salvage;
3445 bos_ProcessAllWaitTransition(serverHandle, &tst);
3449 * Create the salvage command line arguments
3453 sprintf(command, "%s ", AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH);
3454 if (have_partition) {
3456 sprintf(&command[command_len], "-partition %s ", partitionName);
3461 sprintf(&command[command_len], "-volumeid %s ", volumeName);
3464 if (salvageDamagedVolumes == BOS_DONT_SALVAGE_DAMAGED_VOLUMES) {
3465 command_len += sprintf(&command[command_len], "-nowrite ");
3468 if (writeInodes == BOS_SALVAGE_WRITE_INODES) {
3469 command_len += sprintf(&command[command_len], "-inodes ");
3472 if (force == VOS_FORCE) {
3473 command_len += sprintf(&command[command_len], "-force ");
3476 if (writeRootInodes == BOS_SALVAGE_WRITE_ROOT_INODES) {
3477 command_len += sprintf(&command[command_len], "-rootinodes ");
3480 if (forceDirectory == BOS_SALVAGE_FORCE_DIRECTORIES) {
3481 command_len += sprintf(&command[command_len], "-salvagedirs ");
3484 if (forceBlockRead == BOS_SALVAGE_FORCE_BLOCK_READS) {
3485 command_len += sprintf(&command[command_len], "-blockreads ");
3489 sprintf(&command[command_len], "-parallel %d ", numSalvagers);
3491 if ((tmpDir != NULL) && (*tmpDir != 0)) {
3492 command_len += sprintf(&command[command_len], "-tmpdir %s ", tmpDir);
3495 if (command_len > BOS_MAX_NAME_LEN) {
3496 tst = ADMBOSSALVAGEBADOPTIONS;
3497 goto fail_bos_Salvage;
3501 * Create the process at the bosserver and wait until it completes
3504 if (!bos_ProcessCreate
3505 (serverHandle, "salvage-tmp", BOS_PROCESS_CRON, command, "now", 0,
3507 goto fail_bos_Salvage;
3511 bos_ProcessInfoGet(serverHandle, "salvage-tmp", &procType,
3512 &procInfo, &tst))) {
3516 if (tst != BZNOENT) {
3517 goto fail_bos_Salvage;
3521 * Print out the salvage log if required by the user
3526 logData = (char *)malloc(INITIAL_LOG_LEN);
3529 goto fail_bos_Salvage;
3533 (serverHandle, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH,
3534 &logLen, logData, &tst)) {
3535 if (logLen > INITIAL_LOG_LEN) {
3536 logData = (char *)realloc(logData, (logLen + (logLen / 10)));
3537 if (logData == NULL) {
3539 goto fail_bos_Salvage;
3542 goto fail_bos_Salvage;
3545 fprintf(log, "SalvageLog:\n%s", logData);
3549 * Restart the fileserver if we had stopped it previously
3552 if (try_to_stop_fileserver) {
3553 try_to_stop_fileserver = 0;
3554 if (!bos_ProcessExecutionStateSetTemporary
3555 (serverHandle, "fs", BOS_PROCESS_RUNNING, &tst)) {
3556 goto fail_bos_Salvage;
3567 if (logData != NULL) {
3571 if (try_to_stop_fileserver) {
3572 bos_ProcessExecutionStateSetTemporary(serverHandle, "fs",
3573 BOS_PROCESS_RUNNING, 0);