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 = calloc(1, 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 *, const 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 = malloc(sizeof(afs_admin_iterator_t));
775 process_name_get_p proc = malloc(sizeof(process_name_get_t));
777 if (!isValidServerHandle(b_handle, &tst)) {
778 goto fail_bos_ProcessNameGetBegin;
781 if (iterationIdP == NULL) {
782 tst = ADMITERATIONIDPNULL;
783 goto fail_bos_ProcessNameGetBegin;
786 if ((iter == NULL) || (proc == NULL)) {
788 goto fail_bos_ProcessNameGetBegin;
792 proc->server = b_handle->server;
795 (iter, (void *)proc, GetProcessNameRPC, GetProcessNameFromCache, NULL,
797 *iterationIdP = (void *)iter;
799 goto fail_bos_ProcessNameGetBegin;
803 fail_bos_ProcessNameGetBegin:
821 * bos_ProcessNameGetNext - retrieve the next process name from the bos server.
825 * IN iterationId - an iterator previously returned by bos_ProcessNameGetBegin
827 * OUT processName - upon successful completion contains the next process name
828 * retrieved from the server.
832 * No locks are obtained or released by this function
836 * Returns != 0 upon successful completion.
841 bos_ProcessNameGetNext(const void *iterationId, char *processName,
845 afs_status_t tst = 0;
846 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
848 if (processName == NULL) {
849 tst = ADMBOSPROCESSNAMENULL;
850 goto fail_bos_ProcessNameGetNext;
853 if (iterationId == NULL) {
854 tst = ADMITERATIONIDPNULL;
855 goto fail_bos_ProcessNameGetNext;
858 rc = IteratorNext(iter, (void *)processName, &tst);
860 fail_bos_ProcessNameGetNext:
869 * bos_ProcessNameGetDone - finish using a process name iterator.
873 * IN iterationId - an iterator previously returned by bos_ProcessNameGetBegin
877 * No locks are obtained or released by this function
881 * Returns != 0 upon successful completion.
886 bos_ProcessNameGetDone(const void *iterationId, afs_status_p st)
889 afs_status_t tst = 0;
890 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
892 if (iterationId == NULL) {
893 tst = ADMITERATIONIDPNULL;
894 goto fail_bos_ProcessNameGetDone;
897 rc = IteratorDone(iter, &tst);
899 fail_bos_ProcessNameGetDone:
908 * bos_ProcessInfoGet - get information about a single process
912 * IN serverHandle - a previously opened serverHandle.
914 * IN processName - the process of interest.
916 * OUT processTypeP - upon successful completion contains the process type
918 * OUT processInfoP - upon successful completion contains the process info
922 * No locks are obtained or released by this function
926 * Returns != 0 upon successful completion.
931 bos_ProcessInfoGet(const void *serverHandle, char *processName,
932 bos_ProcessType_p processTypeP,
933 bos_ProcessInfo_p processInfoP, afs_status_p st)
936 afs_status_t tst = 0;
937 bos_server_p b_handle = (bos_server_p) serverHandle;
938 char type[BOS_MAX_NAME_LEN];
940 struct bozo_status status;
943 if (!isValidServerHandle(b_handle, &tst)) {
944 goto fail_bos_ProcessInfoGet;
947 if ((processName == NULL) || (*processName == 0)) {
948 tst = ADMBOSPROCESSNAMENULL;
949 goto fail_bos_ProcessInfoGet;
952 if (processTypeP == NULL) {
953 tst = ADMBOSPROCESSTYPEPNULL;
954 goto fail_bos_ProcessInfoGet;
957 if (processInfoP == NULL) {
958 tst = ADMBOSPROCESSINFOPNULL;
959 goto fail_bos_ProcessInfoGet;
962 tst = BOZO_GetInstanceInfo(b_handle->server, processName, &ptr, &status);
965 goto fail_bos_ProcessInfoGet;
969 for (i = 0; (processTypes[i] != NULL); i++) {
970 if (!strcmp(processTypes[i], type)) {
971 *processTypeP = (bos_ProcessType_t) i;
976 if (processTypes[i] == NULL) {
977 tst = ADMBOSINVALIDPROCESSTYPE;
978 goto fail_bos_ProcessInfoGet;
981 processInfoP->processGoal = (bos_ProcessExecutionState_t) status.goal;
982 processInfoP->processStartTime = status.procStartTime;
983 processInfoP->numberProcessStarts = status.procStarts;
984 processInfoP->processExitTime = status.lastAnyExit;
985 processInfoP->processExitErrorTime = status.lastErrorExit;
986 processInfoP->processErrorCode = status.errorCode;
987 processInfoP->processErrorSignal = status.errorSignal;
988 processInfoP->state = BOS_PROCESS_OK;
990 if (status.flags & BOZO_ERRORSTOP) {
991 processInfoP->state |= BOS_PROCESS_TOO_MANY_ERRORS;
993 if (status.flags & BOZO_HASCORE) {
994 processInfoP->state |= BOS_PROCESS_CORE_DUMPED;
996 if (status.flags & BOZO_BADDIRACCESS) {
997 processInfoP->state |= BOS_PROCESS_BAD_FILE_ACCESS;
1001 fail_bos_ProcessInfoGet:
1010 * The iterator functions and data for the parameter retrieval functions
1013 typedef struct param_get {
1015 struct rx_connection *server;
1016 char processName[BOS_MAX_NAME_LEN];
1017 char param[CACHED_ITEMS][BOS_MAX_NAME_LEN];
1018 } param_get_t, *param_get_p;
1021 GetParameterRPC(void *rpc_specific, int slot, int *last_item,
1022 int *last_item_contains_data, afs_status_p st)
1025 afs_status_t tst = 0;
1026 param_get_p param = (param_get_p) rpc_specific;
1027 char *ptr = (char *)¶m->param[slot];
1030 BOZO_GetInstanceParm(param->server, param->processName, param->next++,
1035 } else if (tst == BZDOM) {
1039 *last_item_contains_data = 0;
1049 GetParameterFromCache(void *rpc_specific, int slot, void *dest,
1053 afs_status_t tst = 0;
1054 param_get_p param = (param_get_p) rpc_specific;
1056 strcpy((char *)dest, (char *)¶m->param[slot]);
1066 * bos_ProcessParameterGetBegin - begin iterating over the parameters
1067 * of a particular process.
1071 * IN serverHandle - a previously opened serverHandle.
1073 * IN processName - the process whose parameters are returned.
1075 * OUT iter - an iterator that can be passed to bos_ProcessParameterGetNext
1076 * to retrieve the parameters.
1080 * No locks are obtained or released by this function
1084 * Returns != 0 upon successful completion.
1089 bos_ProcessParameterGetBegin(const void *serverHandle,
1090 const char *processName, void **iterationIdP,
1094 afs_status_t tst = 0;
1095 bos_server_p b_handle = (bos_server_p) serverHandle;
1096 afs_admin_iterator_p iter = malloc(sizeof(afs_admin_iterator_t));
1097 param_get_p param = malloc(sizeof(param_get_t));
1099 if (!isValidServerHandle(b_handle, &tst)) {
1100 goto fail_bos_ProcessParameterGetBegin;
1103 if ((processName == NULL) || (*processName == 0)) {
1104 tst = ADMBOSPROCESSNAMENULL;
1105 goto fail_bos_ProcessParameterGetBegin;
1108 if (iterationIdP == NULL) {
1109 tst = ADMITERATIONIDPNULL;
1110 goto fail_bos_ProcessParameterGetBegin;
1113 if ((iter == NULL) || (param == NULL)) {
1115 goto fail_bos_ProcessParameterGetBegin;
1119 param->server = b_handle->server;
1120 strcpy(param->processName, processName);
1123 (iter, (void *)param, GetParameterRPC, GetParameterFromCache, NULL,
1125 *iterationIdP = (void *)iter;
1127 goto fail_bos_ProcessParameterGetBegin;
1131 fail_bos_ProcessParameterGetBegin:
1137 if (param != NULL) {
1149 * bos_ProcessParameterGetNext - retrieve the next parameter
1150 * from the bos server.
1154 * IN iterationId - an iterator previously returned by
1155 * bos_ProcessParameterGetBegin
1157 * OUT parameter - upon successful completion contains the next parameter
1158 * retrieved from the server.
1162 * No locks are obtained or released by this function
1166 * Returns != 0 upon successful completion.
1171 bos_ProcessParameterGetNext(const void *iterationId, char *parameter,
1175 afs_status_t tst = 0;
1176 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1178 if (iterationId == NULL) {
1179 tst = ADMITERATIONIDPNULL;
1180 goto fail_bos_ProcessParameterGetNext;
1183 if (parameter == NULL) {
1184 tst = ADMBOSPARAMETERNULL;
1185 goto fail_bos_ProcessParameterGetNext;
1188 rc = IteratorNext(iter, (void *)parameter, &tst);
1190 fail_bos_ProcessParameterGetNext:
1199 * bos_ProcessParameterGetDone - finish using a process name iterator.
1203 * IN iterationId - an iterator previously returned by
1204 * bos_ProcessParameterGetBegin
1208 * No locks are obtained or released by this function
1212 * Returns != 0 upon successful completion.
1217 bos_ProcessParameterGetDone(const void *iterationId, afs_status_p st)
1220 afs_status_t tst = 0;
1221 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1223 if (iterationId == NULL) {
1224 tst = ADMITERATIONIDPNULL;
1225 goto fail_bos_ProcessParameterGetDone;
1228 rc = IteratorDone(iter, &tst);
1230 fail_bos_ProcessParameterGetDone:
1239 * bos_ProcessNotifierGet - retrieve the notifier associated with a
1244 * IN serverHandle - a previously opened serverHandle.
1246 * IN processName - the process whose notifier we are retrieving.
1248 * OUT notifier - upon successful completion contains the notifier.
1252 * No locks are obtained or released by this function
1256 * Returns != 0 upon successful completion.
1261 bos_ProcessNotifierGet(const void *serverHandle, const char *processName,
1262 char *notifier, afs_status_p st)
1265 afs_status_t tst = 0;
1266 bos_server_p b_handle = (bos_server_p) serverHandle;
1268 if (!isValidServerHandle(b_handle, &tst)) {
1269 goto fail_bos_ProcessNotifierGet;
1272 if ((processName == NULL) || (*processName == 0)) {
1273 tst = ADMBOSPROCESSNAMENULL;
1274 goto fail_bos_ProcessNotifierGet;
1277 if (notifier == NULL) {
1278 tst = ADMBOSNOTIFIERNULL;
1279 goto fail_bos_ProcessNotifierGet;
1282 tst = BOZO_GetInstanceParm(b_handle->server, (char *)processName,
1289 fail_bos_ProcessNotifierGet:
1298 * bos_ProcessRestart - restart a particular process.
1302 * IN serverHandle - a previously opened serverHandle.
1304 * IN processName - the process to restart
1308 * No locks are obtained or released by this function
1312 * Returns != 0 upon successful completion.
1317 bos_ProcessRestart(const void *serverHandle, const char *processName,
1321 afs_status_t tst = 0;
1322 bos_server_p b_handle = (bos_server_p) serverHandle;
1324 if (!isValidServerHandle(b_handle, &tst)) {
1325 goto fail_bos_ProcessRestart;
1328 if ((processName == NULL) || (*processName == 0)) {
1329 tst = ADMBOSPROCESSNAMENULL;
1330 goto fail_bos_ProcessRestart;
1333 tst = BOZO_Restart(b_handle->server, (char *)processName);
1339 fail_bos_ProcessRestart:
1348 * bos_ProcessAllStop - stop all running processes at a server.
1352 * IN serverHandle - a previously opened serverHandle.
1356 * No locks are obtained or released by this function
1360 * Returns != 0 upon successful completion.
1365 bos_ProcessAllStop(const void *serverHandle, afs_status_p st)
1368 afs_status_t tst = 0;
1369 bos_server_p b_handle = (bos_server_p) serverHandle;
1371 if (!isValidServerHandle(b_handle, &tst)) {
1372 goto fail_bos_ProcessAllStop;
1375 tst = BOZO_ShutdownAll(b_handle->server);
1381 fail_bos_ProcessAllStop:
1390 * bos_ProcessAllStart - start all processes that should be running at a
1395 * IN serverHandle - a previously opened serverHandle.
1399 * No locks are obtained or released by this function
1403 * Returns != 0 upon successful completion.
1408 bos_ProcessAllStart(const void *serverHandle, afs_status_p st)
1411 afs_status_t tst = 0;
1412 bos_server_p b_handle = (bos_server_p) serverHandle;
1414 if (!isValidServerHandle(b_handle, &tst)) {
1415 goto fail_bos_ProcessAllStart;
1418 tst = BOZO_StartupAll(b_handle->server);
1424 fail_bos_ProcessAllStart:
1433 * bos_ProcessAllWaitStop - stop all processes, and block until they have
1438 * IN serverHandle - a previously opened serverHandle.
1442 * No locks are obtained or released by this function
1446 * Returns != 0 upon successful completion.
1451 bos_ProcessAllWaitStop(const void *serverHandle, afs_status_p st)
1454 afs_status_t tst = 0;
1455 bos_server_p b_handle = (bos_server_p) serverHandle;
1457 if (!isValidServerHandle(b_handle, &tst)) {
1458 goto fail_bos_ProcessAllWaitStop;
1461 if (!bos_ProcessAllStop(serverHandle, &tst)) {
1462 goto fail_bos_ProcessAllWaitStop;
1465 tst = BOZO_WaitAll(b_handle->server);
1471 fail_bos_ProcessAllWaitStop:
1480 * bos_ProcessAllWaitTransition - block until all processes at the bosserver
1481 * have reached their desired state.
1485 * IN serverHandle - a previously opened serverHandle.
1489 * No locks are obtained or released by this function
1493 * Returns != 0 upon successful completion.
1498 bos_ProcessAllWaitTransition(const void *serverHandle, afs_status_p st)
1501 afs_status_t tst = 0;
1502 bos_server_p b_handle = (bos_server_p) serverHandle;
1504 if (!isValidServerHandle(b_handle, &tst)) {
1505 goto fail_bos_ProcessAllWaitTransition;
1508 tst = BOZO_WaitAll(b_handle->server);
1514 fail_bos_ProcessAllWaitTransition:
1523 * bos_ProcessAllStopAndRestart - stop all the running processes, restart
1524 * them, and optionally restart the bosserver itself.
1529 * IN serverHandle - a previously opened serverHandle.
1531 * IN restartBosServer - flag to indicate whether to restart bosserver.
1535 * No locks are obtained or released by this function
1539 * Returns != 0 upon successful completion.
1544 bos_ProcessAllStopAndRestart(const void *serverHandle,
1545 bos_RestartBosServer_t restartBosServer,
1549 afs_status_t tst = 0;
1550 bos_server_p b_handle = (bos_server_p) serverHandle;
1552 if (!isValidServerHandle(b_handle, &tst)) {
1553 goto fail_bos_ProcessAllStopAndRestart;
1556 if (restartBosServer == BOS_RESTART_BOS_SERVER) {
1557 tst = BOZO_ReBozo(b_handle->server);
1559 goto fail_bos_ProcessAllStopAndRestart;
1563 tst = BOZO_RestartAll(b_handle->server);
1569 fail_bos_ProcessAllStopAndRestart:
1578 * bos_AdminCreate - create a new admin.
1582 * IN serverHandle - a previously opened serverHandle.
1584 * IN adminName - the new admin name.
1588 * No locks are obtained or released by this function
1592 * Returns != 0 upon successful completion.
1597 bos_AdminCreate(const void *serverHandle, const char *adminName,
1601 afs_status_t tst = 0;
1602 bos_server_p b_handle = (bos_server_p) serverHandle;
1604 if (!isValidServerHandle(b_handle, &tst)) {
1605 goto fail_bos_AdminCreate;
1608 if ((adminName == NULL) || (*adminName == 0)) {
1609 tst = ADMBOSADMINNAMENULL;
1610 goto fail_bos_AdminCreate;
1613 tst = BOZO_AddSUser(b_handle->server, (char *)adminName);
1619 fail_bos_AdminCreate:
1628 * bos_AdminDelete - delete a new admin.
1632 * IN serverHandle - a previously opened serverHandle.
1634 * IN adminName - the admin name.
1638 * No locks are obtained or released by this function
1642 * Returns != 0 upon successful completion.
1647 bos_AdminDelete(const void *serverHandle, const char *adminName,
1651 afs_status_t tst = 0;
1652 bos_server_p b_handle = (bos_server_p) serverHandle;
1654 if (!isValidServerHandle(b_handle, &tst)) {
1655 goto fail_bos_AdminDelete;
1658 if ((adminName == NULL) || (*adminName == 0)) {
1659 tst = ADMBOSADMINNAMENULL;
1660 goto fail_bos_AdminDelete;
1663 tst = BOZO_DeleteSUser(b_handle->server, (char *)adminName);
1669 fail_bos_AdminDelete:
1678 * The iterator functions and data for the admin retrieval functions
1681 typedef struct admin_get {
1683 struct rx_connection *server;
1684 char admin[CACHED_ITEMS][BOS_MAX_NAME_LEN];
1685 } admin_get_t, *admin_get_p;
1688 GetAdminRPC(void *rpc_specific, int slot, int *last_item,
1689 int *last_item_contains_data, afs_status_p st)
1692 afs_status_t tst = 0;
1693 admin_get_p admin = (admin_get_p) rpc_specific;
1694 char *ptr = (char *)&admin->admin[slot];
1696 tst = BOZO_ListSUsers(admin->server, admin->next++, &ptr);
1699 * There's no way to tell the difference between an rpc failure
1700 * and the end of the list, so we assume that any error means the
1707 *last_item_contains_data = 0;
1718 GetAdminFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
1721 afs_status_t tst = 0;
1722 admin_get_p admin = (admin_get_p) rpc_specific;
1724 strcpy((char *)dest, (char *)&admin->admin[slot]);
1734 * bos_AdminGetBegin - begin iterating over the administrators.
1738 * IN serverHandle - a previously opened serverHandle.
1740 * OUT iter - an iterator that can be passed to bos_AdminGetBegin
1741 * to retrieve the administrators.
1745 * No locks are obtained or released by this function
1749 * Returns != 0 upon successful completion.
1754 bos_AdminGetBegin(const void *serverHandle, void **iterationIdP,
1758 afs_status_t tst = 0;
1759 bos_server_p b_handle = (bos_server_p) serverHandle;
1760 afs_admin_iterator_p iter = malloc(sizeof(afs_admin_iterator_t));
1761 admin_get_p admin = malloc(sizeof(admin_get_t));
1763 if (!isValidServerHandle(b_handle, &tst)) {
1764 goto fail_bos_AdminGetBegin;
1767 if (iterationIdP == NULL) {
1768 tst = ADMITERATIONIDPNULL;
1769 goto fail_bos_AdminGetBegin;
1772 if ((iter == NULL) || (admin == NULL)) {
1774 goto fail_bos_AdminGetBegin;
1778 admin->server = b_handle->server;
1781 (iter, (void *)admin, GetAdminRPC, GetAdminFromCache, NULL, NULL,
1783 *iterationIdP = (void *)iter;
1787 fail_bos_AdminGetBegin:
1793 if (admin != NULL) {
1805 * bos_AdminGetNext - retrieve the next administrator
1806 * from the bos server.
1810 * IN iterationId - an iterator previously returned by
1813 * OUT adminName - upon successful completion contains the next administrator
1814 * retrieved from the server.
1818 * No locks are obtained or released by this function
1822 * Returns != 0 upon successful completion.
1827 bos_AdminGetNext(const void *iterationId, char *adminName, afs_status_p st)
1830 afs_status_t tst = 0;
1831 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1833 if (iterationId == NULL) {
1834 tst = ADMITERATIONIDPNULL;
1835 goto fail_bos_AdminGetNext;
1838 if (adminName == NULL) {
1839 tst = ADMBOSADMINNAMENULL;
1840 goto fail_bos_AdminGetNext;
1843 rc = IteratorNext(iter, (void *)adminName, &tst);
1845 fail_bos_AdminGetNext:
1854 * bos_AdminGetDone - finish using a administrator iterator.
1858 * IN iterationId - an iterator previously returned by
1863 * No locks are obtained or released by this function
1867 * Returns != 0 upon successful completion.
1872 bos_AdminGetDone(const void *iterationId, afs_status_p st)
1875 afs_status_t tst = 0;
1876 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1878 if (iterationId == NULL) {
1879 tst = ADMITERATIONIDPNULL;
1880 goto fail_bos_AdminGetDone;
1883 rc = IteratorDone(iter, &tst);
1885 fail_bos_AdminGetDone:
1894 * bos_KeyCreate - add a new key to the keyfile.
1898 * IN serverHandle - a previously opened serverHandle.
1900 * IN keyVersionNumber - the key version number.
1902 * IN key - the new key.
1906 * No locks are obtained or released by this function
1910 * Returns != 0 upon successful completion.
1915 bos_KeyCreate(const void *serverHandle, int keyVersionNumber,
1916 const kas_encryptionKey_p key, afs_status_p st)
1919 afs_status_t tst = 0;
1920 bos_server_p b_handle = (bos_server_p) serverHandle;
1922 if (!isValidServerHandle(b_handle, &tst)) {
1923 goto fail_bos_KeyCreate;
1927 tst = ADMBOSKEYNULL;
1928 goto fail_bos_KeyCreate;
1931 tst = BOZO_AddKey(b_handle->server_encrypt, keyVersionNumber, kas_to_bozoptr(key));
1946 * bos_KeyDelete - delete an existing key from the keyfile.
1950 * IN serverHandle - a previously opened serverHandle.
1952 * IN keyVersionNumber - the key version number.
1956 * No locks are obtained or released by this function
1960 * Returns != 0 upon successful completion.
1965 bos_KeyDelete(const void *serverHandle, int keyVersionNumber, afs_status_p st)
1968 afs_status_t tst = 0;
1969 bos_server_p b_handle = (bos_server_p) serverHandle;
1971 if (!isValidServerHandle(b_handle, &tst)) {
1972 goto fail_bos_KeyDelete;
1975 tst = BOZO_DeleteKey(b_handle->server, keyVersionNumber);
1990 * The iterator functions and data for the key retrieval functions
1993 typedef struct key_get {
1995 struct rx_connection *server;
1996 bos_KeyInfo_t key[CACHED_ITEMS];
1997 } key_get_t, *key_get_p;
2000 GetKeyRPC(void *rpc_specific, int slot, int *last_item,
2001 int *last_item_contains_data, afs_status_p st)
2004 afs_status_t tst = 0;
2005 key_get_p key = (key_get_p) rpc_specific;
2006 struct bozo_keyInfo keyInfo;
2009 BOZO_ListKeys(key->server, key->next++,
2010 &key->key[slot].keyVersionNumber, kas_to_bozoptr(&key->key[slot].key),
2015 key->key[slot].keyStatus.lastModificationDate = keyInfo.mod_sec;
2016 key->key[slot].keyStatus.lastModificationMicroSeconds =
2018 key->key[slot].keyStatus.checkSum = keyInfo.keyCheckSum;
2020 } else if (tst == BZDOM) {
2024 *last_item_contains_data = 0;
2034 GetKeyFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
2037 afs_status_t tst = 0;
2038 key_get_p key = (key_get_p) rpc_specific;
2040 memcpy(dest, &key->key[slot], sizeof(bos_KeyInfo_t));
2050 * bos_KeyGetBegin - begin iterating over the keys.
2054 * IN serverHandle - a previously opened serverHandle.
2056 * OUT iter - an iterator that can be passed to bos_KeyGetNext
2057 * to retrieve the keys.
2061 * No locks are obtained or released by this function
2065 * Returns != 0 upon successful completion.
2070 bos_KeyGetBegin(const void *serverHandle, void **iterationIdP,
2074 afs_status_t tst = 0;
2075 bos_server_p b_handle = (bos_server_p) serverHandle;
2076 afs_admin_iterator_p iter = malloc(sizeof(afs_admin_iterator_t));
2077 key_get_p key = malloc(sizeof(key_get_t));
2079 if (!isValidServerHandle(b_handle, &tst)) {
2080 goto fail_bos_KeyGetBegin;
2083 if (iterationIdP == NULL) {
2084 tst = ADMITERATIONIDPNULL;
2085 goto fail_bos_KeyGetBegin;
2088 if ((iter == NULL) || (key == NULL)) {
2090 goto fail_bos_KeyGetBegin;
2094 key->server = b_handle->server_encrypt;
2097 (iter, (void *)key, GetKeyRPC, GetKeyFromCache, NULL, NULL, &tst)) {
2098 *iterationIdP = (void *)iter;
2102 fail_bos_KeyGetBegin:
2120 * bos_KeyGetNext - retrieve the next key
2121 * from the bos server.
2125 * IN iterationId - an iterator previously returned by
2128 * OUT keyP - upon successful completion contains the next key
2129 * retrieved from the server.
2133 * No locks are obtained or released by this function
2137 * Returns != 0 upon successful completion.
2142 bos_KeyGetNext(const void *iterationId, bos_KeyInfo_p keyP, afs_status_p st)
2145 afs_status_t tst = 0;
2146 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2148 if (iterationId == NULL) {
2149 tst = ADMITERATIONIDPNULL;
2150 goto fail_bos_KeyGetNext;
2154 tst = ADMBOSKEYPNULL;
2155 goto fail_bos_KeyGetNext;
2158 rc = IteratorNext(iter, (void *)keyP, &tst);
2160 fail_bos_KeyGetNext:
2169 * bos_KeyGetDone - finish using a key iterator.
2173 * IN iterationId - an iterator previously returned by
2178 * No locks are obtained or released by this function
2182 * Returns != 0 upon successful completion.
2187 bos_KeyGetDone(const void *iterationId, afs_status_p st)
2190 afs_status_t tst = 0;
2191 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2193 if (iterationId == NULL) {
2194 tst = ADMITERATIONIDPNULL;
2195 goto fail_bos_KeyGetDone;
2198 rc = IteratorDone(iter, &tst);
2200 fail_bos_KeyGetDone:
2209 * bos_CellSet - set the cell name at a bos server.
2213 * IN serverHandle - a previously opened serverHandle.
2215 * IN cellName - the new cell name.
2219 * No locks are obtained or released by this function
2223 * Returns != 0 upon successful completion.
2227 bos_CellSet(const void *serverHandle, const char *cellName, afs_status_p st)
2230 afs_status_t tst = 0;
2231 bos_server_p b_handle = (bos_server_p) serverHandle;
2233 if (!isValidServerHandle(b_handle, &tst)) {
2234 goto fail_bos_CellSet;
2237 if ((cellName == NULL) || (*cellName == 0)) {
2238 tst = ADMCLIENTCELLNAMENULL;
2239 goto fail_bos_CellSet;
2242 tst = BOZO_SetCellName(b_handle->server, (char *)cellName);
2257 * bos_CellGet - get the cell name at a bos server.
2261 * IN serverHandle - a previously opened serverHandle.
2263 * OUT cellName - the cell name.
2267 * No locks are obtained or released by this function
2271 * Returns != 0 upon successful completion.
2275 bos_CellGet(const void *serverHandle, char *cellName, afs_status_p st)
2278 afs_status_t tst = 0;
2279 bos_server_p b_handle = (bos_server_p) serverHandle;
2281 if (!isValidServerHandle(b_handle, &tst)) {
2282 goto fail_bos_CellGet;
2285 if (cellName == NULL) {
2286 tst = ADMCLIENTCELLNAMENULL;
2287 goto fail_bos_CellGet;
2290 tst = BOZO_GetCellName(b_handle->server, &cellName);
2305 * bos_HostCreate - add a new host to the cell.
2309 * IN serverHandle - a previously opened serverHandle.
2311 * IN hostName - the new host.
2315 * No locks are obtained or released by this function
2319 * Returns != 0 upon successful completion.
2323 bos_HostCreate(const void *serverHandle, const char *hostName,
2327 afs_status_t tst = 0;
2328 bos_server_p b_handle = (bos_server_p) serverHandle;
2330 if (!isValidServerHandle(b_handle, &tst)) {
2331 goto fail_bos_HostCreate;
2334 if ((hostName == NULL) || (*hostName == 0)) {
2335 tst = ADMBOSHOSTNAMENULL;
2336 goto fail_bos_HostCreate;
2339 tst = BOZO_AddCellHost(b_handle->server, (char *)hostName);
2345 fail_bos_HostCreate:
2354 * bos_HostDelete - delete a host from the cell.
2358 * IN serverHandle - a previously opened serverHandle.
2360 * IN hostName - the host.
2364 * No locks are obtained or released by this function
2368 * Returns != 0 upon successful completion.
2372 bos_HostDelete(const void *serverHandle, const char *hostName,
2376 afs_status_t tst = 0;
2377 bos_server_p b_handle = (bos_server_p) serverHandle;
2379 if (!isValidServerHandle(b_handle, &tst)) {
2380 goto fail_bos_HostDelete;
2383 if ((hostName == NULL) || (*hostName == 0)) {
2384 tst = ADMBOSHOSTNAMENULL;
2385 goto fail_bos_HostDelete;
2388 tst = BOZO_DeleteCellHost(b_handle->server, (char *)hostName);
2394 fail_bos_HostDelete:
2403 * The iterator functions and data for the host retrieval functions
2406 typedef struct host_get {
2408 struct rx_connection *server;
2409 char host[CACHED_ITEMS][BOS_MAX_NAME_LEN];
2410 } host_get_t, *host_get_p;
2413 GetHostRPC(void *rpc_specific, int slot, int *last_item,
2414 int *last_item_contains_data, afs_status_p st)
2417 afs_status_t tst = 0;
2418 host_get_p host = (host_get_p) rpc_specific;
2419 char *ptr = (char *)&host->host[slot];
2421 tst = BOZO_GetCellHost(host->server, host->next++, &ptr);
2425 } else if (tst == BZDOM) {
2429 *last_item_contains_data = 0;
2439 GetHostFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
2442 afs_status_t tst = 0;
2443 host_get_p host = (host_get_p) rpc_specific;
2445 strcpy((char *)dest, (char *)&host->host[slot]);
2455 * bos_HostGetBegin - begin iterating over the hosts in a cell
2456 * at a particular bos server.
2460 * IN serverHandle - a previously opened serverHandle.
2462 * OUT iter - an iterator that can be passed to bos_HostGetNext
2463 * to retrieve the process names.
2467 * No locks are obtained or released by this function
2471 * Returns != 0 upon successful completion.
2476 bos_HostGetBegin(const void *serverHandle, void **iterationIdP,
2480 afs_status_t tst = 0;
2481 bos_server_p b_handle = (bos_server_p) serverHandle;
2482 afs_admin_iterator_p iter = malloc(sizeof(afs_admin_iterator_t));
2483 host_get_p host = malloc(sizeof(host_get_t));
2485 if (!isValidServerHandle(b_handle, &tst)) {
2486 goto fail_bos_HostGetBegin;
2489 if (iterationIdP == NULL) {
2490 tst = ADMITERATIONIDPNULL;
2491 goto fail_bos_HostGetBegin;
2494 if ((iter == NULL) || (host == NULL)) {
2496 goto fail_bos_HostGetBegin;
2500 host->server = b_handle->server;
2503 (iter, (void *)host, GetHostRPC, GetHostFromCache, NULL, NULL,
2505 *iterationIdP = (void *)iter;
2509 fail_bos_HostGetBegin:
2527 * bos_HostGetNext - retrieve the next host
2528 * from the bos server.
2532 * IN iterationId - an iterator previously returned by
2535 * OUT hostName - upon successful completion contains the next host
2536 * retrieved from the server.
2540 * No locks are obtained or released by this function
2544 * Returns != 0 upon successful completion.
2549 bos_HostGetNext(const void *iterationId, char *hostName, afs_status_p st)
2552 afs_status_t tst = 0;
2553 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2555 if (iterationId == NULL) {
2556 tst = ADMITERATIONIDPNULL;
2557 goto fail_bos_HostGetNext;
2560 if (hostName == NULL) {
2561 tst = ADMBOSHOSTNAMENULL;
2562 goto fail_bos_HostGetNext;
2565 rc = IteratorNext(iter, (void *)hostName, &tst);
2567 fail_bos_HostGetNext:
2576 * bos_HostGetDone - finish using a host iterator.
2580 * IN iterationId - an iterator previously returned by
2585 * No locks are obtained or released by this function
2589 * Returns != 0 upon successful completion.
2594 bos_HostGetDone(const void *iterationId, afs_status_p st)
2597 afs_status_t tst = 0;
2598 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2600 if (iterationId == NULL) {
2601 tst = ADMITERATIONIDPNULL;
2602 goto fail_bos_HostGetDone;
2605 rc = IteratorDone(iter, &tst);
2607 fail_bos_HostGetDone:
2616 * bos_ExecutableCreate - create a new executable at the bos server.
2620 * IN serverHandle - a previously opened serverHandle.
2622 * IN sourceFile - the executable to install at the bos server.
2624 * IN destFile - the location where the executable will be installed.
2628 * No locks are obtained or released by this function
2632 * Returns != 0 upon successful completion.
2637 bos_ExecutableCreate(const void *serverHandle, const char *sourceFile,
2638 const char *destFile, afs_status_p st)
2641 afs_status_t tst = 0;
2642 bos_server_p b_handle = (bos_server_p) serverHandle;
2645 struct rx_call *tcall;
2648 * Validate arguments
2651 if (!isValidServerHandle(b_handle, &tst)) {
2652 goto fail_bos_ExecutableCreate;
2655 if ((sourceFile == NULL) || (*sourceFile == 0)) {
2656 tst = ADMBOSSOURCEFILENULL;
2657 goto fail_bos_ExecutableCreate;
2660 if ((destFile == NULL) || (*destFile == 0)) {
2661 tst = ADMBOSDESTFILENULL;
2662 goto fail_bos_ExecutableCreate;
2666 * Open the file locally and compute its size
2669 fd = open(sourceFile, O_RDONLY);
2672 tst = ADMBOSCANTOPENSOURCEFILE;
2673 goto fail_bos_ExecutableCreate;
2676 if (fstat(fd, &estat)) {
2677 tst = ADMBOSCANTSTATSOURCEFILE;
2678 goto fail_bos_ExecutableCreate;
2682 * Start a split rpc to the bos server.
2685 tcall = rx_NewCall(b_handle->server);
2688 StartBOZO_Install(tcall, (char *)destFile, estat.st_size,
2689 (afs_int32) estat.st_mode, estat.st_mtime);
2692 rx_EndCall(tcall, tst);
2693 goto fail_bos_ExecutableCreate;
2697 * Copy the data to the server
2703 len = read(fd, tbuffer, sizeof(tbuffer));
2705 tst = ADMBOSCANTREADSOURCEFILE;
2706 rx_EndCall(tcall, len);
2707 goto fail_bos_ExecutableCreate;
2713 tst = rx_Write(tcall, tbuffer, len);
2715 tst = ADMBOSSENDSOURCEFILE;
2716 rx_EndCall(tcall, tst);
2717 goto fail_bos_ExecutableCreate;
2722 * Terminate the rpc to the server
2725 tst = rx_EndCall(tcall, tst);
2731 fail_bos_ExecutableCreate:
2740 * bos_ExecutableRevert - revert an executable to a previous .BAK version.
2744 * IN serverHandle - a previously opened serverHandle.
2746 * IN execFile - the executable to revert at the bos server.
2750 * No locks are obtained or released by this function
2754 * Returns != 0 upon successful completion.
2759 bos_ExecutableRevert(const void *serverHandle, const char *execFile,
2763 afs_status_t tst = 0;
2764 bos_server_p b_handle = (bos_server_p) serverHandle;
2766 if (!isValidServerHandle(b_handle, &tst)) {
2767 goto fail_bos_ExecutableRevert;
2770 if ((execFile == NULL) || (*execFile == 0)) {
2771 tst = ADMBOSEXECFILENULL;
2772 goto fail_bos_ExecutableRevert;
2775 tst = BOZO_UnInstall(b_handle->server, (char *)execFile);
2781 fail_bos_ExecutableRevert:
2790 * bos_ExecutableTimestampGet - get the last mod times for an executable,
2791 * the .BAK version of the executable, and the .OLD version of the
2792 * executable if they exist.
2796 * IN serverHandle - a previously opened serverHandle.
2798 * IN execFile - the executable to revert at the bos server.
2802 * No locks are obtained or released by this function
2806 * Returns != 0 upon successful completion.
2811 bos_ExecutableTimestampGet(const void *serverHandle, const char *execFile,
2812 afs_int32 *newTime, afs_int32 *oldTime,
2813 afs_int32 *bakTime, afs_status_p st)
2816 afs_status_t tst = 0;
2817 bos_server_p b_handle = (bos_server_p) serverHandle;
2819 if (!isValidServerHandle(b_handle, &tst)) {
2820 goto fail_bos_ExecutableTimestampGet;
2823 if ((execFile == NULL) || (*execFile == 0)) {
2824 tst = ADMBOSEXECFILENULL;
2825 goto fail_bos_ExecutableTimestampGet;
2828 if (newTime == NULL) {
2829 tst = ADMBOSNEWTIMENULL;
2830 goto fail_bos_ExecutableTimestampGet;
2833 if (oldTime == NULL) {
2834 tst = ADMBOSOLDTIMENULL;
2835 goto fail_bos_ExecutableTimestampGet;
2838 if (bakTime == NULL) {
2839 tst = ADMBOSBAKTIMENULL;
2840 goto fail_bos_ExecutableTimestampGet;
2844 BOZO_GetDates(b_handle->server, (char *)execFile, newTime, bakTime, oldTime);
2850 fail_bos_ExecutableTimestampGet:
2859 * bos_ExecutablePrune - prune the bak, old, and core files off a server
2864 * IN serverHandle - a previously opened serverHandle.
2866 * IN oldFiles - prune .OLD files.
2868 * IN bakFiles - prune .BAK files.
2870 * IN coreFiles - prune core files.
2874 * No locks are obtained or released by this function
2878 * Returns != 0 upon successful completion.
2883 bos_ExecutablePrune(const void *serverHandle, bos_Prune_t oldFiles,
2884 bos_Prune_t bakFiles, bos_Prune_t coreFiles,
2888 afs_status_t tst = 0;
2889 bos_server_p b_handle = (bos_server_p) serverHandle;
2890 afs_int32 flags = 0;
2892 if (!isValidServerHandle(b_handle, &tst)) {
2893 goto fail_bos_ExecutablePrune;
2896 if (oldFiles == BOS_PRUNE) {
2897 flags |= BOZO_PRUNEOLD;
2900 if (bakFiles == BOS_PRUNE) {
2901 flags |= BOZO_PRUNEBAK;
2904 if (coreFiles == BOS_PRUNE) {
2905 flags |= BOZO_PRUNECORE;
2908 tst = BOZO_Prune(b_handle->server, flags);
2914 fail_bos_ExecutablePrune:
2923 * bos_ExecutableRestartTimeSet - set the restart time of the bos server
2928 * IN serverHandle - a previously opened serverHandle.
2930 * IN type - specifies either weekly restart or daily restart time.
2932 * IN time - the time to begin restarts.
2936 * No locks are obtained or released by this function
2940 * Returns != 0 upon successful completion.
2945 bos_ExecutableRestartTimeSet(const void *serverHandle, bos_Restart_t type,
2946 bos_RestartTime_t time, afs_status_p st)
2949 afs_status_t tst = 0;
2950 bos_server_p b_handle = (bos_server_p) serverHandle;
2951 afs_int32 restartType = 0;
2952 struct bozo_netKTime restartTime;
2954 if (!isValidServerHandle(b_handle, &tst)) {
2955 goto fail_bos_ExecutableRestartTimeSet;
2958 if (type == BOS_RESTART_WEEKLY) {
2964 if ((time.mask & BOS_RESTART_TIME_HOUR)
2965 && ((time.hour < 0) || (time.hour > 23))) {
2966 tst = ADMBOSHOURINVALID;
2967 goto fail_bos_ExecutableRestartTimeSet;
2970 if ((time.mask & BOS_RESTART_TIME_MINUTE)
2971 && ((time.min < 0) || (time.min > 60))) {
2972 tst = ADMBOSMINUTEINVALID;
2973 goto fail_bos_ExecutableRestartTimeSet;
2976 if ((time.mask & BOS_RESTART_TIME_SECOND)
2977 && ((time.sec < 0) || (time.sec > 60))) {
2978 tst = ADMBOSSECONDINVALID;
2979 goto fail_bos_ExecutableRestartTimeSet;
2982 if ((time.mask & BOS_RESTART_TIME_DAY)
2983 && ((time.day < 0) || (time.day > 6))) {
2984 tst = ADMBOSDAYINVALID;
2985 goto fail_bos_ExecutableRestartTimeSet;
2988 restartTime.mask = time.mask;
2989 restartTime.hour = time.hour;
2990 restartTime.min = time.min;
2991 restartTime.sec = time.sec;
2992 restartTime.day = time.day;
2994 tst = BOZO_SetRestartTime(b_handle->server, restartType, &restartTime);
3000 fail_bos_ExecutableRestartTimeSet:
3009 * bos_ExecutableRestartTimeGet - get the restart time of the bos server
3014 * IN serverHandle - a previously opened serverHandle.
3016 * IN type - specifies either weekly restart or daily restart time.
3018 * OUT timeP - the time to begin restarts.
3022 * No locks are obtained or released by this function
3026 * Returns != 0 upon successful completion.
3031 bos_ExecutableRestartTimeGet(const void *serverHandle, bos_Restart_t type,
3032 bos_RestartTime_p timeP, afs_status_p st)
3035 afs_status_t tst = 0;
3036 bos_server_p b_handle = (bos_server_p) serverHandle;
3037 afs_int32 restartType = 0;
3038 struct bozo_netKTime restartTime;
3040 if (!isValidServerHandle(b_handle, &tst)) {
3041 goto fail_bos_ExecutableRestartTimeGet;
3044 if (timeP == NULL) {
3045 tst = ADMBOSTIMEPNULL;
3046 goto fail_bos_ExecutableRestartTimeGet;
3049 if (type == BOS_RESTART_WEEKLY) {
3055 tst = BOZO_GetRestartTime(b_handle->server, restartType, &restartTime);
3058 goto fail_bos_ExecutableRestartTimeGet;
3061 timeP->mask = restartTime.mask;
3062 timeP->hour = restartTime.hour;
3063 timeP->min = restartTime.min;
3064 timeP->sec = restartTime.sec;
3065 timeP->day = restartTime.day;
3068 fail_bos_ExecutableRestartTimeGet:
3077 * bos_LogGet - get a log file from the bos server machine.
3081 * IN serverHandle - a previously opened serverHandle.
3083 * IN log - the log file to retrieve.
3085 * IN/OUT logBufferSizeP - the length of the logData buffer on input,
3086 * and upon successful completion, the length of data stored in the buffer.
3088 * OUT logData - the retrieved data upon successful completion.
3092 * No locks are obtained or released by this function
3096 * Returns != 0 upon successful completion.
3101 bos_LogGet(const void *serverHandle, const char *log,
3102 unsigned long *logBufferSizeP, char *logData, afs_status_p st)
3105 afs_status_t tst = 0;
3106 bos_server_p b_handle = (bos_server_p) serverHandle;
3107 struct rx_call *tcall = NULL;
3111 unsigned long bytes_read = 0;
3114 * Validate parameters
3117 if (!isValidServerHandle(b_handle, &tst)) {
3118 goto fail_bos_LogGet;
3121 if ((log == NULL) || (*log == 0)) {
3122 tst = ADMBOSLOGNULL;
3123 goto fail_bos_LogGet;
3126 if (logBufferSizeP == NULL) {
3127 tst = ADMBOSLOGBUFFERSIZEPNULL;
3128 goto fail_bos_LogGet;
3131 if (logData == NULL) {
3132 tst = ADMBOSLOGDATANULL;
3133 goto fail_bos_LogGet;
3137 * Begin to retrieve the data
3140 tcall = rx_NewCall(b_handle->server);
3142 tst = StartBOZO_GetLog(tcall, (char *) log);
3145 goto fail_bos_LogGet;
3149 * Read the log file data
3153 error = rx_Read(tcall, &buffer, 1);
3155 tst = ADMBOSLOGFILEERROR;
3156 goto fail_bos_LogGet;
3160 * check for the end of the log
3164 *logBufferSizeP = bytes_read;
3169 * We've successfully read another byte, copy it to logData
3174 if (bytes_read <= *logBufferSizeP) {
3175 *logData++ = buffer;
3187 rx_EndCall(tcall, 0);
3197 * bos_AuthSet - set the authorization level required at the bos server.
3201 * IN serverHandle - a previously opened serverHandle.
3203 * IN auth - specifies the new auth level.
3207 * No locks are obtained or released by this function
3211 * Returns != 0 upon successful completion.
3216 bos_AuthSet(const void *serverHandle, bos_Auth_t auth, afs_status_p st)
3219 afs_status_t tst = 0;
3220 bos_server_p b_handle = (bos_server_p) serverHandle;
3221 afs_int32 level = 0;
3223 if (!isValidServerHandle(b_handle, &tst)) {
3224 goto fail_bos_AuthSet;
3227 if (auth == BOS_AUTH_REQUIRED) {
3233 tst = BOZO_SetNoAuthFlag(b_handle->server, level);
3248 * bos_CommandExecute - execute a command at the bos server.
3252 * IN serverHandle - a previously opened serverHandle.
3254 * IN command - the command to execute.
3258 * No locks are obtained or released by this function
3262 * Returns != 0 upon successful completion.
3267 bos_CommandExecute(const void *serverHandle, const char *command,
3271 afs_status_t tst = 0;
3272 bos_server_p b_handle = (bos_server_p) serverHandle;
3274 if (!isValidServerHandle(b_handle, &tst)) {
3275 goto fail_bos_CommandExecute;
3278 if ((command == NULL) || (*command == 0)) {
3279 tst = ADMBOSCOMMANDNULL;
3280 goto fail_bos_CommandExecute;
3283 tst = BOZO_Exec(b_handle->server, (char *) command);
3289 fail_bos_CommandExecute:
3298 * bos_Salvage - perform a remote salvage operation.
3302 * IN cellHandle - a previously opened cellHandle.
3304 * IN serverHandle - a previously opened serverHandle.
3306 * IN partitionName - the partition to salvage. Can be null.
3308 * IN volumeName - the volume to salvage. Can be null, if non-null,
3309 * partitionName cannot be null.
3311 * IN numSalvagers - the number of salvage processes to run in parallel.
3313 * IN tmpDir - directory to place temporary files. Can be null.
3315 * IN logFile - file where salvage log will be written. Can be null.
3317 * IN force - sets salvager -force flag.
3319 * IN salvageDamagedVolumes - sets salvager -oktozap flag.
3321 * IN writeInodes - sets salvager -inodes flag.
3323 * IN writeRootInodes - sets salvager -rootinodes flag.
3325 * IN forceDirectory - sets salvager -salvagedirs flag.
3327 * IN forceBlockRead - sets salvager -blockread flag.
3331 * No locks are obtained or released by this function
3335 * Returns != 0 upon successful completion.
3339 #define INITIAL_LOG_LEN 4096
3342 bos_Salvage(const void *cellHandle, const void *serverHandle,
3343 const char *partitionName, const char *volumeName,
3344 int numSalvagers, const char *tmpDir, const char *logFile,
3346 bos_SalvageDamagedVolumes_t salvageDamagedVolumes,
3347 bos_WriteInodes_t writeInodes,
3348 bos_WriteRootInodes_t writeRootInodes,
3349 bos_ForceDirectory_t forceDirectory,
3350 bos_ForceBlockRead_t forceBlockRead, afs_status_p st)
3353 afs_status_t tst = 0;
3354 bos_server_p b_handle = (bos_server_p) serverHandle;
3355 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3356 int have_partition = 0;
3357 int have_volume = 0;
3358 unsigned int part = 0;
3359 int try_to_stop_fileserver = 0;
3360 bos_ProcessType_t procType;
3361 bos_ProcessInfo_t procInfo;
3363 char command[BOS_MAX_NAME_LEN];
3364 int command_len = 0;
3366 char *logData = NULL;
3367 unsigned long logLen = INITIAL_LOG_LEN;
3370 * Validate arguments
3373 if (!IsValidCellHandle(c_handle, &tst)) {
3374 goto fail_bos_Salvage;
3377 if (!isValidServerHandle(b_handle, &tst)) {
3378 goto fail_bos_Salvage;
3381 if (c_handle->vos_valid == 0) {
3382 tst = ADMBOSCELLHANDLENOVOS;
3383 goto fail_bos_Salvage;
3386 if ((partitionName != NULL) && (*partitionName != 0)) {
3387 if (!vos_PartitionNameToId(partitionName, &part, &tst)) {
3388 goto fail_bos_Salvage;
3393 if ((volumeName != NULL) && (*volumeName != 0)) {
3394 if (!have_partition) {
3395 tst = ADMBOSSALVAGEVOLUME;
3396 goto fail_bos_Salvage;
3401 if ((logFile != NULL) && (*logFile != 0)) {
3402 log = fopen(logFile, "w");
3404 tst = ADMBOSSALVAGEBADLOG;
3405 goto fail_bos_Salvage;
3410 * If we are salvaging more than a single volume, stop the fileserver
3414 try_to_stop_fileserver = 1;
3418 * Only try to stop the fileserver if it is running
3421 if (try_to_stop_fileserver) {
3422 if (bos_ProcessInfoGet
3423 (serverHandle, "fs", &procType, &procInfo, &tst)) {
3424 if (procInfo.processGoal != BOS_PROCESS_RUNNING) {
3425 try_to_stop_fileserver = 0;
3431 * Make the call to stop the fileserver and wait for it to shutdown
3434 if (try_to_stop_fileserver) {
3435 if (!bos_ProcessExecutionStateSetTemporary
3436 (serverHandle, "fs", BOS_PROCESS_STOPPED, &tst)) {
3437 goto fail_bos_Salvage;
3439 bos_ProcessAllWaitTransition(serverHandle, &tst);
3443 * Create the salvage command line arguments
3447 sprintf(command, "%s ", AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH);
3448 if (have_partition) {
3450 sprintf(&command[command_len], "-partition %s ", partitionName);
3455 sprintf(&command[command_len], "-volumeid %s ", volumeName);
3458 if (salvageDamagedVolumes == BOS_DONT_SALVAGE_DAMAGED_VOLUMES) {
3459 command_len += sprintf(&command[command_len], "-nowrite ");
3462 if (writeInodes == BOS_SALVAGE_WRITE_INODES) {
3463 command_len += sprintf(&command[command_len], "-inodes ");
3466 if (force == VOS_FORCE) {
3467 command_len += sprintf(&command[command_len], "-force ");
3470 if (writeRootInodes == BOS_SALVAGE_WRITE_ROOT_INODES) {
3471 command_len += sprintf(&command[command_len], "-rootinodes ");
3474 if (forceDirectory == BOS_SALVAGE_FORCE_DIRECTORIES) {
3475 command_len += sprintf(&command[command_len], "-salvagedirs ");
3478 if (forceBlockRead == BOS_SALVAGE_FORCE_BLOCK_READS) {
3479 command_len += sprintf(&command[command_len], "-blockreads ");
3483 sprintf(&command[command_len], "-parallel %d ", numSalvagers);
3485 if ((tmpDir != NULL) && (*tmpDir != 0)) {
3486 command_len += sprintf(&command[command_len], "-tmpdir %s ", tmpDir);
3489 if (command_len > BOS_MAX_NAME_LEN) {
3490 tst = ADMBOSSALVAGEBADOPTIONS;
3491 goto fail_bos_Salvage;
3495 * Create the process at the bosserver and wait until it completes
3498 if (!bos_ProcessCreate
3499 (serverHandle, "salvage-tmp", BOS_PROCESS_CRON, command, "now", 0,
3501 goto fail_bos_Salvage;
3505 bos_ProcessInfoGet(serverHandle, "salvage-tmp", &procType,
3506 &procInfo, &tst))) {
3510 if (tst != BZNOENT) {
3511 goto fail_bos_Salvage;
3515 * Print out the salvage log if required by the user
3520 logData = malloc(INITIAL_LOG_LEN);
3523 goto fail_bos_Salvage;
3527 (serverHandle, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH,
3528 &logLen, logData, &tst)) {
3529 if (logLen > INITIAL_LOG_LEN) {
3530 logData = realloc(logData, (logLen + (logLen / 10)));
3531 if (logData == NULL) {
3533 goto fail_bos_Salvage;
3536 goto fail_bos_Salvage;
3539 fprintf(log, "SalvageLog:\n%s", logData);
3543 * Restart the fileserver if we had stopped it previously
3546 if (try_to_stop_fileserver) {
3547 try_to_stop_fileserver = 0;
3548 if (!bos_ProcessExecutionStateSetTemporary
3549 (serverHandle, "fs", BOS_PROCESS_RUNNING, &tst)) {
3550 goto fail_bos_Salvage;
3561 if (logData != NULL) {
3565 if (try_to_stop_fileserver) {
3566 bos_ProcessExecutionStateSetTemporary(serverHandle, "fs",
3567 BOS_PROCESS_RUNNING, 0);