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>
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, const char *processName,
326 bos_ProcessType_t processType, const char *process,
327 const char *cronTime, const 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, const char *processName,
406 const char *fileserverPath, const char *volserverPath,
407 const char *salvagerPath, const 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, const 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,
530 const char *processName,
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 *, const 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, 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 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,
694 const char *processName,
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, const 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, processName, 999, ¬ifier);
1300 fail_bos_ProcessNotifierGet:
1309 * bos_ProcessRestart - restart a particular process.
1313 * IN serverHandle - a previously opened serverHandle.
1315 * IN processName - the process to restart
1319 * No locks are obtained or released by this function
1323 * Returns != 0 upon successful completion.
1328 bos_ProcessRestart(const void *serverHandle, const char *processName,
1332 afs_status_t tst = 0;
1333 bos_server_p b_handle = (bos_server_p) serverHandle;
1335 if (!isValidServerHandle(b_handle, &tst)) {
1336 goto fail_bos_ProcessRestart;
1339 if ((processName == NULL) || (*processName == 0)) {
1340 tst = ADMBOSPROCESSNAMENULL;
1341 goto fail_bos_ProcessRestart;
1344 tst = BOZO_Restart(b_handle->server, processName);
1350 fail_bos_ProcessRestart:
1359 * bos_ProcessAllStop - stop all running processes at a server.
1363 * IN serverHandle - a previously opened serverHandle.
1367 * No locks are obtained or released by this function
1371 * Returns != 0 upon successful completion.
1376 bos_ProcessAllStop(const void *serverHandle, afs_status_p st)
1379 afs_status_t tst = 0;
1380 bos_server_p b_handle = (bos_server_p) serverHandle;
1382 if (!isValidServerHandle(b_handle, &tst)) {
1383 goto fail_bos_ProcessAllStop;
1386 tst = BOZO_ShutdownAll(b_handle->server);
1392 fail_bos_ProcessAllStop:
1401 * bos_ProcessAllStart - start all processes that should be running at a
1406 * IN serverHandle - a previously opened serverHandle.
1410 * No locks are obtained or released by this function
1414 * Returns != 0 upon successful completion.
1419 bos_ProcessAllStart(const void *serverHandle, afs_status_p st)
1422 afs_status_t tst = 0;
1423 bos_server_p b_handle = (bos_server_p) serverHandle;
1425 if (!isValidServerHandle(b_handle, &tst)) {
1426 goto fail_bos_ProcessAllStart;
1429 tst = BOZO_StartupAll(b_handle->server);
1435 fail_bos_ProcessAllStart:
1444 * bos_ProcessAllWaitStop - stop all processes, and block until they have
1449 * IN serverHandle - a previously opened serverHandle.
1453 * No locks are obtained or released by this function
1457 * Returns != 0 upon successful completion.
1462 bos_ProcessAllWaitStop(const void *serverHandle, afs_status_p st)
1465 afs_status_t tst = 0;
1466 bos_server_p b_handle = (bos_server_p) serverHandle;
1468 if (!isValidServerHandle(b_handle, &tst)) {
1469 goto fail_bos_ProcessAllWaitStop;
1472 if (!bos_ProcessAllStop(serverHandle, &tst)) {
1473 goto fail_bos_ProcessAllWaitStop;
1476 tst = BOZO_WaitAll(b_handle->server);
1482 fail_bos_ProcessAllWaitStop:
1491 * bos_ProcessAllWaitTransition - block until all processes at the bosserver
1492 * have reached their desired state.
1496 * IN serverHandle - a previously opened serverHandle.
1500 * No locks are obtained or released by this function
1504 * Returns != 0 upon successful completion.
1509 bos_ProcessAllWaitTransition(const void *serverHandle, afs_status_p st)
1512 afs_status_t tst = 0;
1513 bos_server_p b_handle = (bos_server_p) serverHandle;
1515 if (!isValidServerHandle(b_handle, &tst)) {
1516 goto fail_bos_ProcessAllWaitTransition;
1519 tst = BOZO_WaitAll(b_handle->server);
1525 fail_bos_ProcessAllWaitTransition:
1534 * bos_ProcessAllStopAndRestart - stop all the running processes, restart
1535 * them, and optionally restart the bosserver itself.
1540 * IN serverHandle - a previously opened serverHandle.
1542 * IN restartBosServer - flag to indicate whether to restart bosserver.
1546 * No locks are obtained or released by this function
1550 * Returns != 0 upon successful completion.
1555 bos_ProcessAllStopAndRestart(const void *serverHandle,
1556 bos_RestartBosServer_t restartBosServer,
1560 afs_status_t tst = 0;
1561 bos_server_p b_handle = (bos_server_p) serverHandle;
1563 if (!isValidServerHandle(b_handle, &tst)) {
1564 goto fail_bos_ProcessAllStopAndRestart;
1567 if (restartBosServer == BOS_RESTART_BOS_SERVER) {
1568 tst = BOZO_ReBozo(b_handle->server);
1570 goto fail_bos_ProcessAllStopAndRestart;
1574 tst = BOZO_RestartAll(b_handle->server);
1580 fail_bos_ProcessAllStopAndRestart:
1589 * bos_AdminCreate - create a new admin.
1593 * IN serverHandle - a previously opened serverHandle.
1595 * IN adminName - the new admin name.
1599 * No locks are obtained or released by this function
1603 * Returns != 0 upon successful completion.
1608 bos_AdminCreate(const void *serverHandle, const char *adminName,
1612 afs_status_t tst = 0;
1613 bos_server_p b_handle = (bos_server_p) serverHandle;
1615 if (!isValidServerHandle(b_handle, &tst)) {
1616 goto fail_bos_AdminCreate;
1619 if ((adminName == NULL) || (*adminName == 0)) {
1620 tst = ADMBOSADMINNAMENULL;
1621 goto fail_bos_AdminCreate;
1624 tst = BOZO_AddSUser(b_handle->server, adminName);
1630 fail_bos_AdminCreate:
1639 * bos_AdminDelete - delete a new admin.
1643 * IN serverHandle - a previously opened serverHandle.
1645 * IN adminName - the admin name.
1649 * No locks are obtained or released by this function
1653 * Returns != 0 upon successful completion.
1658 bos_AdminDelete(const void *serverHandle, const char *adminName,
1662 afs_status_t tst = 0;
1663 bos_server_p b_handle = (bos_server_p) serverHandle;
1665 if (!isValidServerHandle(b_handle, &tst)) {
1666 goto fail_bos_AdminDelete;
1669 if ((adminName == NULL) || (*adminName == 0)) {
1670 tst = ADMBOSADMINNAMENULL;
1671 goto fail_bos_AdminDelete;
1674 tst = BOZO_DeleteSUser(b_handle->server, adminName);
1680 fail_bos_AdminDelete:
1689 * The iterator functions and data for the admin retrieval functions
1692 typedef struct admin_get {
1694 struct rx_connection *server;
1695 char admin[CACHED_ITEMS][BOS_MAX_NAME_LEN];
1696 } admin_get_t, *admin_get_p;
1699 GetAdminRPC(void *rpc_specific, int slot, int *last_item,
1700 int *last_item_contains_data, afs_status_p st)
1703 afs_status_t tst = 0;
1704 admin_get_p admin = (admin_get_p) rpc_specific;
1705 char *ptr = (char *)&admin->admin[slot];
1707 tst = BOZO_ListSUsers(admin->server, admin->next++, &ptr);
1710 * There's no way to tell the difference between an rpc failure
1711 * and the end of the list, so we assume that any error means the
1718 *last_item_contains_data = 0;
1729 GetAdminFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
1732 afs_status_t tst = 0;
1733 admin_get_p admin = (admin_get_p) rpc_specific;
1735 strcpy((char *)dest, (char *)&admin->admin[slot]);
1745 * bos_AdminGetBegin - begin iterating over the administrators.
1749 * IN serverHandle - a previously opened serverHandle.
1751 * OUT iter - an iterator that can be passed to bos_AdminGetBegin
1752 * to retrieve the administrators.
1756 * No locks are obtained or released by this function
1760 * Returns != 0 upon successful completion.
1765 bos_AdminGetBegin(const void *serverHandle, void **iterationIdP,
1769 afs_status_t tst = 0;
1770 bos_server_p b_handle = (bos_server_p) serverHandle;
1771 afs_admin_iterator_p iter =
1772 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1773 admin_get_p admin = (admin_get_p) malloc(sizeof(admin_get_t));
1775 if (!isValidServerHandle(b_handle, &tst)) {
1776 goto fail_bos_AdminGetBegin;
1779 if (iterationIdP == NULL) {
1780 tst = ADMITERATIONIDPNULL;
1781 goto fail_bos_AdminGetBegin;
1784 if ((iter == NULL) || (admin == NULL)) {
1786 goto fail_bos_AdminGetBegin;
1790 admin->server = b_handle->server;
1793 (iter, (void *)admin, GetAdminRPC, GetAdminFromCache, NULL, NULL,
1795 *iterationIdP = (void *)iter;
1799 fail_bos_AdminGetBegin:
1805 if (admin != NULL) {
1817 * bos_AdminGetNext - retrieve the next administrator
1818 * from the bos server.
1822 * IN iterationId - an iterator previously returned by
1825 * OUT adminName - upon successful completion contains the next administrator
1826 * retrieved from the server.
1830 * No locks are obtained or released by this function
1834 * Returns != 0 upon successful completion.
1839 bos_AdminGetNext(const void *iterationId, char *adminName, afs_status_p st)
1842 afs_status_t tst = 0;
1843 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1845 if (iterationId == NULL) {
1846 tst = ADMITERATIONIDPNULL;
1847 goto fail_bos_AdminGetNext;
1850 if (adminName == NULL) {
1851 tst = ADMBOSADMINNAMENULL;
1852 goto fail_bos_AdminGetNext;
1855 rc = IteratorNext(iter, (void *)adminName, &tst);
1857 fail_bos_AdminGetNext:
1866 * bos_AdminGetDone - finish using a administrator iterator.
1870 * IN iterationId - an iterator previously returned by
1875 * No locks are obtained or released by this function
1879 * Returns != 0 upon successful completion.
1884 bos_AdminGetDone(const void *iterationId, afs_status_p st)
1887 afs_status_t tst = 0;
1888 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1890 if (iterationId == NULL) {
1891 tst = ADMITERATIONIDPNULL;
1892 goto fail_bos_AdminGetDone;
1895 rc = IteratorDone(iter, &tst);
1897 fail_bos_AdminGetDone:
1906 * bos_KeyCreate - add a new key to the keyfile.
1910 * IN serverHandle - a previously opened serverHandle.
1912 * IN keyVersionNumber - the key version number.
1914 * IN key - the new key.
1918 * No locks are obtained or released by this function
1922 * Returns != 0 upon successful completion.
1927 bos_KeyCreate(const void *serverHandle, int keyVersionNumber,
1928 const kas_encryptionKey_p key, afs_status_p st)
1931 afs_status_t tst = 0;
1932 bos_server_p b_handle = (bos_server_p) serverHandle;
1934 if (!isValidServerHandle(b_handle, &tst)) {
1935 goto fail_bos_KeyCreate;
1939 tst = ADMBOSKEYNULL;
1940 goto fail_bos_KeyCreate;
1943 tst = BOZO_AddKey(b_handle->server_encrypt, keyVersionNumber, key);
1958 * bos_KeyDelete - delete an existing key from the keyfile.
1962 * IN serverHandle - a previously opened serverHandle.
1964 * IN keyVersionNumber - the key version number.
1968 * No locks are obtained or released by this function
1972 * Returns != 0 upon successful completion.
1977 bos_KeyDelete(const void *serverHandle, int keyVersionNumber, afs_status_p st)
1980 afs_status_t tst = 0;
1981 bos_server_p b_handle = (bos_server_p) serverHandle;
1983 if (!isValidServerHandle(b_handle, &tst)) {
1984 goto fail_bos_KeyDelete;
1987 tst = BOZO_DeleteKey(b_handle->server, keyVersionNumber);
2002 * The iterator functions and data for the key retrieval functions
2005 typedef struct key_get {
2007 struct rx_connection *server;
2008 bos_KeyInfo_t key[CACHED_ITEMS];
2009 } key_get_t, *key_get_p;
2012 GetKeyRPC(void *rpc_specific, int slot, int *last_item,
2013 int *last_item_contains_data, afs_status_p st)
2016 afs_status_t tst = 0;
2017 key_get_p key = (key_get_p) rpc_specific;
2018 struct bozo_keyInfo keyInfo;
2021 BOZO_ListKeys(key->server, key->next++,
2022 &key->key[slot].keyVersionNumber, &key->key[slot].key,
2027 key->key[slot].keyStatus.lastModificationDate = keyInfo.mod_sec;
2028 key->key[slot].keyStatus.lastModificationMicroSeconds =
2030 key->key[slot].keyStatus.checkSum = keyInfo.keyCheckSum;
2032 } else if (tst == BZDOM) {
2036 *last_item_contains_data = 0;
2046 GetKeyFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
2049 afs_status_t tst = 0;
2050 key_get_p key = (key_get_p) rpc_specific;
2052 memcpy(dest, &key->key[slot], sizeof(bos_KeyInfo_t));
2062 * bos_KeyGetBegin - begin iterating over the keys.
2066 * IN serverHandle - a previously opened serverHandle.
2068 * OUT iter - an iterator that can be passed to bos_KeyGetNext
2069 * to retrieve the keys.
2073 * No locks are obtained or released by this function
2077 * Returns != 0 upon successful completion.
2082 bos_KeyGetBegin(const void *serverHandle, void **iterationIdP,
2086 afs_status_t tst = 0;
2087 bos_server_p b_handle = (bos_server_p) serverHandle;
2088 afs_admin_iterator_p iter =
2089 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
2090 key_get_p key = (key_get_p) malloc(sizeof(key_get_t));
2092 if (!isValidServerHandle(b_handle, &tst)) {
2093 goto fail_bos_KeyGetBegin;
2096 if (iterationIdP == NULL) {
2097 tst = ADMITERATIONIDPNULL;
2098 goto fail_bos_KeyGetBegin;
2101 if ((iter == NULL) || (key == NULL)) {
2103 goto fail_bos_KeyGetBegin;
2107 key->server = b_handle->server_encrypt;
2110 (iter, (void *)key, GetKeyRPC, GetKeyFromCache, NULL, NULL, &tst)) {
2111 *iterationIdP = (void *)iter;
2115 fail_bos_KeyGetBegin:
2133 * bos_KeyGetNext - retrieve the next key
2134 * from the bos server.
2138 * IN iterationId - an iterator previously returned by
2141 * OUT keyP - upon successful completion contains the next key
2142 * retrieved from the server.
2146 * No locks are obtained or released by this function
2150 * Returns != 0 upon successful completion.
2155 bos_KeyGetNext(const void *iterationId, bos_KeyInfo_p keyP, afs_status_p st)
2158 afs_status_t tst = 0;
2159 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2161 if (iterationId == NULL) {
2162 tst = ADMITERATIONIDPNULL;
2163 goto fail_bos_KeyGetNext;
2167 tst = ADMBOSKEYPNULL;
2168 goto fail_bos_KeyGetNext;
2171 rc = IteratorNext(iter, (void *)keyP, &tst);
2173 fail_bos_KeyGetNext:
2182 * bos_KeyGetDone - finish using a key iterator.
2186 * IN iterationId - an iterator previously returned by
2191 * No locks are obtained or released by this function
2195 * Returns != 0 upon successful completion.
2200 bos_KeyGetDone(const void *iterationId, afs_status_p st)
2203 afs_status_t tst = 0;
2204 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2206 if (iterationId == NULL) {
2207 tst = ADMITERATIONIDPNULL;
2208 goto fail_bos_KeyGetDone;
2211 rc = IteratorDone(iter, &tst);
2213 fail_bos_KeyGetDone:
2222 * bos_CellSet - set the cell name at a bos server.
2226 * IN serverHandle - a previously opened serverHandle.
2228 * IN cellName - the new cell name.
2232 * No locks are obtained or released by this function
2236 * Returns != 0 upon successful completion.
2240 bos_CellSet(const void *serverHandle, const char *cellName, afs_status_p st)
2243 afs_status_t tst = 0;
2244 bos_server_p b_handle = (bos_server_p) serverHandle;
2246 if (!isValidServerHandle(b_handle, &tst)) {
2247 goto fail_bos_CellSet;
2250 if ((cellName == NULL) || (*cellName == 0)) {
2251 tst = ADMCLIENTCELLNAMENULL;
2252 goto fail_bos_CellSet;
2255 tst = BOZO_SetCellName(b_handle->server, cellName);
2270 * bos_CellGet - get the cell name at a bos server.
2274 * IN serverHandle - a previously opened serverHandle.
2276 * OUT cellName - the cell name.
2280 * No locks are obtained or released by this function
2284 * Returns != 0 upon successful completion.
2288 bos_CellGet(const void *serverHandle, char *cellName, afs_status_p st)
2291 afs_status_t tst = 0;
2292 bos_server_p b_handle = (bos_server_p) serverHandle;
2294 if (!isValidServerHandle(b_handle, &tst)) {
2295 goto fail_bos_CellGet;
2298 if (cellName == NULL) {
2299 tst = ADMCLIENTCELLNAMENULL;
2300 goto fail_bos_CellGet;
2303 tst = BOZO_GetCellName(b_handle->server, &cellName);
2318 * bos_HostCreate - add a new host to the cell.
2322 * IN serverHandle - a previously opened serverHandle.
2324 * IN hostName - the new host.
2328 * No locks are obtained or released by this function
2332 * Returns != 0 upon successful completion.
2336 bos_HostCreate(const void *serverHandle, const char *hostName,
2340 afs_status_t tst = 0;
2341 bos_server_p b_handle = (bos_server_p) serverHandle;
2343 if (!isValidServerHandle(b_handle, &tst)) {
2344 goto fail_bos_HostCreate;
2347 if ((hostName == NULL) || (*hostName == 0)) {
2348 tst = ADMBOSHOSTNAMENULL;
2349 goto fail_bos_HostCreate;
2352 tst = BOZO_AddCellHost(b_handle->server, hostName);
2358 fail_bos_HostCreate:
2367 * bos_HostDelete - delete a host from the cell.
2371 * IN serverHandle - a previously opened serverHandle.
2373 * IN hostName - the host.
2377 * No locks are obtained or released by this function
2381 * Returns != 0 upon successful completion.
2385 bos_HostDelete(const void *serverHandle, const char *hostName,
2389 afs_status_t tst = 0;
2390 bos_server_p b_handle = (bos_server_p) serverHandle;
2392 if (!isValidServerHandle(b_handle, &tst)) {
2393 goto fail_bos_HostDelete;
2396 if ((hostName == NULL) || (*hostName == 0)) {
2397 tst = ADMBOSHOSTNAMENULL;
2398 goto fail_bos_HostDelete;
2401 tst = BOZO_DeleteCellHost(b_handle->server, hostName);
2407 fail_bos_HostDelete:
2416 * The iterator functions and data for the host retrieval functions
2419 typedef struct host_get {
2421 struct rx_connection *server;
2422 char host[CACHED_ITEMS][BOS_MAX_NAME_LEN];
2423 } host_get_t, *host_get_p;
2426 GetHostRPC(void *rpc_specific, int slot, int *last_item,
2427 int *last_item_contains_data, afs_status_p st)
2430 afs_status_t tst = 0;
2431 host_get_p host = (host_get_p) rpc_specific;
2432 char *ptr = (char *)&host->host[slot];
2434 tst = BOZO_GetCellHost(host->server, host->next++, &ptr);
2438 } else if (tst == BZDOM) {
2442 *last_item_contains_data = 0;
2452 GetHostFromCache(void *rpc_specific, int slot, void *dest, afs_status_p st)
2455 afs_status_t tst = 0;
2456 host_get_p host = (host_get_p) rpc_specific;
2458 strcpy((char *)dest, (char *)&host->host[slot]);
2468 * bos_HostGetBegin - begin iterating over the hosts in a cell
2469 * at a particular bos server.
2473 * IN serverHandle - a previously opened serverHandle.
2475 * OUT iter - an iterator that can be passed to bos_HostGetNext
2476 * to retrieve the process names.
2480 * No locks are obtained or released by this function
2484 * Returns != 0 upon successful completion.
2489 bos_HostGetBegin(const void *serverHandle, void **iterationIdP,
2493 afs_status_t tst = 0;
2494 bos_server_p b_handle = (bos_server_p) serverHandle;
2495 afs_admin_iterator_p iter =
2496 (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
2497 host_get_p host = (host_get_p) malloc(sizeof(host_get_t));
2499 if (!isValidServerHandle(b_handle, &tst)) {
2500 goto fail_bos_HostGetBegin;
2503 if (iterationIdP == NULL) {
2504 tst = ADMITERATIONIDPNULL;
2505 goto fail_bos_HostGetBegin;
2508 if ((iter == NULL) || (host == NULL)) {
2510 goto fail_bos_HostGetBegin;
2514 host->server = b_handle->server;
2517 (iter, (void *)host, GetHostRPC, GetHostFromCache, NULL, NULL,
2519 *iterationIdP = (void *)iter;
2523 fail_bos_HostGetBegin:
2541 * bos_HostGetNext - retrieve the next host
2542 * from the bos server.
2546 * IN iterationId - an iterator previously returned by
2549 * OUT hostName - upon successful completion contains the next host
2550 * retrieved from the server.
2554 * No locks are obtained or released by this function
2558 * Returns != 0 upon successful completion.
2563 bos_HostGetNext(const void *iterationId, char *hostName, afs_status_p st)
2566 afs_status_t tst = 0;
2567 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2569 if (iterationId == NULL) {
2570 tst = ADMITERATIONIDPNULL;
2571 goto fail_bos_HostGetNext;
2574 if (hostName == NULL) {
2575 tst = ADMBOSHOSTNAMENULL;
2576 goto fail_bos_HostGetNext;
2579 rc = IteratorNext(iter, (void *)hostName, &tst);
2581 fail_bos_HostGetNext:
2590 * bos_HostGetDone - finish using a host iterator.
2594 * IN iterationId - an iterator previously returned by
2599 * No locks are obtained or released by this function
2603 * Returns != 0 upon successful completion.
2608 bos_HostGetDone(const void *iterationId, afs_status_p st)
2611 afs_status_t tst = 0;
2612 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2614 if (iterationId == NULL) {
2615 tst = ADMITERATIONIDPNULL;
2616 goto fail_bos_HostGetDone;
2619 rc = IteratorDone(iter, &tst);
2621 fail_bos_HostGetDone:
2630 * bos_ExecutableCreate - create a new executable at the bos server.
2634 * IN serverHandle - a previously opened serverHandle.
2636 * IN sourceFile - the executable to install at the bos server.
2638 * IN destFile - the location where the executable will be installed.
2642 * No locks are obtained or released by this function
2646 * Returns != 0 upon successful completion.
2651 bos_ExecutableCreate(const void *serverHandle, const char *sourceFile,
2652 const char *destFile, afs_status_p st)
2655 afs_status_t tst = 0;
2656 bos_server_p b_handle = (bos_server_p) serverHandle;
2659 struct rx_call *tcall;
2662 * Validate arguments
2665 if (!isValidServerHandle(b_handle, &tst)) {
2666 goto fail_bos_ExecutableCreate;
2669 if ((sourceFile == NULL) || (*sourceFile == 0)) {
2670 tst = ADMBOSSOURCEFILENULL;
2671 goto fail_bos_ExecutableCreate;
2674 if ((destFile == NULL) || (*destFile == 0)) {
2675 tst = ADMBOSDESTFILENULL;
2676 goto fail_bos_ExecutableCreate;
2680 * Open the file locally and compute its size
2683 fd = open(sourceFile, O_RDONLY);
2686 tst = ADMBOSCANTOPENSOURCEFILE;
2687 goto fail_bos_ExecutableCreate;
2690 if (fstat(fd, &estat)) {
2691 tst = ADMBOSCANTSTATSOURCEFILE;
2692 goto fail_bos_ExecutableCreate;
2696 * Start a split rpc to the bos server.
2699 tcall = rx_NewCall(b_handle->server);
2702 StartBOZO_Install(tcall, destFile, estat.st_size,
2703 (afs_int32) estat.st_mode, estat.st_mtime);
2706 rx_EndCall(tcall, tst);
2707 goto fail_bos_ExecutableCreate;
2711 * Copy the data to the server
2717 len = read(fd, tbuffer, sizeof(tbuffer));
2719 tst = ADMBOSCANTREADSOURCEFILE;
2720 rx_EndCall(tcall, len);
2721 goto fail_bos_ExecutableCreate;
2727 tst = rx_Write(tcall, tbuffer, len);
2729 tst = ADMBOSSENDSOURCEFILE;
2730 rx_EndCall(tcall, tst);
2731 goto fail_bos_ExecutableCreate;
2736 * Terminate the rpc to the server
2739 tst = rx_EndCall(tcall, tst);
2745 fail_bos_ExecutableCreate:
2754 * bos_ExecutableRevert - revert an executable to a previous .BAK version.
2758 * IN serverHandle - a previously opened serverHandle.
2760 * IN execFile - the executable to revert at the bos server.
2764 * No locks are obtained or released by this function
2768 * Returns != 0 upon successful completion.
2773 bos_ExecutableRevert(const void *serverHandle, const char *execFile,
2777 afs_status_t tst = 0;
2778 bos_server_p b_handle = (bos_server_p) serverHandle;
2780 if (!isValidServerHandle(b_handle, &tst)) {
2781 goto fail_bos_ExecutableRevert;
2784 if ((execFile == NULL) || (*execFile == 0)) {
2785 tst = ADMBOSEXECFILENULL;
2786 goto fail_bos_ExecutableRevert;
2789 tst = BOZO_UnInstall(b_handle->server, execFile);
2795 fail_bos_ExecutableRevert:
2804 * bos_ExecutableTimestampGet - get the last mod times for an executable,
2805 * the .BAK version of the executable, and the .OLD version of the
2806 * executable if they exist.
2810 * IN serverHandle - a previously opened serverHandle.
2812 * IN execFile - the executable to revert at the bos server.
2816 * No locks are obtained or released by this function
2820 * Returns != 0 upon successful completion.
2825 bos_ExecutableTimestampGet(const void *serverHandle, const char *execFile,
2826 unsigned long *newTime, unsigned long *oldTime,
2827 unsigned long *bakTime, afs_status_p st)
2830 afs_status_t tst = 0;
2831 bos_server_p b_handle = (bos_server_p) serverHandle;
2833 if (!isValidServerHandle(b_handle, &tst)) {
2834 goto fail_bos_ExecutableTimestampGet;
2837 if ((execFile == NULL) || (*execFile == 0)) {
2838 tst = ADMBOSEXECFILENULL;
2839 goto fail_bos_ExecutableTimestampGet;
2842 if (newTime == NULL) {
2843 tst = ADMBOSNEWTIMENULL;
2844 goto fail_bos_ExecutableTimestampGet;
2847 if (oldTime == NULL) {
2848 tst = ADMBOSOLDTIMENULL;
2849 goto fail_bos_ExecutableTimestampGet;
2852 if (bakTime == NULL) {
2853 tst = ADMBOSBAKTIMENULL;
2854 goto fail_bos_ExecutableTimestampGet;
2858 BOZO_GetDates(b_handle->server, execFile, newTime, bakTime, oldTime);
2864 fail_bos_ExecutableTimestampGet:
2873 * bos_ExecutablePrune - prune the bak, old, and core files off a server
2878 * IN serverHandle - a previously opened serverHandle.
2880 * IN oldFiles - prune .OLD files.
2882 * IN bakFiles - prune .BAK files.
2884 * IN coreFiles - prune core files.
2888 * No locks are obtained or released by this function
2892 * Returns != 0 upon successful completion.
2897 bos_ExecutablePrune(const void *serverHandle, bos_Prune_t oldFiles,
2898 bos_Prune_t bakFiles, bos_Prune_t coreFiles,
2902 afs_status_t tst = 0;
2903 bos_server_p b_handle = (bos_server_p) serverHandle;
2904 afs_int32 flags = 0;
2906 if (!isValidServerHandle(b_handle, &tst)) {
2907 goto fail_bos_ExecutablePrune;
2910 if (oldFiles == BOS_PRUNE) {
2911 flags |= BOZO_PRUNEOLD;
2914 if (bakFiles == BOS_PRUNE) {
2915 flags |= BOZO_PRUNEBAK;
2918 if (coreFiles == BOS_PRUNE) {
2919 flags |= BOZO_PRUNECORE;
2922 tst = BOZO_Prune(b_handle->server, flags);
2928 fail_bos_ExecutablePrune:
2937 * bos_ExecutableRestartTimeSet - set the restart time of the bos server
2942 * IN serverHandle - a previously opened serverHandle.
2944 * IN type - specifies either weekly restart or daily restart time.
2946 * IN time - the time to begin restarts.
2950 * No locks are obtained or released by this function
2954 * Returns != 0 upon successful completion.
2959 bos_ExecutableRestartTimeSet(const void *serverHandle, bos_Restart_t type,
2960 bos_RestartTime_t time, afs_status_p st)
2963 afs_status_t tst = 0;
2964 bos_server_p b_handle = (bos_server_p) serverHandle;
2965 afs_int32 restartType = 0;
2966 struct ktime restartTime;
2968 if (!isValidServerHandle(b_handle, &tst)) {
2969 goto fail_bos_ExecutableRestartTimeSet;
2972 if (type == BOS_RESTART_WEEKLY) {
2978 if ((time.mask & BOS_RESTART_TIME_HOUR)
2979 && ((time.hour < 0) || (time.hour > 23))) {
2980 tst = ADMBOSHOURINVALID;
2981 goto fail_bos_ExecutableRestartTimeSet;
2984 if ((time.mask & BOS_RESTART_TIME_MINUTE)
2985 && ((time.min < 0) || (time.min > 60))) {
2986 tst = ADMBOSMINUTEINVALID;
2987 goto fail_bos_ExecutableRestartTimeSet;
2990 if ((time.mask & BOS_RESTART_TIME_SECOND)
2991 && ((time.sec < 0) || (time.sec > 60))) {
2992 tst = ADMBOSSECONDINVALID;
2993 goto fail_bos_ExecutableRestartTimeSet;
2996 if ((time.mask & BOS_RESTART_TIME_DAY)
2997 && ((time.day < 0) || (time.day > 6))) {
2998 tst = ADMBOSDAYINVALID;
2999 goto fail_bos_ExecutableRestartTimeSet;
3002 restartTime.mask = time.mask;
3003 restartTime.hour = time.hour;
3004 restartTime.min = time.min;
3005 restartTime.sec = time.sec;
3006 restartTime.day = time.day;
3008 tst = BOZO_SetRestartTime(b_handle->server, restartType, &restartTime);
3014 fail_bos_ExecutableRestartTimeSet:
3023 * bos_ExecutableRestartTimeGet - get the restart time of the bos server
3028 * IN serverHandle - a previously opened serverHandle.
3030 * IN type - specifies either weekly restart or daily restart time.
3032 * OUT timeP - the time to begin restarts.
3036 * No locks are obtained or released by this function
3040 * Returns != 0 upon successful completion.
3045 bos_ExecutableRestartTimeGet(const void *serverHandle, bos_Restart_t type,
3046 bos_RestartTime_p timeP, afs_status_p st)
3049 afs_status_t tst = 0;
3050 bos_server_p b_handle = (bos_server_p) serverHandle;
3051 afs_int32 restartType = 0;
3052 struct ktime restartTime;
3054 if (!isValidServerHandle(b_handle, &tst)) {
3055 goto fail_bos_ExecutableRestartTimeGet;
3058 if (timeP == NULL) {
3059 tst = ADMBOSTIMEPNULL;
3060 goto fail_bos_ExecutableRestartTimeGet;
3063 if (type == BOS_RESTART_WEEKLY) {
3069 tst = BOZO_GetRestartTime(b_handle->server, restartType, &restartTime);
3072 goto fail_bos_ExecutableRestartTimeGet;
3075 timeP->mask = restartTime.mask;
3076 timeP->hour = restartTime.hour;
3077 timeP->min = restartTime.min;
3078 timeP->sec = restartTime.sec;
3079 timeP->day = restartTime.day;
3082 fail_bos_ExecutableRestartTimeGet:
3091 * bos_LogGet - get a log file from the bos server machine.
3095 * IN serverHandle - a previously opened serverHandle.
3097 * IN log - the log file to retrieve.
3099 * IN/OUT logBufferSizeP - the length of the logData buffer on input,
3100 * and upon successful completion, the length of data stored in the buffer.
3102 * OUT logData - the retrieved data upon successful completion.
3106 * No locks are obtained or released by this function
3110 * Returns != 0 upon successful completion.
3115 bos_LogGet(const void *serverHandle, const char *log,
3116 unsigned long *logBufferSizeP, char *logData, afs_status_p st)
3119 afs_status_t tst = 0;
3120 bos_server_p b_handle = (bos_server_p) serverHandle;
3121 struct rx_call *tcall = NULL;
3125 unsigned long bytes_read = 0;
3128 * Validate parameters
3131 if (!isValidServerHandle(b_handle, &tst)) {
3132 goto fail_bos_LogGet;
3135 if ((log == NULL) || (*log == 0)) {
3136 tst = ADMBOSLOGNULL;
3137 goto fail_bos_LogGet;
3140 if (logBufferSizeP == NULL) {
3141 tst = ADMBOSLOGBUFFERSIZEPNULL;
3142 goto fail_bos_LogGet;
3145 if (logData == NULL) {
3146 tst = ADMBOSLOGDATANULL;
3147 goto fail_bos_LogGet;
3151 * Begin to retrieve the data
3154 tcall = rx_NewCall(b_handle->server);
3156 tst = StartBOZO_GetLog(tcall, log);
3159 goto fail_bos_LogGet;
3163 * Read the log file data
3167 error = rx_Read(tcall, &buffer, 1);
3169 tst = ADMBOSLOGFILEERROR;
3170 goto fail_bos_LogGet;
3174 * check for the end of the log
3178 *logBufferSizeP = bytes_read;
3183 * We've successfully read another byte, copy it to logData
3188 if (bytes_read <= *logBufferSizeP) {
3189 *logData++ = buffer;
3201 rx_EndCall(tcall, 0);
3211 * bos_AuthSet - set the authorization level required at the bos server.
3215 * IN serverHandle - a previously opened serverHandle.
3217 * IN auth - specifies the new auth level.
3221 * No locks are obtained or released by this function
3225 * Returns != 0 upon successful completion.
3230 bos_AuthSet(const void *serverHandle, bos_Auth_t auth, afs_status_p st)
3233 afs_status_t tst = 0;
3234 bos_server_p b_handle = (bos_server_p) serverHandle;
3235 afs_int32 level = 0;
3237 if (!isValidServerHandle(b_handle, &tst)) {
3238 goto fail_bos_AuthSet;
3241 if (auth == BOS_AUTH_REQUIRED) {
3247 tst = BOZO_SetNoAuthFlag(b_handle->server, level);
3262 * bos_CommandExecute - execute a command at the bos server.
3266 * IN serverHandle - a previously opened serverHandle.
3268 * IN command - the command to execute.
3272 * No locks are obtained or released by this function
3276 * Returns != 0 upon successful completion.
3281 bos_CommandExecute(const void *serverHandle, const char *command,
3285 afs_status_t tst = 0;
3286 bos_server_p b_handle = (bos_server_p) serverHandle;
3288 if (!isValidServerHandle(b_handle, &tst)) {
3289 goto fail_bos_CommandExecute;
3292 if ((command == NULL) || (*command == 0)) {
3293 tst = ADMBOSCOMMANDNULL;
3294 goto fail_bos_CommandExecute;
3297 tst = BOZO_Exec(b_handle->server, command);
3303 fail_bos_CommandExecute:
3312 * bos_Salvage - perform a remote salvage operation.
3316 * IN cellHandle - a previously opened cellHandle.
3318 * IN serverHandle - a previously opened serverHandle.
3320 * IN partitionName - the partition to salvage. Can be null.
3322 * IN volumeName - the volume to salvage. Can be null, if non-null,
3323 * partitionName cannot be null.
3325 * IN numSalvagers - the number of salvage processes to run in parallel.
3327 * IN tmpDir - directory to place temporary files. Can be null.
3329 * IN logFile - file where salvage log will be written. Can be null.
3331 * IN force - sets salvager -force flag.
3333 * IN salvageDamagedVolumes - sets salvager -oktozap flag.
3335 * IN writeInodes - sets salvager -inodes flag.
3337 * IN writeRootInodes - sets salvager -rootinodes flag.
3339 * IN forceDirectory - sets salvager -salvagedirs flag.
3341 * IN forceBlockRead - sets salvager -blockread flag.
3345 * No locks are obtained or released by this function
3349 * Returns != 0 upon successful completion.
3353 #define INITIAL_LOG_LEN 4096
3356 bos_Salvage(const void *cellHandle, const void *serverHandle,
3357 const char *partitionName, const char *volumeName,
3358 int numSalvagers, const char *tmpDir, const char *logFile,
3360 bos_SalvageDamagedVolumes_t salvageDamagedVolumes,
3361 bos_WriteInodes_t writeInodes,
3362 bos_WriteRootInodes_t writeRootInodes,
3363 bos_ForceDirectory_t forceDirectory,
3364 bos_ForceBlockRead_t forceBlockRead, afs_status_p st)
3367 afs_status_t tst = 0;
3368 bos_server_p b_handle = (bos_server_p) serverHandle;
3369 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3370 int have_partition = 0;
3371 int have_volume = 0;
3372 unsigned int part = 0;
3373 int try_to_stop_fileserver = 0;
3374 bos_ProcessType_t procType;
3375 bos_ProcessInfo_t procInfo;
3377 char command[BOS_MAX_NAME_LEN];
3378 int command_len = 0;
3380 char *logData = NULL;
3381 unsigned long logLen = INITIAL_LOG_LEN;
3384 * Validate arguments
3387 if (!IsValidCellHandle(c_handle, &tst)) {
3388 goto fail_bos_Salvage;
3391 if (!isValidServerHandle(b_handle, &tst)) {
3392 goto fail_bos_Salvage;
3395 if (c_handle->vos_valid == 0) {
3396 tst = ADMBOSCELLHANDLENOVOS;
3397 goto fail_bos_Salvage;
3400 if ((partitionName != NULL) && (*partitionName != 0)) {
3401 if (!vos_PartitionNameToId(partitionName, &part, &tst)) {
3402 goto fail_bos_Salvage;
3407 if ((volumeName != NULL) && (*volumeName != 0)) {
3408 if (!have_partition) {
3409 tst = ADMBOSSALVAGEVOLUME;
3410 goto fail_bos_Salvage;
3415 if ((logFile != NULL) && (*logFile != 0)) {
3416 log = fopen(logFile, "w");
3418 tst = ADMBOSSALVAGEBADLOG;
3419 goto fail_bos_Salvage;
3424 * If we are salvaging more than a single volume, stop the fileserver
3428 try_to_stop_fileserver = 1;
3432 * Only try to stop the fileserver if it is running
3435 if (try_to_stop_fileserver) {
3436 if (bos_ProcessInfoGet
3437 (serverHandle, "fs", &procType, &procInfo, &tst)) {
3438 if (procInfo.processGoal != BOS_PROCESS_RUNNING) {
3439 try_to_stop_fileserver = 0;
3445 * Make the call to stop the fileserver and wait for it to shutdown
3448 if (try_to_stop_fileserver) {
3449 if (!bos_ProcessExecutionStateSetTemporary
3450 (serverHandle, "fs", BOS_PROCESS_STOPPED, &tst)) {
3451 goto fail_bos_Salvage;
3453 bos_ProcessAllWaitTransition(serverHandle, &tst);
3457 * Create the salvage command line arguments
3461 sprintf(command, "%s ", AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH);
3462 if (have_partition) {
3464 sprintf(&command[command_len], "-partition %s ", partitionName);
3469 sprintf(&command[command_len], "-volumeid %s ", volumeName);
3472 if (salvageDamagedVolumes == BOS_DONT_SALVAGE_DAMAGED_VOLUMES) {
3473 command_len += sprintf(&command[command_len], "-nowrite ");
3476 if (writeInodes == BOS_SALVAGE_WRITE_INODES) {
3477 command_len += sprintf(&command[command_len], "-inodes ");
3480 if (force == VOS_FORCE) {
3481 command_len += sprintf(&command[command_len], "-force ");
3484 if (writeRootInodes == BOS_SALVAGE_WRITE_ROOT_INODES) {
3485 command_len += sprintf(&command[command_len], "-rootinodes ");
3488 if (forceDirectory == BOS_SALVAGE_FORCE_DIRECTORIES) {
3489 command_len += sprintf(&command[command_len], "-salvagedirs ");
3492 if (forceBlockRead == BOS_SALVAGE_FORCE_BLOCK_READS) {
3493 command_len += sprintf(&command[command_len], "-blockreads ");
3497 sprintf(&command[command_len], "-parallel %d ", numSalvagers);
3499 if ((tmpDir != NULL) && (*tmpDir != 0)) {
3500 command_len += sprintf(&command[command_len], "-tmpdir %s ", tmpDir);
3503 if (command_len > BOS_MAX_NAME_LEN) {
3504 tst = ADMBOSSALVAGEBADOPTIONS;
3505 goto fail_bos_Salvage;
3509 * Create the process at the bosserver and wait until it completes
3512 if (!bos_ProcessCreate
3513 (serverHandle, "salvage-tmp", BOS_PROCESS_CRON, command, "now", 0,
3515 goto fail_bos_Salvage;
3519 bos_ProcessInfoGet(serverHandle, "salvage-tmp", &procType,
3520 &procInfo, &tst))) {
3524 if (tst != BZNOENT) {
3525 goto fail_bos_Salvage;
3529 * Print out the salvage log if required by the user
3534 logData = (char *)malloc(INITIAL_LOG_LEN);
3537 goto fail_bos_Salvage;
3541 (serverHandle, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH,
3542 &logLen, logData, &tst)) {
3543 if (logLen > INITIAL_LOG_LEN) {
3544 logData = (char *)realloc(logData, (logLen + (logLen / 10)));
3545 if (logData == NULL) {
3547 goto fail_bos_Salvage;
3550 goto fail_bos_Salvage;
3553 fprintf(log, "SalvageLog:\n%s", logData);
3557 * Restart the fileserver if we had stopped it previously
3560 if (try_to_stop_fileserver) {
3561 try_to_stop_fileserver = 0;
3562 if (!bos_ProcessExecutionStateSetTemporary
3563 (serverHandle, "fs", BOS_PROCESS_RUNNING, &tst)) {
3564 goto fail_bos_Salvage;
3575 if (logData != NULL) {
3579 if (try_to_stop_fileserver) {
3580 bos_ProcessExecutionStateSetTemporary(serverHandle, "fs",
3581 BOS_PROCESS_RUNNING, 0);