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_bosAdmin.h"
19 #include "../adminutil/afs_AdminInternal.h"
20 #include <afs/afs_AdminErrors.h>
21 #include <afs/afs_utilAdmin.h>
22 #include <afs/bosint.h>
23 #include <afs/bnode.h>
24 #include <afs/ktime.h>
25 #include <afs/dirpath.h>
27 #include <sys/types.h>
37 typedef struct bos_server {
40 struct rx_connection *server;
41 struct rx_connection *server_encrypt;
42 struct rx_connection *server_stats;
44 } bos_server_t, *bos_server_p;
47 * isValidServerHandle - validate a bos_server_p.
51 * IN serverHandle - the handle to validate
55 * No locks are obtained or released by this function
59 * Returns != 0 upon successful completion.
63 isValidServerHandle(const bos_server_p serverHandle, afs_status_p st)
68 if (serverHandle == NULL) {
69 tst = ADMBOSSERVERHANDLENULL;
70 goto fail_IsValidServerHandle;
73 if ((serverHandle->begin_magic != BEGIN_MAGIC)
74 || (serverHandle->end_magic != END_MAGIC)) {
75 tst = ADMBOSSERVERHANDLEBADMAGIC;
76 goto fail_IsValidServerHandle;
79 if (serverHandle->is_valid == 0) {
80 tst = ADMBOSSERVERHANDLEINVALID;
81 goto fail_IsValidServerHandle;
84 if (serverHandle->server == NULL) {
85 tst = ADMBOSSERVERHANDLENOSERVER;
86 goto fail_IsValidServerHandle;
89 if (serverHandle->server_encrypt == NULL) {
90 tst = ADMBOSSERVERHANDLENOSERVER;
91 goto fail_IsValidServerHandle;
95 fail_IsValidServerHandle:
104 * IsValidCellHandle - verify that a cell handle can be used to make bos
109 * IN cellHandle - the cellHandle to be validated.
113 * No locks are obtained or released by this function
117 * Returns != 0 upon successful completion.
121 IsValidCellHandle(afs_cell_handle_p cellHandle, afs_status_p st)
124 afs_status_t tst = 0;
126 if (!CellHandleIsValid((void *)cellHandle, &tst)) {
127 goto fail_IsValidCellHandle;
130 if (cellHandle->tokens == NULL) {
131 tst = ADMBOSCELLHANDLENOTOKENS;
132 goto fail_IsValidCellHandle;
136 fail_IsValidCellHandle:
145 * bos_ServerOpen - open a bos server for work.
149 * IN cellHandle - a previously opened cellHandle.
151 * IN serverName - the name of the machine that houses the bosserver of
154 * OUT serverHandleP - upon successful completion, this void pointer
155 * will point to a valid server handle for use in future operations.
159 * No locks are obtained or released by this function
163 * Returns != 0 upon successful completion.
167 bos_ServerOpen(const void *cellHandle, const char *serverName,
168 void **serverHandleP, afs_status_p st)
171 afs_status_t tst = 0;
172 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
173 bos_server_p bos_server = (bos_server_p) malloc(sizeof(bos_server_t));
177 * Validate parameters
180 if (!IsValidCellHandle(c_handle, &tst)) {
181 goto fail_bos_ServerOpen;
184 if ((serverName == NULL) || (*serverName == 0)) {
185 tst = ADMBOSSERVERNAMENULL;
186 goto fail_bos_ServerOpen;
189 if (serverHandleP == NULL) {
190 tst = ADMBOSSERVERHANDLEPNULL;
191 goto fail_bos_ServerOpen;
194 if (util_AdminServerAddressGetFromName(serverName, &serverAddress, &tst)
196 goto fail_bos_ServerOpen;
199 if (bos_server == NULL) {
201 goto fail_bos_ServerOpen;
205 rx_GetCachedConnection(htonl(serverAddress), htons(AFSCONF_NANNYPORT),
207 c_handle->tokens->afs_sc[c_handle->tokens->
209 c_handle->tokens->sc_index);
211 bos_server->server_encrypt =
212 rx_GetCachedConnection(htonl(serverAddress), htons(AFSCONF_NANNYPORT),
214 c_handle->tokens->afs_encrypt_sc[c_handle->
217 c_handle->tokens->sc_index);
219 bos_server->server_stats =
220 rx_GetCachedConnection(htonl(serverAddress), htons(AFSCONF_NANNYPORT),
222 c_handle->tokens->afs_sc[c_handle->tokens->
224 c_handle->tokens->sc_index);
226 if ((bos_server->server == NULL) || (bos_server->server_encrypt == NULL)) {
227 tst = ADMBOSSERVERNOCONNECTION;
228 goto fail_bos_ServerOpen;
231 bos_server->begin_magic = BEGIN_MAGIC;
232 bos_server->is_valid = 1;
233 bos_server->end_magic = END_MAGIC;
235 *serverHandleP = (void *)bos_server;
240 if ((rc == 0) && (bos_server != NULL)) {
241 if (bos_server->server) {
242 rx_ReleaseCachedConnection(bos_server->server);
244 if (bos_server->server_encrypt) {
245 rx_ReleaseCachedConnection(bos_server->server_encrypt);
257 * bos_ServerClose - close a bos server handle
261 * IN serverHandle - a bos server handle previously returned by bos_ServerOpen
265 * No locks are obtained or released by this function
269 * Returns != 0 upon successful completion.
273 bos_ServerClose(const void *serverHandle, afs_status_p st)
276 afs_status_t tst = 0;
277 bos_server_p b_handle = (bos_server_p) serverHandle;
279 if (isValidServerHandle(b_handle, &tst)) {
280 rx_ReleaseCachedConnection(b_handle->server);
281 b_handle->is_valid = 0;
293 * bos_ProcessCreate - create a new process to run at a bos server.
297 * IN serverHandle - a previously opened serverHandle.
299 * IN processName - the name of the process to create.
301 * IN processType - the type of process to create.
303 * IN process - the path to the process binary at the bos server.
305 * IN cronTime - the time specification for cron processes.
307 * IN notifier - the path to the notifier binary at the bos server.
311 * No locks are obtained or released by this function
315 * Returns != 0 upon successful completion.
319 * CAUTION - this list must match bos_ProcessType_t definition
322 static char *processTypes[] = { "simple", "fs", "cron", 0 };
325 bos_ProcessCreate(const void *serverHandle, char *processName,
326 bos_ProcessType_t processType, char *process,
327 char *cronTime, char *notifier, afs_status_p st)
330 afs_status_t tst = 0;
331 bos_server_p b_handle = (bos_server_p) serverHandle;
333 if (!isValidServerHandle(b_handle, &tst)) {
334 goto fail_bos_ProcessCreate;
337 if (processType == BOS_PROCESS_FS) {
338 tst = ADMBOSPROCESSCREATEBADTYPE;
339 goto fail_bos_ProcessCreate;
342 if ((processName == NULL) || (*processName == 0)) {
343 tst = ADMBOSPROCESSNAMENULL;
344 goto fail_bos_ProcessCreate;
347 if ((process == NULL) || (*process == 0)) {
348 tst = ADMBOSPROCESSNULL;
349 goto fail_bos_ProcessCreate;
352 if ((processType == BOS_PROCESS_CRON) && (cronTime == NULL)) {
353 tst = ADMBOSCRONTIMENULL;
354 goto fail_bos_ProcessCreate;
357 if ((processType == BOS_PROCESS_SIMPLE) && (cronTime != NULL)) {
358 tst = ADMBOSCRONTIMENOTNULL;
359 goto fail_bos_ProcessCreate;
363 BOZO_CreateBnode(b_handle->server, processTypes[processType],
364 processName, process, (cronTime) ? cronTime : "", "",
365 "", "", (notifier) ? notifier : NONOTIFIER);
370 fail_bos_ProcessCreate:
379 * bos_FSProcessCreate - create the fs group of processes at the boserver.
383 * IN serverHandle - a previously opened serverHandle.
385 * IN processName - the name of the process to create.
387 * IN fileserverPath - the path to the fileserver binary at the bos server.
389 * IN volserverPath - the path to the volserver binary at the bos server.
391 * IN salvagerPath - the path to the salvager binary at the bos server.
393 * IN notifier - the path to the notifier binary at the bos server.
397 * No locks are obtained or released by this function
401 * Returns != 0 upon successful completion.
405 bos_FSProcessCreate(const void *serverHandle, char *processName,
406 char *fileserverPath, char *volserverPath,
407 char *salvagerPath, char *notifier,
411 afs_status_t tst = 0;
412 bos_server_p b_handle = (bos_server_p) serverHandle;
414 if (!isValidServerHandle(b_handle, &tst)) {
415 goto fail_bos_ProcessCreate;
418 if ((processName == NULL) || (*processName == 0)) {
419 tst = ADMBOSPROCESSNAMENULL;
420 goto fail_bos_ProcessCreate;
423 if ((fileserverPath == NULL) || (*fileserverPath == 0)) {
424 tst = ADMBOSFILESERVERPATHNULL;
425 goto fail_bos_ProcessCreate;
428 if ((volserverPath == NULL) || (*volserverPath == 0)) {
429 tst = ADMBOSVOLSERVERPATHNULL;
430 goto fail_bos_ProcessCreate;
433 if ((salvagerPath == NULL) || (*salvagerPath == 0)) {
434 tst = ADMBOSSALVAGERPATHNULL;
435 goto fail_bos_ProcessCreate;
439 BOZO_CreateBnode(b_handle->server, processTypes[BOS_PROCESS_FS],
440 processName, fileserverPath, volserverPath,
441 salvagerPath, "", "",
442 (notifier) ? notifier : NONOTIFIER);
447 fail_bos_ProcessCreate:
456 * bos_ProcessDelete - delete an existing process at a bos server.
460 * IN serverHandle - a previously opened serverHandle.
462 * IN processName - the name of the process to delete.
466 * No locks are obtained or released by this function
470 * Returns != 0 upon successful completion.
474 bos_ProcessDelete(const void *serverHandle, char *processName,
478 afs_status_t tst = 0;
479 bos_server_p b_handle = (bos_server_p) serverHandle;
481 if (!isValidServerHandle(b_handle, &tst)) {
482 goto fail_bos_ProcessDelete;
485 if ((processName == NULL) || (*processName == 0)) {
486 tst = ADMBOSPROCESSNAMENULL;
487 goto fail_bos_ProcessDelete;
490 tst = BOZO_DeleteBnode(b_handle->server, processName);
496 fail_bos_ProcessDelete:
505 * bos_ProcessExecutionStateGet - get the current execution state of a
510 * IN serverHandle - a previously opened serverHandle.
512 * IN processName - the name of the process to retrieve.
514 * OUT processStatusP - upon successful completion the process execution state
516 * OUT auxiliaryProcessStatus - set to point to aux proc status if available.
517 * Pass a pointer to an char array at least BOS_MAX_NAME_LEN long.
521 * No locks are obtained or released by this function
525 * Returns != 0 upon successful completion.
529 bos_ProcessExecutionStateGet(const void *serverHandle,
531 bos_ProcessExecutionState_p processStatusP,
532 char *auxiliaryProcessStatus, afs_status_p st)
535 afs_status_t tst = 0;
536 bos_server_p b_handle = (bos_server_p) serverHandle;
539 if (!isValidServerHandle(b_handle, &tst)) {
540 goto fail_bos_ProcessExecutionStateGet;
543 if ((processName == NULL) || (*processName == 0)) {
544 tst = ADMBOSPROCESSNAMENULL;
545 goto fail_bos_ProcessExecutionStateGet;
548 if (processStatusP == NULL) {
549 tst = ADMBOSPROCESSSTATUSPNULL;
550 goto fail_bos_ProcessExecutionStateGet;
553 if (auxiliaryProcessStatus == NULL) {
554 tst = ADMBOSAUXILIARYPROCESSSTATUSNULL;
555 goto fail_bos_ProcessExecutionStateGet;
559 BOZO_GetStatus(b_handle->server, processName, &state,
560 &auxiliaryProcessStatus);
563 goto fail_bos_ProcessExecutionStateGet;
566 *processStatusP = (bos_ProcessExecutionState_t) state;
569 fail_bos_ProcessExecutionStateGet:
578 * SetExecutionState - set the execution state of a process
582 * IN serverHandle - a previously opened serverHandle.
584 * IN processName - the name of the process to modify.
586 * IN processStatus - the new process state.
588 * IN func - the function to call to set the status.
592 * No locks are obtained or released by this function
596 * Returns != 0 upon successful completion.
600 SetExecutionState(const void *serverHandle, const char *processName,
601 const bos_ProcessExecutionState_t processStatus,
602 int (*func) (struct rx_connection *, char *,
603 afs_int32), afs_status_p st)
606 afs_status_t tst = 0;
607 bos_server_p b_handle = (bos_server_p) serverHandle;
610 if (!isValidServerHandle(b_handle, &tst)) {
611 goto fail_SetExecutionState;
614 if ((processName == NULL) || (*processName == 0)) {
615 tst = ADMBOSPROCESSNAMENULL;
616 goto fail_SetExecutionState;
619 if ((processStatus != BOS_PROCESS_STOPPED)
620 && (processStatus != BOS_PROCESS_RUNNING)) {
621 tst = ADMBOSPROCESSSTATUSSET;
622 goto fail_SetExecutionState;
625 state = (afs_int32) processStatus;
627 tst = func(b_handle->server, (char *)processName, state);
633 fail_SetExecutionState:
642 * bos_ProcessExecutionStateSet - set the execution state of a process
646 * IN serverHandle - a previously opened serverHandle.
648 * IN processName - the name of the process to modify.
650 * IN processStatus - the new process state.
654 * No locks are obtained or released by this function
658 * Returns != 0 upon successful completion.
662 bos_ProcessExecutionStateSet(const void *serverHandle,
663 const char *processName,
664 const bos_ProcessExecutionState_t processStatus,
667 return SetExecutionState(serverHandle, processName, processStatus,
672 * bos_ProcessExecutionStateSetTemporary - set the execution state of a process
677 * IN serverHandle - a previously opened serverHandle.
679 * IN processName - the name of the process to modify.
681 * IN processStatus - the new process state.
685 * No locks are obtained or released by this function
689 * Returns != 0 upon successful completion.
693 bos_ProcessExecutionStateSetTemporary(const void *serverHandle,
695 bos_ProcessExecutionState_t
696 processStatus, afs_status_p st)
698 return SetExecutionState(serverHandle, processName, processStatus,
699 BOZO_SetTStatus, st);
703 * The iterator functions and data for the process name retrieval functions
706 typedef struct process_name_get {
708 struct rx_connection *server;
709 char process[CACHED_ITEMS][BOS_MAX_NAME_LEN];
710 } process_name_get_t, *process_name_get_p;
713 GetProcessNameRPC(void *rpc_specific, int slot, int *last_item,
714 int *last_item_contains_data, afs_status_p st)
717 afs_status_t tst = 0;
718 process_name_get_p proc = (process_name_get_p) rpc_specific;
719 char *ptr = (char *)&proc->process[slot];
721 tst = BOZO_EnumerateInstance(proc->server, proc->next++, &ptr);
725 } else if (tst == BZDOM) {
729 *last_item_contains_data = 0;
739 GetProcessNameFromCache(void *rpc_specific, int slot, void *dest,
743 afs_status_t tst = 0;
744 process_name_get_p proc = (process_name_get_p) rpc_specific;
746 strcpy((char *)dest, (char *)&proc->process[slot]);
756 * bos_ProcessNameGetBegin - begin iterating over the list of processes
757 * at a particular bos server.
761 * IN serverHandle - a previously opened serverHandle.
763 * OUT iter - an iterator that can be passed to bos_ProcessNameGetNext
764 * to retrieve the process names.
768 * No locks are obtained or released by this function
772 * Returns != 0 upon successful completion.
777 bos_ProcessNameGetBegin(const void *serverHandle, void **iterationIdP,
781 afs_status_t tst = 0;
782 bos_server_p b_handle = (bos_server_p) serverHandle;
783 afs_admin_iterator_p iter =
784 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
785 process_name_get_p proc =
786 (process_name_get_p) malloc(sizeof(process_name_get_t));
788 if (!isValidServerHandle(b_handle, &tst)) {
789 goto fail_bos_ProcessNameGetBegin;
792 if (iterationIdP == NULL) {
793 tst = ADMITERATIONIDPNULL;
794 goto fail_bos_ProcessNameGetBegin;
797 if ((iter == NULL) || (proc == NULL)) {
799 goto fail_bos_ProcessNameGetBegin;
803 proc->server = b_handle->server;
806 (iter, (void *)proc, GetProcessNameRPC, GetProcessNameFromCache, NULL,
808 *iterationIdP = (void *)iter;
810 goto fail_bos_ProcessNameGetBegin;
814 fail_bos_ProcessNameGetBegin:
832 * bos_ProcessNameGetNext - retrieve the next process name from the bos server.
836 * IN iterationId - an iterator previously returned by bos_ProcessNameGetBegin
838 * OUT processName - upon successful completion contains the next process name
839 * retrieved from the server.
843 * No locks are obtained or released by this function
847 * Returns != 0 upon successful completion.
852 bos_ProcessNameGetNext(const void *iterationId, char *processName,
856 afs_status_t tst = 0;
857 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
859 if (processName == NULL) {
860 tst = ADMBOSPROCESSNAMENULL;
861 goto fail_bos_ProcessNameGetNext;
864 if (iterationId == NULL) {
865 tst = ADMITERATIONIDPNULL;
866 goto fail_bos_ProcessNameGetNext;
869 rc = IteratorNext(iter, (void *)processName, &tst);
871 fail_bos_ProcessNameGetNext:
880 * bos_ProcessNameGetDone - finish using a process name iterator.
884 * IN iterationId - an iterator previously returned by bos_ProcessNameGetBegin
888 * No locks are obtained or released by this function
892 * Returns != 0 upon successful completion.
897 bos_ProcessNameGetDone(const void *iterationId, afs_status_p st)
900 afs_status_t tst = 0;
901 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
903 if (iterationId == NULL) {
904 tst = ADMITERATIONIDPNULL;
905 goto fail_bos_ProcessNameGetDone;
908 rc = IteratorDone(iter, &tst);
910 fail_bos_ProcessNameGetDone:
919 * bos_ProcessInfoGet - get information about a single process
923 * IN serverHandle - a previously opened serverHandle.
925 * IN processName - the process of interest.
927 * OUT processTypeP - upon successful completion contains the process type
929 * OUT processInfoP - upon successful completion contains the process info
933 * No locks are obtained or released by this function
937 * Returns != 0 upon successful completion.
942 bos_ProcessInfoGet(const void *serverHandle, char *processName,
943 bos_ProcessType_p processTypeP,
944 bos_ProcessInfo_p processInfoP, afs_status_p st)
947 afs_status_t tst = 0;
948 bos_server_p b_handle = (bos_server_p) serverHandle;
949 char type[BOS_MAX_NAME_LEN];
951 struct bozo_status status;
954 if (!isValidServerHandle(b_handle, &tst)) {
955 goto fail_bos_ProcessInfoGet;
958 if ((processName == NULL) || (*processName == 0)) {
959 tst = ADMBOSPROCESSNAMENULL;
960 goto fail_bos_ProcessInfoGet;
963 if (processTypeP == NULL) {
964 tst = ADMBOSPROCESSTYPEPNULL;
965 goto fail_bos_ProcessInfoGet;
968 if (processInfoP == NULL) {
969 tst = ADMBOSPROCESSINFOPNULL;
970 goto fail_bos_ProcessInfoGet;
973 tst = BOZO_GetInstanceInfo(b_handle->server, processName, &ptr, &status);
976 goto fail_bos_ProcessInfoGet;
980 for (i = 0; (processTypes[i] != NULL); i++) {
981 if (!strcmp(processTypes[i], type)) {
982 *processTypeP = (bos_ProcessType_t) i;
987 if (processTypes[i] == NULL) {
988 tst = ADMBOSINVALIDPROCESSTYPE;
989 goto fail_bos_ProcessInfoGet;
992 processInfoP->processGoal = (bos_ProcessExecutionState_t) status.goal;
993 processInfoP->processStartTime = status.procStartTime;
994 processInfoP->numberProcessStarts = status.procStarts;
995 processInfoP->processExitTime = status.lastAnyExit;
996 processInfoP->processExitErrorTime = status.lastErrorExit;
997 processInfoP->processErrorCode = status.errorCode;
998 processInfoP->processErrorSignal = status.errorSignal;
999 processInfoP->state = BOS_PROCESS_OK;
1001 if (status.flags & BOZO_ERRORSTOP) {
1002 processInfoP->state |= BOS_PROCESS_TOO_MANY_ERRORS;
1004 if (status.flags & BOZO_HASCORE) {
1005 processInfoP->state |= BOS_PROCESS_CORE_DUMPED;
1007 if (status.flags & BOZO_BADDIRACCESS) {
1008 processInfoP->state |= BOS_PROCESS_BAD_FILE_ACCESS;
1012 fail_bos_ProcessInfoGet:
1021 * The iterator functions and data for the parameter retrieval functions
1024 typedef struct param_get {
1026 struct rx_connection *server;
1027 char processName[BOS_MAX_NAME_LEN];
1028 char param[CACHED_ITEMS][BOS_MAX_NAME_LEN];
1029 } param_get_t, *param_get_p;
1032 GetParameterRPC(void *rpc_specific, int slot, int *last_item,
1033 int *last_item_contains_data, afs_status_p st)
1036 afs_status_t tst = 0;
1037 param_get_p param = (param_get_p) rpc_specific;
1038 char *ptr = (char *)¶m->param[slot];
1041 BOZO_GetInstanceParm(param->server, param->processName, param->next++,
1046 } else if (tst == BZDOM) {
1050 *last_item_contains_data = 0;
1060 GetParameterFromCache(void *rpc_specific, int slot, void *dest,
1064 afs_status_t tst = 0;
1065 param_get_p param = (param_get_p) rpc_specific;
1067 strcpy((char *)dest, (char *)¶m->param[slot]);
1077 * bos_ProcessParameterGetBegin - begin iterating over the parameters
1078 * of a particular process.
1082 * IN serverHandle - a previously opened serverHandle.
1084 * IN processName - the process whose parameters are returned.
1086 * OUT iter - an iterator that can be passed to bos_ProcessParameterGetNext
1087 * to retrieve the parameters.
1091 * No locks are obtained or released by this function
1095 * Returns != 0 upon successful completion.
1100 bos_ProcessParameterGetBegin(const void *serverHandle,
1101 const char *processName, void **iterationIdP,
1105 afs_status_t tst = 0;
1106 bos_server_p b_handle = (bos_server_p) serverHandle;
1107 afs_admin_iterator_p iter =
1108 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1109 param_get_p param = (param_get_p) malloc(sizeof(param_get_t));
1111 if (!isValidServerHandle(b_handle, &tst)) {
1112 goto fail_bos_ProcessParameterGetBegin;
1115 if ((processName == NULL) || (*processName == 0)) {
1116 tst = ADMBOSPROCESSNAMENULL;
1117 goto fail_bos_ProcessParameterGetBegin;
1120 if (iterationIdP == NULL) {
1121 tst = ADMITERATIONIDPNULL;
1122 goto fail_bos_ProcessParameterGetBegin;
1125 if ((iter == NULL) || (param == NULL)) {
1127 goto fail_bos_ProcessParameterGetBegin;
1131 param->server = b_handle->server;
1132 strcpy(param->processName, processName);
1135 (iter, (void *)param, GetParameterRPC, GetParameterFromCache, NULL,
1137 *iterationIdP = (void *)iter;
1139 goto fail_bos_ProcessParameterGetBegin;
1143 fail_bos_ProcessParameterGetBegin:
1149 if (param != NULL) {
1161 * bos_ProcessParameterGetNext - retrieve the next parameter
1162 * from the bos server.
1166 * IN iterationId - an iterator previously returned by
1167 * bos_ProcessParameterGetBegin
1169 * OUT parameter - upon successful completion contains the next parameter
1170 * retrieved from the server.
1174 * No locks are obtained or released by this function
1178 * Returns != 0 upon successful completion.
1183 bos_ProcessParameterGetNext(const void *iterationId, char *parameter,
1187 afs_status_t tst = 0;
1188 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1190 if (iterationId == NULL) {
1191 tst = ADMITERATIONIDPNULL;
1192 goto fail_bos_ProcessParameterGetNext;
1195 if (parameter == NULL) {
1196 tst = ADMBOSPARAMETERNULL;
1197 goto fail_bos_ProcessParameterGetNext;
1200 rc = IteratorNext(iter, (void *)parameter, &tst);
1202 fail_bos_ProcessParameterGetNext:
1211 * bos_ProcessParameterGetDone - finish using a process name iterator.
1215 * IN iterationId - an iterator previously returned by
1216 * bos_ProcessParameterGetBegin
1220 * No locks are obtained or released by this function
1224 * Returns != 0 upon successful completion.
1229 bos_ProcessParameterGetDone(const void *iterationId, afs_status_p st)
1232 afs_status_t tst = 0;
1233 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1235 if (iterationId == NULL) {
1236 tst = ADMITERATIONIDPNULL;
1237 goto fail_bos_ProcessParameterGetDone;
1240 rc = IteratorDone(iter, &tst);
1242 fail_bos_ProcessParameterGetDone:
1251 * bos_ProcessNotifierGet - retrieve the notifier associated with a
1256 * IN serverHandle - a previously opened serverHandle.
1258 * IN processName - the process whose notifier we are retrieving.
1260 * OUT notifier - upon successful completion contains the notifier.
1264 * No locks are obtained or released by this function
1268 * Returns != 0 upon successful completion.
1273 bos_ProcessNotifierGet(const void *serverHandle, const char *processName,
1274 char *notifier, afs_status_p st)
1277 afs_status_t tst = 0;
1278 bos_server_p b_handle = (bos_server_p) serverHandle;
1280 if (!isValidServerHandle(b_handle, &tst)) {
1281 goto fail_bos_ProcessNotifierGet;
1284 if ((processName == NULL) || (*processName == 0)) {
1285 tst = ADMBOSPROCESSNAMENULL;
1286 goto fail_bos_ProcessNotifierGet;
1289 if (notifier == NULL) {
1290 tst = ADMBOSNOTIFIERNULL;
1291 goto fail_bos_ProcessNotifierGet;
1294 tst = BOZO_GetInstanceParm(b_handle->server, (char *)processName,
1301 fail_bos_ProcessNotifierGet:
1310 * bos_ProcessRestart - restart a particular process.
1314 * IN serverHandle - a previously opened serverHandle.
1316 * IN processName - the process to restart
1320 * No locks are obtained or released by this function
1324 * Returns != 0 upon successful completion.
1329 bos_ProcessRestart(const void *serverHandle, const char *processName,
1333 afs_status_t tst = 0;
1334 bos_server_p b_handle = (bos_server_p) serverHandle;
1336 if (!isValidServerHandle(b_handle, &tst)) {
1337 goto fail_bos_ProcessRestart;
1340 if ((processName == NULL) || (*processName == 0)) {
1341 tst = ADMBOSPROCESSNAMENULL;
1342 goto fail_bos_ProcessRestart;
1345 tst = BOZO_Restart(b_handle->server, (char *)processName);
1351 fail_bos_ProcessRestart:
1360 * bos_ProcessAllStop - stop all running processes at a server.
1364 * IN serverHandle - a previously opened serverHandle.
1368 * No locks are obtained or released by this function
1372 * Returns != 0 upon successful completion.
1377 bos_ProcessAllStop(const void *serverHandle, afs_status_p st)
1380 afs_status_t tst = 0;
1381 bos_server_p b_handle = (bos_server_p) serverHandle;
1383 if (!isValidServerHandle(b_handle, &tst)) {
1384 goto fail_bos_ProcessAllStop;
1387 tst = BOZO_ShutdownAll(b_handle->server);
1393 fail_bos_ProcessAllStop:
1402 * bos_ProcessAllStart - start all processes that should be running at a
1407 * IN serverHandle - a previously opened serverHandle.
1411 * No locks are obtained or released by this function
1415 * Returns != 0 upon successful completion.
1420 bos_ProcessAllStart(const void *serverHandle, afs_status_p st)
1423 afs_status_t tst = 0;
1424 bos_server_p b_handle = (bos_server_p) serverHandle;
1426 if (!isValidServerHandle(b_handle, &tst)) {
1427 goto fail_bos_ProcessAllStart;
1430 tst = BOZO_StartupAll(b_handle->server);
1436 fail_bos_ProcessAllStart:
1445 * bos_ProcessAllWaitStop - stop all processes, and block until they have
1450 * IN serverHandle - a previously opened serverHandle.
1454 * No locks are obtained or released by this function
1458 * Returns != 0 upon successful completion.
1463 bos_ProcessAllWaitStop(const void *serverHandle, afs_status_p st)
1466 afs_status_t tst = 0;
1467 bos_server_p b_handle = (bos_server_p) serverHandle;
1469 if (!isValidServerHandle(b_handle, &tst)) {
1470 goto fail_bos_ProcessAllWaitStop;
1473 if (!bos_ProcessAllStop(serverHandle, &tst)) {
1474 goto fail_bos_ProcessAllWaitStop;
1477 tst = BOZO_WaitAll(b_handle->server);
1483 fail_bos_ProcessAllWaitStop:
1492 * bos_ProcessAllWaitTransition - block until all processes at the bosserver
1493 * have reached their desired state.
1497 * IN serverHandle - a previously opened serverHandle.
1501 * No locks are obtained or released by this function
1505 * Returns != 0 upon successful completion.
1510 bos_ProcessAllWaitTransition(const void *serverHandle, afs_status_p st)
1513 afs_status_t tst = 0;
1514 bos_server_p b_handle = (bos_server_p) serverHandle;
1516 if (!isValidServerHandle(b_handle, &tst)) {
1517 goto fail_bos_ProcessAllWaitTransition;
1520 tst = BOZO_WaitAll(b_handle->server);
1526 fail_bos_ProcessAllWaitTransition:
1535 * bos_ProcessAllStopAndRestart - stop all the running processes, restart
1536 * them, and optionally restart the bosserver itself.
1541 * IN serverHandle - a previously opened serverHandle.
1543 * IN restartBosServer - flag to indicate whether to restart bosserver.
1547 * No locks are obtained or released by this function
1551 * Returns != 0 upon successful completion.
1556 bos_ProcessAllStopAndRestart(const void *serverHandle,
1557 bos_RestartBosServer_t restartBosServer,
1561 afs_status_t tst = 0;
1562 bos_server_p b_handle = (bos_server_p) serverHandle;
1564 if (!isValidServerHandle(b_handle, &tst)) {
1565 goto fail_bos_ProcessAllStopAndRestart;
1568 if (restartBosServer == BOS_RESTART_BOS_SERVER) {
1569 tst = BOZO_ReBozo(b_handle->server);
1571 goto fail_bos_ProcessAllStopAndRestart;
1575 tst = BOZO_RestartAll(b_handle->server);
1581 fail_bos_ProcessAllStopAndRestart:
1590 * bos_AdminCreate - create a new admin.
1594 * IN serverHandle - a previously opened serverHandle.
1596 * IN adminName - the new admin name.
1600 * No locks are obtained or released by this function
1604 * Returns != 0 upon successful completion.
1609 bos_AdminCreate(const void *serverHandle, const char *adminName,
1613 afs_status_t tst = 0;
1614 bos_server_p b_handle = (bos_server_p) serverHandle;
1616 if (!isValidServerHandle(b_handle, &tst)) {
1617 goto fail_bos_AdminCreate;
1620 if ((adminName == NULL) || (*adminName == 0)) {
1621 tst = ADMBOSADMINNAMENULL;
1622 goto fail_bos_AdminCreate;
1625 tst = BOZO_AddSUser(b_handle->server, (char *)adminName);
1631 fail_bos_AdminCreate:
1640 * bos_AdminDelete - delete a new admin.
1644 * IN serverHandle - a previously opened serverHandle.
1646 * IN adminName - the admin name.
1650 * No locks are obtained or released by this function
1654 * Returns != 0 upon successful completion.
1659 bos_AdminDelete(const void *serverHandle, const char *adminName,
1663 afs_status_t tst = 0;
1664 bos_server_p b_handle = (bos_server_p) serverHandle;
1666 if (!isValidServerHandle(b_handle, &tst)) {
1667 goto fail_bos_AdminDelete;
1670 if ((adminName == NULL) || (*adminName == 0)) {
1671 tst = ADMBOSADMINNAMENULL;
1672 goto fail_bos_AdminDelete;
1675 tst = BOZO_DeleteSUser(b_handle->server, (char *)adminName);
1681 fail_bos_AdminDelete:
1690 * The iterator functions and data for the admin retrieval functions
1693 typedef struct admin_get {
1695 struct rx_connection *server;
1696 char admin[CACHED_ITEMS][BOS_MAX_NAME_LEN];
1697 } admin_get_t, *admin_get_p;
1700 GetAdminRPC(void *rpc_specific, int slot, int *last_item,
1701 int *last_item_contains_data, afs_status_p st)
1704 afs_status_t tst = 0;
1705 admin_get_p admin = (admin_get_p) rpc_specific;
1706 char *ptr = (char *)&admin->admin[slot];
1708 tst = BOZO_ListSUsers(admin->server, admin->next++, &ptr);
1711 * There's no way to tell the difference between an rpc failure
1712 * and the end of the list, so we assume that any error means the
1719 *last_item_contains_data = 0;
1730 GetAdminFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
1733 afs_status_t tst = 0;
1734 admin_get_p admin = (admin_get_p) rpc_specific;
1736 strcpy((char *)dest, (char *)&admin->admin[slot]);
1746 * bos_AdminGetBegin - begin iterating over the administrators.
1750 * IN serverHandle - a previously opened serverHandle.
1752 * OUT iter - an iterator that can be passed to bos_AdminGetBegin
1753 * to retrieve the administrators.
1757 * No locks are obtained or released by this function
1761 * Returns != 0 upon successful completion.
1766 bos_AdminGetBegin(const void *serverHandle, void **iterationIdP,
1770 afs_status_t tst = 0;
1771 bos_server_p b_handle = (bos_server_p) serverHandle;
1772 afs_admin_iterator_p iter =
1773 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1774 admin_get_p admin = (admin_get_p) malloc(sizeof(admin_get_t));
1776 if (!isValidServerHandle(b_handle, &tst)) {
1777 goto fail_bos_AdminGetBegin;
1780 if (iterationIdP == NULL) {
1781 tst = ADMITERATIONIDPNULL;
1782 goto fail_bos_AdminGetBegin;
1785 if ((iter == NULL) || (admin == NULL)) {
1787 goto fail_bos_AdminGetBegin;
1791 admin->server = b_handle->server;
1794 (iter, (void *)admin, GetAdminRPC, GetAdminFromCache, NULL, NULL,
1796 *iterationIdP = (void *)iter;
1800 fail_bos_AdminGetBegin:
1806 if (admin != NULL) {
1818 * bos_AdminGetNext - retrieve the next administrator
1819 * from the bos server.
1823 * IN iterationId - an iterator previously returned by
1826 * OUT adminName - upon successful completion contains the next administrator
1827 * retrieved from the server.
1831 * No locks are obtained or released by this function
1835 * Returns != 0 upon successful completion.
1840 bos_AdminGetNext(const void *iterationId, char *adminName, afs_status_p st)
1843 afs_status_t tst = 0;
1844 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1846 if (iterationId == NULL) {
1847 tst = ADMITERATIONIDPNULL;
1848 goto fail_bos_AdminGetNext;
1851 if (adminName == NULL) {
1852 tst = ADMBOSADMINNAMENULL;
1853 goto fail_bos_AdminGetNext;
1856 rc = IteratorNext(iter, (void *)adminName, &tst);
1858 fail_bos_AdminGetNext:
1867 * bos_AdminGetDone - finish using a administrator iterator.
1871 * IN iterationId - an iterator previously returned by
1876 * No locks are obtained or released by this function
1880 * Returns != 0 upon successful completion.
1885 bos_AdminGetDone(const void *iterationId, afs_status_p st)
1888 afs_status_t tst = 0;
1889 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1891 if (iterationId == NULL) {
1892 tst = ADMITERATIONIDPNULL;
1893 goto fail_bos_AdminGetDone;
1896 rc = IteratorDone(iter, &tst);
1898 fail_bos_AdminGetDone:
1907 * bos_KeyCreate - add a new key to the keyfile.
1911 * IN serverHandle - a previously opened serverHandle.
1913 * IN keyVersionNumber - the key version number.
1915 * IN key - the new key.
1919 * No locks are obtained or released by this function
1923 * Returns != 0 upon successful completion.
1928 bos_KeyCreate(const void *serverHandle, int keyVersionNumber,
1929 const kas_encryptionKey_p key, afs_status_p st)
1932 afs_status_t tst = 0;
1933 bos_server_p b_handle = (bos_server_p) serverHandle;
1935 if (!isValidServerHandle(b_handle, &tst)) {
1936 goto fail_bos_KeyCreate;
1940 tst = ADMBOSKEYNULL;
1941 goto fail_bos_KeyCreate;
1944 tst = BOZO_AddKey(b_handle->server_encrypt, keyVersionNumber, kas_to_bozoptr(key));
1959 * bos_KeyDelete - delete an existing key from the keyfile.
1963 * IN serverHandle - a previously opened serverHandle.
1965 * IN keyVersionNumber - the key version number.
1969 * No locks are obtained or released by this function
1973 * Returns != 0 upon successful completion.
1978 bos_KeyDelete(const void *serverHandle, int keyVersionNumber, afs_status_p st)
1981 afs_status_t tst = 0;
1982 bos_server_p b_handle = (bos_server_p) serverHandle;
1984 if (!isValidServerHandle(b_handle, &tst)) {
1985 goto fail_bos_KeyDelete;
1988 tst = BOZO_DeleteKey(b_handle->server, keyVersionNumber);
2003 * The iterator functions and data for the key retrieval functions
2006 typedef struct key_get {
2008 struct rx_connection *server;
2009 bos_KeyInfo_t key[CACHED_ITEMS];
2010 } key_get_t, *key_get_p;
2013 GetKeyRPC(void *rpc_specific, int slot, int *last_item,
2014 int *last_item_contains_data, afs_status_p st)
2017 afs_status_t tst = 0;
2018 key_get_p key = (key_get_p) rpc_specific;
2019 struct bozo_keyInfo keyInfo;
2022 BOZO_ListKeys(key->server, key->next++,
2023 &key->key[slot].keyVersionNumber, kas_to_bozoptr(&key->key[slot].key),
2028 key->key[slot].keyStatus.lastModificationDate = keyInfo.mod_sec;
2029 key->key[slot].keyStatus.lastModificationMicroSeconds =
2031 key->key[slot].keyStatus.checkSum = keyInfo.keyCheckSum;
2033 } else if (tst == BZDOM) {
2037 *last_item_contains_data = 0;
2047 GetKeyFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
2050 afs_status_t tst = 0;
2051 key_get_p key = (key_get_p) rpc_specific;
2053 memcpy(dest, &key->key[slot], sizeof(bos_KeyInfo_t));
2063 * bos_KeyGetBegin - begin iterating over the keys.
2067 * IN serverHandle - a previously opened serverHandle.
2069 * OUT iter - an iterator that can be passed to bos_KeyGetNext
2070 * to retrieve the keys.
2074 * No locks are obtained or released by this function
2078 * Returns != 0 upon successful completion.
2083 bos_KeyGetBegin(const void *serverHandle, void **iterationIdP,
2087 afs_status_t tst = 0;
2088 bos_server_p b_handle = (bos_server_p) serverHandle;
2089 afs_admin_iterator_p iter =
2090 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
2091 key_get_p key = (key_get_p) malloc(sizeof(key_get_t));
2093 if (!isValidServerHandle(b_handle, &tst)) {
2094 goto fail_bos_KeyGetBegin;
2097 if (iterationIdP == NULL) {
2098 tst = ADMITERATIONIDPNULL;
2099 goto fail_bos_KeyGetBegin;
2102 if ((iter == NULL) || (key == NULL)) {
2104 goto fail_bos_KeyGetBegin;
2108 key->server = b_handle->server_encrypt;
2111 (iter, (void *)key, GetKeyRPC, GetKeyFromCache, NULL, NULL, &tst)) {
2112 *iterationIdP = (void *)iter;
2116 fail_bos_KeyGetBegin:
2134 * bos_KeyGetNext - retrieve the next key
2135 * from the bos server.
2139 * IN iterationId - an iterator previously returned by
2142 * OUT keyP - upon successful completion contains the next key
2143 * retrieved from the server.
2147 * No locks are obtained or released by this function
2151 * Returns != 0 upon successful completion.
2156 bos_KeyGetNext(const void *iterationId, bos_KeyInfo_p keyP, afs_status_p st)
2159 afs_status_t tst = 0;
2160 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2162 if (iterationId == NULL) {
2163 tst = ADMITERATIONIDPNULL;
2164 goto fail_bos_KeyGetNext;
2168 tst = ADMBOSKEYPNULL;
2169 goto fail_bos_KeyGetNext;
2172 rc = IteratorNext(iter, (void *)keyP, &tst);
2174 fail_bos_KeyGetNext:
2183 * bos_KeyGetDone - finish using a key iterator.
2187 * IN iterationId - an iterator previously returned by
2192 * No locks are obtained or released by this function
2196 * Returns != 0 upon successful completion.
2201 bos_KeyGetDone(const void *iterationId, afs_status_p st)
2204 afs_status_t tst = 0;
2205 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2207 if (iterationId == NULL) {
2208 tst = ADMITERATIONIDPNULL;
2209 goto fail_bos_KeyGetDone;
2212 rc = IteratorDone(iter, &tst);
2214 fail_bos_KeyGetDone:
2223 * bos_CellSet - set the cell name at a bos server.
2227 * IN serverHandle - a previously opened serverHandle.
2229 * IN cellName - the new cell name.
2233 * No locks are obtained or released by this function
2237 * Returns != 0 upon successful completion.
2241 bos_CellSet(const void *serverHandle, const char *cellName, afs_status_p st)
2244 afs_status_t tst = 0;
2245 bos_server_p b_handle = (bos_server_p) serverHandle;
2247 if (!isValidServerHandle(b_handle, &tst)) {
2248 goto fail_bos_CellSet;
2251 if ((cellName == NULL) || (*cellName == 0)) {
2252 tst = ADMCLIENTCELLNAMENULL;
2253 goto fail_bos_CellSet;
2256 tst = BOZO_SetCellName(b_handle->server, (char *)cellName);
2271 * bos_CellGet - get the cell name at a bos server.
2275 * IN serverHandle - a previously opened serverHandle.
2277 * OUT cellName - the cell name.
2281 * No locks are obtained or released by this function
2285 * Returns != 0 upon successful completion.
2289 bos_CellGet(const void *serverHandle, char *cellName, afs_status_p st)
2292 afs_status_t tst = 0;
2293 bos_server_p b_handle = (bos_server_p) serverHandle;
2295 if (!isValidServerHandle(b_handle, &tst)) {
2296 goto fail_bos_CellGet;
2299 if (cellName == NULL) {
2300 tst = ADMCLIENTCELLNAMENULL;
2301 goto fail_bos_CellGet;
2304 tst = BOZO_GetCellName(b_handle->server, &cellName);
2319 * bos_HostCreate - add a new host to the cell.
2323 * IN serverHandle - a previously opened serverHandle.
2325 * IN hostName - the new host.
2329 * No locks are obtained or released by this function
2333 * Returns != 0 upon successful completion.
2337 bos_HostCreate(const void *serverHandle, const char *hostName,
2341 afs_status_t tst = 0;
2342 bos_server_p b_handle = (bos_server_p) serverHandle;
2344 if (!isValidServerHandle(b_handle, &tst)) {
2345 goto fail_bos_HostCreate;
2348 if ((hostName == NULL) || (*hostName == 0)) {
2349 tst = ADMBOSHOSTNAMENULL;
2350 goto fail_bos_HostCreate;
2353 tst = BOZO_AddCellHost(b_handle->server, (char *)hostName);
2359 fail_bos_HostCreate:
2368 * bos_HostDelete - delete a host from the cell.
2372 * IN serverHandle - a previously opened serverHandle.
2374 * IN hostName - the host.
2378 * No locks are obtained or released by this function
2382 * Returns != 0 upon successful completion.
2386 bos_HostDelete(const void *serverHandle, const char *hostName,
2390 afs_status_t tst = 0;
2391 bos_server_p b_handle = (bos_server_p) serverHandle;
2393 if (!isValidServerHandle(b_handle, &tst)) {
2394 goto fail_bos_HostDelete;
2397 if ((hostName == NULL) || (*hostName == 0)) {
2398 tst = ADMBOSHOSTNAMENULL;
2399 goto fail_bos_HostDelete;
2402 tst = BOZO_DeleteCellHost(b_handle->server, (char *)hostName);
2408 fail_bos_HostDelete:
2417 * The iterator functions and data for the host retrieval functions
2420 typedef struct host_get {
2422 struct rx_connection *server;
2423 char host[CACHED_ITEMS][BOS_MAX_NAME_LEN];
2424 } host_get_t, *host_get_p;
2427 GetHostRPC(void *rpc_specific, int slot, int *last_item,
2428 int *last_item_contains_data, afs_status_p st)
2431 afs_status_t tst = 0;
2432 host_get_p host = (host_get_p) rpc_specific;
2433 char *ptr = (char *)&host->host[slot];
2435 tst = BOZO_GetCellHost(host->server, host->next++, &ptr);
2439 } else if (tst == BZDOM) {
2443 *last_item_contains_data = 0;
2453 GetHostFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
2456 afs_status_t tst = 0;
2457 host_get_p host = (host_get_p) rpc_specific;
2459 strcpy((char *)dest, (char *)&host->host[slot]);
2469 * bos_HostGetBegin - begin iterating over the hosts in a cell
2470 * at a particular bos server.
2474 * IN serverHandle - a previously opened serverHandle.
2476 * OUT iter - an iterator that can be passed to bos_HostGetNext
2477 * to retrieve the process names.
2481 * No locks are obtained or released by this function
2485 * Returns != 0 upon successful completion.
2490 bos_HostGetBegin(const void *serverHandle, void **iterationIdP,
2494 afs_status_t tst = 0;
2495 bos_server_p b_handle = (bos_server_p) serverHandle;
2496 afs_admin_iterator_p iter =
2497 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
2498 host_get_p host = (host_get_p) malloc(sizeof(host_get_t));
2500 if (!isValidServerHandle(b_handle, &tst)) {
2501 goto fail_bos_HostGetBegin;
2504 if (iterationIdP == NULL) {
2505 tst = ADMITERATIONIDPNULL;
2506 goto fail_bos_HostGetBegin;
2509 if ((iter == NULL) || (host == NULL)) {
2511 goto fail_bos_HostGetBegin;
2515 host->server = b_handle->server;
2518 (iter, (void *)host, GetHostRPC, GetHostFromCache, NULL, NULL,
2520 *iterationIdP = (void *)iter;
2524 fail_bos_HostGetBegin:
2542 * bos_HostGetNext - retrieve the next host
2543 * from the bos server.
2547 * IN iterationId - an iterator previously returned by
2550 * OUT hostName - upon successful completion contains the next host
2551 * retrieved from the server.
2555 * No locks are obtained or released by this function
2559 * Returns != 0 upon successful completion.
2564 bos_HostGetNext(const void *iterationId, char *hostName, afs_status_p st)
2567 afs_status_t tst = 0;
2568 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2570 if (iterationId == NULL) {
2571 tst = ADMITERATIONIDPNULL;
2572 goto fail_bos_HostGetNext;
2575 if (hostName == NULL) {
2576 tst = ADMBOSHOSTNAMENULL;
2577 goto fail_bos_HostGetNext;
2580 rc = IteratorNext(iter, (void *)hostName, &tst);
2582 fail_bos_HostGetNext:
2591 * bos_HostGetDone - finish using a host iterator.
2595 * IN iterationId - an iterator previously returned by
2600 * No locks are obtained or released by this function
2604 * Returns != 0 upon successful completion.
2609 bos_HostGetDone(const void *iterationId, afs_status_p st)
2612 afs_status_t tst = 0;
2613 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2615 if (iterationId == NULL) {
2616 tst = ADMITERATIONIDPNULL;
2617 goto fail_bos_HostGetDone;
2620 rc = IteratorDone(iter, &tst);
2622 fail_bos_HostGetDone:
2631 * bos_ExecutableCreate - create a new executable at the bos server.
2635 * IN serverHandle - a previously opened serverHandle.
2637 * IN sourceFile - the executable to install at the bos server.
2639 * IN destFile - the location where the executable will be installed.
2643 * No locks are obtained or released by this function
2647 * Returns != 0 upon successful completion.
2652 bos_ExecutableCreate(const void *serverHandle, const char *sourceFile,
2653 const char *destFile, afs_status_p st)
2656 afs_status_t tst = 0;
2657 bos_server_p b_handle = (bos_server_p) serverHandle;
2660 struct rx_call *tcall;
2663 * Validate arguments
2666 if (!isValidServerHandle(b_handle, &tst)) {
2667 goto fail_bos_ExecutableCreate;
2670 if ((sourceFile == NULL) || (*sourceFile == 0)) {
2671 tst = ADMBOSSOURCEFILENULL;
2672 goto fail_bos_ExecutableCreate;
2675 if ((destFile == NULL) || (*destFile == 0)) {
2676 tst = ADMBOSDESTFILENULL;
2677 goto fail_bos_ExecutableCreate;
2681 * Open the file locally and compute its size
2684 fd = open(sourceFile, O_RDONLY);
2687 tst = ADMBOSCANTOPENSOURCEFILE;
2688 goto fail_bos_ExecutableCreate;
2691 if (fstat(fd, &estat)) {
2692 tst = ADMBOSCANTSTATSOURCEFILE;
2693 goto fail_bos_ExecutableCreate;
2697 * Start a split rpc to the bos server.
2700 tcall = rx_NewCall(b_handle->server);
2703 StartBOZO_Install(tcall, (char *)destFile, estat.st_size,
2704 (afs_int32) estat.st_mode, estat.st_mtime);
2707 rx_EndCall(tcall, tst);
2708 goto fail_bos_ExecutableCreate;
2712 * Copy the data to the server
2718 len = read(fd, tbuffer, sizeof(tbuffer));
2720 tst = ADMBOSCANTREADSOURCEFILE;
2721 rx_EndCall(tcall, len);
2722 goto fail_bos_ExecutableCreate;
2728 tst = rx_Write(tcall, tbuffer, len);
2730 tst = ADMBOSSENDSOURCEFILE;
2731 rx_EndCall(tcall, tst);
2732 goto fail_bos_ExecutableCreate;
2737 * Terminate the rpc to the server
2740 tst = rx_EndCall(tcall, tst);
2746 fail_bos_ExecutableCreate:
2755 * bos_ExecutableRevert - revert an executable to a previous .BAK version.
2759 * IN serverHandle - a previously opened serverHandle.
2761 * IN execFile - the executable to revert at the bos server.
2765 * No locks are obtained or released by this function
2769 * Returns != 0 upon successful completion.
2774 bos_ExecutableRevert(const void *serverHandle, const char *execFile,
2778 afs_status_t tst = 0;
2779 bos_server_p b_handle = (bos_server_p) serverHandle;
2781 if (!isValidServerHandle(b_handle, &tst)) {
2782 goto fail_bos_ExecutableRevert;
2785 if ((execFile == NULL) || (*execFile == 0)) {
2786 tst = ADMBOSEXECFILENULL;
2787 goto fail_bos_ExecutableRevert;
2790 tst = BOZO_UnInstall(b_handle->server, (char *)execFile);
2796 fail_bos_ExecutableRevert:
2805 * bos_ExecutableTimestampGet - get the last mod times for an executable,
2806 * the .BAK version of the executable, and the .OLD version of the
2807 * executable if they exist.
2811 * IN serverHandle - a previously opened serverHandle.
2813 * IN execFile - the executable to revert at the bos server.
2817 * No locks are obtained or released by this function
2821 * Returns != 0 upon successful completion.
2826 bos_ExecutableTimestampGet(const void *serverHandle, const char *execFile,
2827 afs_int32 *newTime, afs_int32 *oldTime,
2828 afs_int32 *bakTime, afs_status_p st)
2831 afs_status_t tst = 0;
2832 bos_server_p b_handle = (bos_server_p) serverHandle;
2834 if (!isValidServerHandle(b_handle, &tst)) {
2835 goto fail_bos_ExecutableTimestampGet;
2838 if ((execFile == NULL) || (*execFile == 0)) {
2839 tst = ADMBOSEXECFILENULL;
2840 goto fail_bos_ExecutableTimestampGet;
2843 if (newTime == NULL) {
2844 tst = ADMBOSNEWTIMENULL;
2845 goto fail_bos_ExecutableTimestampGet;
2848 if (oldTime == NULL) {
2849 tst = ADMBOSOLDTIMENULL;
2850 goto fail_bos_ExecutableTimestampGet;
2853 if (bakTime == NULL) {
2854 tst = ADMBOSBAKTIMENULL;
2855 goto fail_bos_ExecutableTimestampGet;
2859 BOZO_GetDates(b_handle->server, (char *)execFile, newTime, bakTime, oldTime);
2865 fail_bos_ExecutableTimestampGet:
2874 * bos_ExecutablePrune - prune the bak, old, and core files off a server
2879 * IN serverHandle - a previously opened serverHandle.
2881 * IN oldFiles - prune .OLD files.
2883 * IN bakFiles - prune .BAK files.
2885 * IN coreFiles - prune core files.
2889 * No locks are obtained or released by this function
2893 * Returns != 0 upon successful completion.
2898 bos_ExecutablePrune(const void *serverHandle, bos_Prune_t oldFiles,
2899 bos_Prune_t bakFiles, bos_Prune_t coreFiles,
2903 afs_status_t tst = 0;
2904 bos_server_p b_handle = (bos_server_p) serverHandle;
2905 afs_int32 flags = 0;
2907 if (!isValidServerHandle(b_handle, &tst)) {
2908 goto fail_bos_ExecutablePrune;
2911 if (oldFiles == BOS_PRUNE) {
2912 flags |= BOZO_PRUNEOLD;
2915 if (bakFiles == BOS_PRUNE) {
2916 flags |= BOZO_PRUNEBAK;
2919 if (coreFiles == BOS_PRUNE) {
2920 flags |= BOZO_PRUNECORE;
2923 tst = BOZO_Prune(b_handle->server, flags);
2929 fail_bos_ExecutablePrune:
2938 * bos_ExecutableRestartTimeSet - set the restart time of the bos server
2943 * IN serverHandle - a previously opened serverHandle.
2945 * IN type - specifies either weekly restart or daily restart time.
2947 * IN time - the time to begin restarts.
2951 * No locks are obtained or released by this function
2955 * Returns != 0 upon successful completion.
2960 bos_ExecutableRestartTimeSet(const void *serverHandle, bos_Restart_t type,
2961 bos_RestartTime_t time, afs_status_p st)
2964 afs_status_t tst = 0;
2965 bos_server_p b_handle = (bos_server_p) serverHandle;
2966 afs_int32 restartType = 0;
2967 struct bozo_netKTime restartTime;
2969 if (!isValidServerHandle(b_handle, &tst)) {
2970 goto fail_bos_ExecutableRestartTimeSet;
2973 if (type == BOS_RESTART_WEEKLY) {
2979 if ((time.mask & BOS_RESTART_TIME_HOUR)
2980 && ((time.hour < 0) || (time.hour > 23))) {
2981 tst = ADMBOSHOURINVALID;
2982 goto fail_bos_ExecutableRestartTimeSet;
2985 if ((time.mask & BOS_RESTART_TIME_MINUTE)
2986 && ((time.min < 0) || (time.min > 60))) {
2987 tst = ADMBOSMINUTEINVALID;
2988 goto fail_bos_ExecutableRestartTimeSet;
2991 if ((time.mask & BOS_RESTART_TIME_SECOND)
2992 && ((time.sec < 0) || (time.sec > 60))) {
2993 tst = ADMBOSSECONDINVALID;
2994 goto fail_bos_ExecutableRestartTimeSet;
2997 if ((time.mask & BOS_RESTART_TIME_DAY)
2998 && ((time.day < 0) || (time.day > 6))) {
2999 tst = ADMBOSDAYINVALID;
3000 goto fail_bos_ExecutableRestartTimeSet;
3003 restartTime.mask = time.mask;
3004 restartTime.hour = time.hour;
3005 restartTime.min = time.min;
3006 restartTime.sec = time.sec;
3007 restartTime.day = time.day;
3009 tst = BOZO_SetRestartTime(b_handle->server, restartType, &restartTime);
3015 fail_bos_ExecutableRestartTimeSet:
3024 * bos_ExecutableRestartTimeGet - get the restart time of the bos server
3029 * IN serverHandle - a previously opened serverHandle.
3031 * IN type - specifies either weekly restart or daily restart time.
3033 * OUT timeP - the time to begin restarts.
3037 * No locks are obtained or released by this function
3041 * Returns != 0 upon successful completion.
3046 bos_ExecutableRestartTimeGet(const void *serverHandle, bos_Restart_t type,
3047 bos_RestartTime_p timeP, afs_status_p st)
3050 afs_status_t tst = 0;
3051 bos_server_p b_handle = (bos_server_p) serverHandle;
3052 afs_int32 restartType = 0;
3053 struct bozo_netKTime restartTime;
3055 if (!isValidServerHandle(b_handle, &tst)) {
3056 goto fail_bos_ExecutableRestartTimeGet;
3059 if (timeP == NULL) {
3060 tst = ADMBOSTIMEPNULL;
3061 goto fail_bos_ExecutableRestartTimeGet;
3064 if (type == BOS_RESTART_WEEKLY) {
3070 tst = BOZO_GetRestartTime(b_handle->server, restartType, &restartTime);
3073 goto fail_bos_ExecutableRestartTimeGet;
3076 timeP->mask = restartTime.mask;
3077 timeP->hour = restartTime.hour;
3078 timeP->min = restartTime.min;
3079 timeP->sec = restartTime.sec;
3080 timeP->day = restartTime.day;
3083 fail_bos_ExecutableRestartTimeGet:
3092 * bos_LogGet - get a log file from the bos server machine.
3096 * IN serverHandle - a previously opened serverHandle.
3098 * IN log - the log file to retrieve.
3100 * IN/OUT logBufferSizeP - the length of the logData buffer on input,
3101 * and upon successful completion, the length of data stored in the buffer.
3103 * OUT logData - the retrieved data upon successful completion.
3107 * No locks are obtained or released by this function
3111 * Returns != 0 upon successful completion.
3116 bos_LogGet(const void *serverHandle, const char *log,
3117 unsigned long *logBufferSizeP, char *logData, afs_status_p st)
3120 afs_status_t tst = 0;
3121 bos_server_p b_handle = (bos_server_p) serverHandle;
3122 struct rx_call *tcall = NULL;
3126 unsigned long bytes_read = 0;
3129 * Validate parameters
3132 if (!isValidServerHandle(b_handle, &tst)) {
3133 goto fail_bos_LogGet;
3136 if ((log == NULL) || (*log == 0)) {
3137 tst = ADMBOSLOGNULL;
3138 goto fail_bos_LogGet;
3141 if (logBufferSizeP == NULL) {
3142 tst = ADMBOSLOGBUFFERSIZEPNULL;
3143 goto fail_bos_LogGet;
3146 if (logData == NULL) {
3147 tst = ADMBOSLOGDATANULL;
3148 goto fail_bos_LogGet;
3152 * Begin to retrieve the data
3155 tcall = rx_NewCall(b_handle->server);
3157 tst = StartBOZO_GetLog(tcall, (char *) log);
3160 goto fail_bos_LogGet;
3164 * Read the log file data
3168 error = rx_Read(tcall, &buffer, 1);
3170 tst = ADMBOSLOGFILEERROR;
3171 goto fail_bos_LogGet;
3175 * check for the end of the log
3179 *logBufferSizeP = bytes_read;
3184 * We've successfully read another byte, copy it to logData
3189 if (bytes_read <= *logBufferSizeP) {
3190 *logData++ = buffer;
3202 rx_EndCall(tcall, 0);
3212 * bos_AuthSet - set the authorization level required at the bos server.
3216 * IN serverHandle - a previously opened serverHandle.
3218 * IN auth - specifies the new auth level.
3222 * No locks are obtained or released by this function
3226 * Returns != 0 upon successful completion.
3231 bos_AuthSet(const void *serverHandle, bos_Auth_t auth, afs_status_p st)
3234 afs_status_t tst = 0;
3235 bos_server_p b_handle = (bos_server_p) serverHandle;
3236 afs_int32 level = 0;
3238 if (!isValidServerHandle(b_handle, &tst)) {
3239 goto fail_bos_AuthSet;
3242 if (auth == BOS_AUTH_REQUIRED) {
3248 tst = BOZO_SetNoAuthFlag(b_handle->server, level);
3263 * bos_CommandExecute - execute a command at the bos server.
3267 * IN serverHandle - a previously opened serverHandle.
3269 * IN command - the command to execute.
3273 * No locks are obtained or released by this function
3277 * Returns != 0 upon successful completion.
3282 bos_CommandExecute(const void *serverHandle, const char *command,
3286 afs_status_t tst = 0;
3287 bos_server_p b_handle = (bos_server_p) serverHandle;
3289 if (!isValidServerHandle(b_handle, &tst)) {
3290 goto fail_bos_CommandExecute;
3293 if ((command == NULL) || (*command == 0)) {
3294 tst = ADMBOSCOMMANDNULL;
3295 goto fail_bos_CommandExecute;
3298 tst = BOZO_Exec(b_handle->server, (char *) command);
3304 fail_bos_CommandExecute:
3313 * bos_Salvage - perform a remote salvage operation.
3317 * IN cellHandle - a previously opened cellHandle.
3319 * IN serverHandle - a previously opened serverHandle.
3321 * IN partitionName - the partition to salvage. Can be null.
3323 * IN volumeName - the volume to salvage. Can be null, if non-null,
3324 * partitionName cannot be null.
3326 * IN numSalvagers - the number of salvage processes to run in parallel.
3328 * IN tmpDir - directory to place temporary files. Can be null.
3330 * IN logFile - file where salvage log will be written. Can be null.
3332 * IN force - sets salvager -force flag.
3334 * IN salvageDamagedVolumes - sets salvager -oktozap flag.
3336 * IN writeInodes - sets salvager -inodes flag.
3338 * IN writeRootInodes - sets salvager -rootinodes flag.
3340 * IN forceDirectory - sets salvager -salvagedirs flag.
3342 * IN forceBlockRead - sets salvager -blockread flag.
3346 * No locks are obtained or released by this function
3350 * Returns != 0 upon successful completion.
3354 #define INITIAL_LOG_LEN 4096
3357 bos_Salvage(const void *cellHandle, const void *serverHandle,
3358 const char *partitionName, const char *volumeName,
3359 int numSalvagers, const char *tmpDir, const char *logFile,
3361 bos_SalvageDamagedVolumes_t salvageDamagedVolumes,
3362 bos_WriteInodes_t writeInodes,
3363 bos_WriteRootInodes_t writeRootInodes,
3364 bos_ForceDirectory_t forceDirectory,
3365 bos_ForceBlockRead_t forceBlockRead, afs_status_p st)
3368 afs_status_t tst = 0;
3369 bos_server_p b_handle = (bos_server_p) serverHandle;
3370 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3371 int have_partition = 0;
3372 int have_volume = 0;
3373 unsigned int part = 0;
3374 int try_to_stop_fileserver = 0;
3375 bos_ProcessType_t procType;
3376 bos_ProcessInfo_t procInfo;
3378 char command[BOS_MAX_NAME_LEN];
3379 int command_len = 0;
3381 char *logData = NULL;
3382 unsigned long logLen = INITIAL_LOG_LEN;
3385 * Validate arguments
3388 if (!IsValidCellHandle(c_handle, &tst)) {
3389 goto fail_bos_Salvage;
3392 if (!isValidServerHandle(b_handle, &tst)) {
3393 goto fail_bos_Salvage;
3396 if (c_handle->vos_valid == 0) {
3397 tst = ADMBOSCELLHANDLENOVOS;
3398 goto fail_bos_Salvage;
3401 if ((partitionName != NULL) && (*partitionName != 0)) {
3402 if (!vos_PartitionNameToId(partitionName, &part, &tst)) {
3403 goto fail_bos_Salvage;
3408 if ((volumeName != NULL) && (*volumeName != 0)) {
3409 if (!have_partition) {
3410 tst = ADMBOSSALVAGEVOLUME;
3411 goto fail_bos_Salvage;
3416 if ((logFile != NULL) && (*logFile != 0)) {
3417 log = fopen(logFile, "w");
3419 tst = ADMBOSSALVAGEBADLOG;
3420 goto fail_bos_Salvage;
3425 * If we are salvaging more than a single volume, stop the fileserver
3429 try_to_stop_fileserver = 1;
3433 * Only try to stop the fileserver if it is running
3436 if (try_to_stop_fileserver) {
3437 if (bos_ProcessInfoGet
3438 (serverHandle, "fs", &procType, &procInfo, &tst)) {
3439 if (procInfo.processGoal != BOS_PROCESS_RUNNING) {
3440 try_to_stop_fileserver = 0;
3446 * Make the call to stop the fileserver and wait for it to shutdown
3449 if (try_to_stop_fileserver) {
3450 if (!bos_ProcessExecutionStateSetTemporary
3451 (serverHandle, "fs", BOS_PROCESS_STOPPED, &tst)) {
3452 goto fail_bos_Salvage;
3454 bos_ProcessAllWaitTransition(serverHandle, &tst);
3458 * Create the salvage command line arguments
3462 sprintf(command, "%s ", AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH);
3463 if (have_partition) {
3465 sprintf(&command[command_len], "-partition %s ", partitionName);
3470 sprintf(&command[command_len], "-volumeid %s ", volumeName);
3473 if (salvageDamagedVolumes == BOS_DONT_SALVAGE_DAMAGED_VOLUMES) {
3474 command_len += sprintf(&command[command_len], "-nowrite ");
3477 if (writeInodes == BOS_SALVAGE_WRITE_INODES) {
3478 command_len += sprintf(&command[command_len], "-inodes ");
3481 if (force == VOS_FORCE) {
3482 command_len += sprintf(&command[command_len], "-force ");
3485 if (writeRootInodes == BOS_SALVAGE_WRITE_ROOT_INODES) {
3486 command_len += sprintf(&command[command_len], "-rootinodes ");
3489 if (forceDirectory == BOS_SALVAGE_FORCE_DIRECTORIES) {
3490 command_len += sprintf(&command[command_len], "-salvagedirs ");
3493 if (forceBlockRead == BOS_SALVAGE_FORCE_BLOCK_READS) {
3494 command_len += sprintf(&command[command_len], "-blockreads ");
3498 sprintf(&command[command_len], "-parallel %d ", numSalvagers);
3500 if ((tmpDir != NULL) && (*tmpDir != 0)) {
3501 command_len += sprintf(&command[command_len], "-tmpdir %s ", tmpDir);
3504 if (command_len > BOS_MAX_NAME_LEN) {
3505 tst = ADMBOSSALVAGEBADOPTIONS;
3506 goto fail_bos_Salvage;
3510 * Create the process at the bosserver and wait until it completes
3513 if (!bos_ProcessCreate
3514 (serverHandle, "salvage-tmp", BOS_PROCESS_CRON, command, "now", 0,
3516 goto fail_bos_Salvage;
3520 bos_ProcessInfoGet(serverHandle, "salvage-tmp", &procType,
3521 &procInfo, &tst))) {
3525 if (tst != BZNOENT) {
3526 goto fail_bos_Salvage;
3530 * Print out the salvage log if required by the user
3535 logData = (char *)malloc(INITIAL_LOG_LEN);
3538 goto fail_bos_Salvage;
3542 (serverHandle, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH,
3543 &logLen, logData, &tst)) {
3544 if (logLen > INITIAL_LOG_LEN) {
3545 logData = (char *)realloc(logData, (logLen + (logLen / 10)));
3546 if (logData == NULL) {
3548 goto fail_bos_Salvage;
3551 goto fail_bos_Salvage;
3554 fprintf(log, "SalvageLog:\n%s", logData);
3558 * Restart the fileserver if we had stopped it previously
3561 if (try_to_stop_fileserver) {
3562 try_to_stop_fileserver = 0;
3563 if (!bos_ProcessExecutionStateSetTemporary
3564 (serverHandle, "fs", BOS_PROCESS_RUNNING, &tst)) {
3565 goto fail_bos_Salvage;
3576 if (logData != NULL) {
3580 if (try_to_stop_fileserver) {
3581 bos_ProcessExecutionStateSetTemporary(serverHandle, "fs",
3582 BOS_PROCESS_RUNNING, 0);