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 "afs_bosAdmin.h"
18 #include "../adminutil/afs_AdminInternal.h"
19 #include <afs/afs_AdminErrors.h>
20 #include <afs/afs_utilAdmin.h>
21 #include <afs/bosint.h>
22 #include <afs/bnode.h>
23 #include <afs/ktime.h>
24 #include <afs/dirpath.h>
26 #include <sys/types.h>
46 * Prototypes for functions that don't exist in any header files
49 extern int BOZO_AddCellHost();
50 extern int BOZO_AddKey();
51 extern int BOZO_AddSUser();
52 extern int BOZO_CreateBnode();
53 extern int BOZO_DeleteBnode();
54 extern int BOZO_DeleteCellHost();
55 extern int BOZO_DeleteKey();
56 extern int BOZO_DeleteSUser();
57 extern int BOZO_EnumerateInstance();
58 extern int BOZO_Exec();
59 extern int BOZO_GetCellHost();
60 extern int BOZO_GetCellName();
61 extern int BOZO_GetDates();
62 extern int BOZO_GetInstanceInfo();
63 extern int BOZO_GetInstanceParm();
64 extern int BOZO_GetInstanceParm();
65 extern int BOZO_GetRestartTime();
66 extern int BOZO_GetStatus();
67 extern int BOZO_ListSUsers();
68 extern int BOZO_ListKeys();
69 extern int BOZO_Prune();
70 extern int BOZO_ReBozo();
71 extern int BOZO_Restart();
72 extern int BOZO_RestartAll();
73 extern int BOZO_SetCellName();
74 extern int BOZO_SetNoAuthFlag();
75 extern int BOZO_SetRestartTime();
76 extern int BOZO_SetStatus(struct rx_connection *, char *, afs_int32);
77 extern int BOZO_SetTStatus(struct rx_connection *, char *, afs_int32);
78 extern int BOZO_ShutdownAll();
79 extern int BOZO_StartupAll();
80 extern int BOZO_UnInstall();
81 extern int BOZO_WaitAll();
82 extern int StartBOZO_GetLog();
83 extern int StartBOZO_Install();
85 typedef struct bos_server {
88 struct rx_connection *server;
89 struct rx_connection *server_encrypt;
90 struct rx_connection *server_stats;
92 } bos_server_t, *bos_server_p;
95 * isValidServerHandle - validate a bos_server_p.
99 * IN serverHandle - the handle to validate
103 * No locks are obtained or released by this function
107 * Returns != 0 upon successful completion.
110 int isValidServerHandle (
111 const bos_server_p serverHandle,
115 afs_status_t tst = 0;
117 if (serverHandle == NULL) {
118 tst = ADMBOSSERVERHANDLENULL;
119 goto fail_IsValidServerHandle;
122 if ((serverHandle->begin_magic != BEGIN_MAGIC) ||
123 (serverHandle->end_magic != END_MAGIC)) {
124 tst = ADMBOSSERVERHANDLEBADMAGIC;
125 goto fail_IsValidServerHandle;
128 if (serverHandle->is_valid == 0) {
129 tst = ADMBOSSERVERHANDLEINVALID;
130 goto fail_IsValidServerHandle;
133 if (serverHandle->server == NULL) {
134 tst = ADMBOSSERVERHANDLENOSERVER;
135 goto fail_IsValidServerHandle;
138 if (serverHandle->server_encrypt == NULL) {
139 tst = ADMBOSSERVERHANDLENOSERVER;
140 goto fail_IsValidServerHandle;
144 fail_IsValidServerHandle:
152 * IsValidCellHandle - verify that a cell handle can be used to make bos
157 * IN cellHandle - the cellHandle to be validated.
161 * No locks are obtained or released by this function
165 * Returns != 0 upon successful completion.
168 static int IsValidCellHandle(
169 afs_cell_handle_p cellHandle,
173 afs_status_t tst = 0;
175 if (!CellHandleIsValid((void *) cellHandle, &tst)) {
176 goto fail_IsValidCellHandle;
179 if (cellHandle->tokens == NULL) {
180 tst = ADMBOSCELLHANDLENOTOKENS;
181 goto fail_IsValidCellHandle;
185 fail_IsValidCellHandle:
194 * bos_ServerOpen - open a bos server for work.
198 * IN cellHandle - a previously opened cellHandle.
200 * IN serverName - the name of the machine that houses the bosserver of
203 * OUT serverHandleP - upon successful completion, this void pointer
204 * will point to a valid server handle for use in future operations.
208 * No locks are obtained or released by this function
212 * Returns != 0 upon successful completion.
215 int ADMINAPI bos_ServerOpen(
216 const void *cellHandle,
217 const char *serverName,
218 void **serverHandleP,
222 afs_status_t tst = 0;
223 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
224 bos_server_p bos_server = (bos_server_p) malloc(sizeof(bos_server_t));
228 * Validate parameters
231 if (!IsValidCellHandle(c_handle, &tst)) {
232 goto fail_bos_ServerOpen;
235 if ((serverName == NULL) || (*serverName == 0)) {
236 tst = ADMBOSSERVERNAMENULL;
237 goto fail_bos_ServerOpen;
240 if (serverHandleP == NULL) {
241 tst = ADMBOSSERVERHANDLEPNULL;
242 goto fail_bos_ServerOpen;
245 if (util_AdminServerAddressGetFromName(serverName, &serverAddress, &tst) == 0) {
246 goto fail_bos_ServerOpen;
249 if (bos_server == NULL) {
251 goto fail_bos_ServerOpen;
254 bos_server->server = rx_GetCachedConnection(htonl(serverAddress),
255 htons(AFSCONF_NANNYPORT), 1,
256 c_handle->tokens->afs_sc[c_handle->tokens->sc_index], c_handle->tokens->sc_index);
258 bos_server->server_encrypt = rx_GetCachedConnection(htonl(serverAddress),
259 htons(AFSCONF_NANNYPORT), 1,
260 c_handle->tokens->afs_encrypt_sc[c_handle->tokens->sc_index], c_handle->tokens->sc_index);
262 bos_server->server_stats = rx_GetCachedConnection(htonl(serverAddress),
263 htons(AFSCONF_NANNYPORT),
265 c_handle->tokens->afs_sc[c_handle->tokens->sc_index], c_handle->tokens->sc_index);
267 if ((bos_server->server == NULL) || (bos_server->server_encrypt == NULL)) {
268 tst = ADMBOSSERVERNOCONNECTION;
269 goto fail_bos_ServerOpen;
272 bos_server->begin_magic = BEGIN_MAGIC;
273 bos_server->is_valid = 1;
274 bos_server->end_magic = END_MAGIC;
276 *serverHandleP = (void *) bos_server;
281 if ((rc == 0) && (bos_server != NULL)) {
282 if (bos_server->server) {
283 rx_ReleaseCachedConnection(bos_server->server);
285 if (bos_server->server_encrypt) {
286 rx_ReleaseCachedConnection(bos_server->server_encrypt);
298 * bos_ServerClose - close a bos server handle
302 * IN serverHandle - a bos server handle previously returned by bos_ServerOpen
306 * No locks are obtained or released by this function
310 * Returns != 0 upon successful completion.
313 int ADMINAPI bos_ServerClose(
314 const void *serverHandle,
318 afs_status_t tst = 0;
319 bos_server_p b_handle = (bos_server_p) serverHandle;
321 if (isValidServerHandle(b_handle, &tst)) {
322 rx_ReleaseCachedConnection(b_handle->server);
323 b_handle->is_valid = 0;
335 * bos_ProcessCreate - create a new process to run at a bos server.
339 * IN serverHandle - a previously opened serverHandle.
341 * IN processName - the name of the process to create.
343 * IN processType - the type of process to create.
345 * IN process - the path to the process binary at the bos server.
347 * IN cronTime - the time specification for cron processes.
349 * IN notifier - the path to the notifier binary at the bos server.
353 * No locks are obtained or released by this function
357 * Returns != 0 upon successful completion.
361 * CAUTION - this list must match bos_ProcessType_t definition
364 static char *processTypes[] = {"simple", "fs", "cron", 0};
366 int ADMINAPI bos_ProcessCreate(
367 const void *serverHandle,
368 const char *processName,
369 bos_ProcessType_t processType,
371 const char *cronTime,
372 const char *notifier,
376 afs_status_t tst = 0;
377 bos_server_p b_handle = (bos_server_p) serverHandle;
379 if (!isValidServerHandle(b_handle, &tst)) {
380 goto fail_bos_ProcessCreate;
383 if (processType == BOS_PROCESS_FS) {
384 tst = ADMBOSPROCESSCREATEBADTYPE;
385 goto fail_bos_ProcessCreate;
388 if ((processName == NULL) || (*processName == 0)) {
389 tst = ADMBOSPROCESSNAMENULL;
390 goto fail_bos_ProcessCreate;
393 if ((process == NULL) || (*process == 0)) {
394 tst = ADMBOSPROCESSNULL;
395 goto fail_bos_ProcessCreate;
398 if ((processType == BOS_PROCESS_CRON) && (cronTime == NULL)) {
399 tst = ADMBOSCRONTIMENULL;
400 goto fail_bos_ProcessCreate;
403 if ((processType == BOS_PROCESS_SIMPLE) && (cronTime != NULL)) {
404 tst = ADMBOSCRONTIMENOTNULL;
405 goto fail_bos_ProcessCreate;
408 tst = BOZO_CreateBnode(b_handle->server, processTypes[processType],
409 processName, process,
410 (cronTime) ? cronTime : "", "", "", "",
411 (notifier) ? notifier : NONOTIFIER);
416 fail_bos_ProcessCreate:
425 * bos_FSProcessCreate - create the fs group of processes at the boserver.
429 * IN serverHandle - a previously opened serverHandle.
431 * IN processName - the name of the process to create.
433 * IN fileserverPath - the path to the fileserver binary at the bos server.
435 * IN volserverPath - the path to the volserver binary at the bos server.
437 * IN salvagerPath - the path to the salvager binary at the bos server.
439 * IN notifier - the path to the notifier binary at the bos server.
443 * No locks are obtained or released by this function
447 * Returns != 0 upon successful completion.
450 int ADMINAPI bos_FSProcessCreate(
451 const void *serverHandle,
452 const char *processName,
453 const char *fileserverPath,
454 const char *volserverPath,
455 const char *salvagerPath,
456 const char *notifier,
460 afs_status_t tst = 0;
461 bos_server_p b_handle = (bos_server_p) serverHandle;
463 if (!isValidServerHandle(b_handle, &tst)) {
464 goto fail_bos_ProcessCreate;
467 if ((processName == NULL) || (*processName == 0)) {
468 tst = ADMBOSPROCESSNAMENULL;
469 goto fail_bos_ProcessCreate;
472 if ((fileserverPath == NULL) || (*fileserverPath == 0)) {
473 tst = ADMBOSFILESERVERPATHNULL;
474 goto fail_bos_ProcessCreate;
477 if ((volserverPath == NULL) || (*volserverPath == 0)) {
478 tst = ADMBOSVOLSERVERPATHNULL;
479 goto fail_bos_ProcessCreate;
482 if ((salvagerPath == NULL) || (*salvagerPath == 0)) {
483 tst = ADMBOSSALVAGERPATHNULL;
484 goto fail_bos_ProcessCreate;
487 tst = BOZO_CreateBnode(b_handle->server,
488 processTypes[BOS_PROCESS_FS],
495 (notifier) ? notifier : NONOTIFIER);
500 fail_bos_ProcessCreate:
509 * bos_ProcessDelete - delete an existing process at a bos server.
513 * IN serverHandle - a previously opened serverHandle.
515 * IN processName - the name of the process to delete.
519 * No locks are obtained or released by this function
523 * Returns != 0 upon successful completion.
526 int ADMINAPI bos_ProcessDelete(
527 const void *serverHandle,
528 const char *processName,
532 afs_status_t tst = 0;
533 bos_server_p b_handle = (bos_server_p) serverHandle;
535 if (!isValidServerHandle(b_handle, &tst)) {
536 goto fail_bos_ProcessDelete;
539 if ((processName == NULL) || (*processName == 0)) {
540 tst = ADMBOSPROCESSNAMENULL;
541 goto fail_bos_ProcessDelete;
544 tst = BOZO_DeleteBnode(b_handle->server, processName);
550 fail_bos_ProcessDelete:
559 * bos_ProcessExecutionStateGet - get the current execution state of a
564 * IN serverHandle - a previously opened serverHandle.
566 * IN processName - the name of the process to retrieve.
568 * OUT processStatusP - upon successful completion the process execution state
570 * OUT auxiliaryProcessStatus - set to point to aux proc status if available.
571 * Pass a pointer to an char array at least BOS_MAX_NAME_LEN long.
575 * No locks are obtained or released by this function
579 * Returns != 0 upon successful completion.
582 int ADMINAPI bos_ProcessExecutionStateGet(
583 const void *serverHandle,
584 const char *processName,
585 bos_ProcessExecutionState_p processStatusP,
586 char *auxiliaryProcessStatus,
590 afs_status_t tst = 0;
591 bos_server_p b_handle = (bos_server_p) serverHandle;
594 if (!isValidServerHandle(b_handle, &tst)) {
595 goto fail_bos_ProcessExecutionStateGet;
598 if ((processName == NULL) || (*processName == 0)) {
599 tst = ADMBOSPROCESSNAMENULL;
600 goto fail_bos_ProcessExecutionStateGet;
603 if (processStatusP == NULL) {
604 tst = ADMBOSPROCESSSTATUSPNULL;
605 goto fail_bos_ProcessExecutionStateGet;
608 if (auxiliaryProcessStatus == NULL) {
609 tst = ADMBOSAUXILIARYPROCESSSTATUSNULL;
610 goto fail_bos_ProcessExecutionStateGet;
613 tst = BOZO_GetStatus(b_handle->server, processName, &state, &auxiliaryProcessStatus);
616 goto fail_bos_ProcessExecutionStateGet;
619 *processStatusP = (bos_ProcessExecutionState_t) state;
622 fail_bos_ProcessExecutionStateGet:
631 * SetExecutionState - set the execution state of a process
635 * IN serverHandle - a previously opened serverHandle.
637 * IN processName - the name of the process to modify.
639 * IN processStatus - the new process state.
641 * IN func - the function to call to set the status.
645 * No locks are obtained or released by this function
649 * Returns != 0 upon successful completion.
652 static int SetExecutionState(
653 const void *serverHandle,
654 const char *processName,
655 const bos_ProcessExecutionState_t processStatus,
656 int (*func)(struct rx_connection *, const char *, afs_int32),
660 afs_status_t tst = 0;
661 bos_server_p b_handle = (bos_server_p) serverHandle;
664 if (!isValidServerHandle(b_handle, &tst)) {
665 goto fail_SetExecutionState;
668 if ((processName == NULL) || (*processName == 0)) {
669 tst = ADMBOSPROCESSNAMENULL;
670 goto fail_SetExecutionState;
673 if ((processStatus != BOS_PROCESS_STOPPED) &&
674 (processStatus != BOS_PROCESS_RUNNING)) {
675 tst = ADMBOSPROCESSSTATUSSET;
676 goto fail_SetExecutionState;
679 state = (afs_int32) processStatus;
681 tst = func(b_handle->server, processName, state);
687 fail_SetExecutionState:
696 * bos_ProcessExecutionStateSet - set the execution state of a process
700 * IN serverHandle - a previously opened serverHandle.
702 * IN processName - the name of the process to modify.
704 * IN processStatus - the new process state.
708 * No locks are obtained or released by this function
712 * Returns != 0 upon successful completion.
715 int ADMINAPI bos_ProcessExecutionStateSet(
716 const void *serverHandle,
717 const char *processName,
718 bos_ProcessExecutionState_t processStatus,
721 return SetExecutionState(serverHandle, processName, processStatus,
726 * bos_ProcessExecutionStateSetTemporary - set the execution state of a process
731 * IN serverHandle - a previously opened serverHandle.
733 * IN processName - the name of the process to modify.
735 * IN processStatus - the new process state.
739 * No locks are obtained or released by this function
743 * Returns != 0 upon successful completion.
746 int ADMINAPI bos_ProcessExecutionStateSetTemporary(
747 const void *serverHandle,
748 const char *processName,
749 bos_ProcessExecutionState_t processStatus,
752 return SetExecutionState(serverHandle, processName, processStatus,
753 BOZO_SetTStatus, st);
757 * The iterator functions and data for the process name retrieval functions
760 typedef struct process_name_get {
762 struct rx_connection *server;
763 char process[CACHED_ITEMS][BOS_MAX_NAME_LEN];
764 } process_name_get_t, *process_name_get_p;
766 static int GetProcessNameRPC(
770 int *last_item_contains_data,
774 afs_status_t tst = 0;
775 process_name_get_p proc = (process_name_get_p) rpc_specific;
776 char *ptr = (char *) &proc->process[slot];
778 tst = BOZO_EnumerateInstance(proc->server, proc->next++, &ptr);
782 } else if (tst == BZDOM) {
786 *last_item_contains_data = 0;
795 static int GetProcessNameFromCache(
802 afs_status_t tst = 0;
803 process_name_get_p proc = (process_name_get_p) rpc_specific;
805 strcpy((char *) dest, (char *) &proc->process[slot]);
815 * bos_ProcessNameGetBegin - begin iterating over the list of processes
816 * at a particular bos server.
820 * IN serverHandle - a previously opened serverHandle.
822 * OUT iter - an iterator that can be passed to bos_ProcessNameGetNext
823 * to retrieve the process names.
827 * No locks are obtained or released by this function
831 * Returns != 0 upon successful completion.
835 int ADMINAPI bos_ProcessNameGetBegin(
836 const void *serverHandle,
841 afs_status_t tst = 0;
842 bos_server_p b_handle = (bos_server_p) serverHandle;
843 afs_admin_iterator_p iter = (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
844 process_name_get_p proc = (process_name_get_p) malloc(sizeof(process_name_get_t));
846 if (!isValidServerHandle(b_handle, &tst)) {
847 goto fail_bos_ProcessNameGetBegin;
850 if (iterationIdP == NULL) {
851 tst = ADMITERATIONIDPNULL;
852 goto fail_bos_ProcessNameGetBegin;
855 if ((iter == NULL) || (proc == NULL)) {
857 goto fail_bos_ProcessNameGetBegin;
861 proc->server = b_handle->server;
863 if (IteratorInit(iter, (void *) proc, GetProcessNameRPC, GetProcessNameFromCache, NULL, NULL, &tst)) {
864 *iterationIdP = (void *) iter;
866 goto fail_bos_ProcessNameGetBegin;
870 fail_bos_ProcessNameGetBegin:
888 * bos_ProcessNameGetNext - retrieve the next process name from the bos server.
892 * IN iterationId - an iterator previously returned by bos_ProcessNameGetBegin
894 * OUT processName - upon successful completion contains the next process name
895 * retrieved from the server.
899 * No locks are obtained or released by this function
903 * Returns != 0 upon successful completion.
907 int ADMINAPI bos_ProcessNameGetNext(
908 const void *iterationId,
913 afs_status_t tst = 0;
914 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
916 if (processName == NULL) {
917 tst = ADMBOSPROCESSNAMENULL;
918 goto fail_bos_ProcessNameGetNext;
921 if (iterationId == NULL) {
922 tst = ADMITERATIONIDPNULL;
923 goto fail_bos_ProcessNameGetNext;
926 rc = IteratorNext(iter, (void *) processName, &tst);
928 fail_bos_ProcessNameGetNext:
937 * bos_ProcessNameGetDone - finish using a process name iterator.
941 * IN iterationId - an iterator previously returned by bos_ProcessNameGetBegin
945 * No locks are obtained or released by this function
949 * Returns != 0 upon successful completion.
953 int ADMINAPI bos_ProcessNameGetDone(
954 const void *iterationId,
958 afs_status_t tst = 0;
959 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
961 if (iterationId == NULL) {
962 tst = ADMITERATIONIDPNULL;
963 goto fail_bos_ProcessNameGetDone;
966 rc = IteratorDone(iter, &tst);
968 fail_bos_ProcessNameGetDone:
977 * bos_ProcessInfoGet - get information about a single process
981 * IN serverHandle - a previously opened serverHandle.
983 * IN processName - the process of interest.
985 * OUT processTypeP - upon successful completion contains the process type
987 * OUT processInfoP - upon successful completion contains the process info
991 * No locks are obtained or released by this function
995 * Returns != 0 upon successful completion.
999 int ADMINAPI bos_ProcessInfoGet(
1000 const void *serverHandle,
1001 const char *processName,
1002 bos_ProcessType_p processTypeP,
1003 bos_ProcessInfo_p processInfoP,
1007 afs_status_t tst = 0;
1008 bos_server_p b_handle = (bos_server_p) serverHandle;
1009 char type[BOS_MAX_NAME_LEN];
1011 struct bozo_status status;
1014 if (!isValidServerHandle(b_handle, &tst)) {
1015 goto fail_bos_ProcessInfoGet;
1018 if ((processName == NULL) || (*processName == 0)) {
1019 tst = ADMBOSPROCESSNAMENULL;
1020 goto fail_bos_ProcessInfoGet;
1023 if (processTypeP == NULL) {
1024 tst = ADMBOSPROCESSTYPEPNULL;
1025 goto fail_bos_ProcessInfoGet;
1028 if (processInfoP == NULL) {
1029 tst = ADMBOSPROCESSINFOPNULL;
1030 goto fail_bos_ProcessInfoGet;
1033 tst = BOZO_GetInstanceInfo(b_handle->server, processName, &ptr, &status);
1036 goto fail_bos_ProcessInfoGet;
1040 for(i=0;(processTypes[i] != NULL); i++) {
1041 if (!strcmp(processTypes[i], type)) {
1042 *processTypeP = (bos_ProcessType_t) i;
1047 if (processTypes[i] == NULL) {
1048 tst = ADMBOSINVALIDPROCESSTYPE;
1049 goto fail_bos_ProcessInfoGet;
1052 processInfoP->processGoal = (bos_ProcessExecutionState_t) status.goal;
1053 processInfoP->processStartTime = status.procStartTime;
1054 processInfoP->numberProcessStarts = status.procStarts;
1055 processInfoP->processExitTime = status.lastAnyExit;
1056 processInfoP->processExitErrorTime = status.lastErrorExit;
1057 processInfoP->processErrorCode = status.errorCode;
1058 processInfoP->processErrorSignal = status.errorSignal;
1059 processInfoP->state = BOS_PROCESS_OK;
1061 if (status.flags & BOZO_ERRORSTOP) {
1062 processInfoP->state |= BOS_PROCESS_TOO_MANY_ERRORS;
1064 if (status.flags & BOZO_HASCORE) {
1065 processInfoP->state |= BOS_PROCESS_CORE_DUMPED;
1067 if (status.flags & BOZO_BADDIRACCESS) {
1068 processInfoP->state |= BOS_PROCESS_BAD_FILE_ACCESS;
1072 fail_bos_ProcessInfoGet:
1081 * The iterator functions and data for the parameter retrieval functions
1084 typedef struct param_get {
1086 struct rx_connection *server;
1087 char processName[BOS_MAX_NAME_LEN];
1088 char param[CACHED_ITEMS][BOS_MAX_NAME_LEN];
1089 } param_get_t, *param_get_p;
1091 static int GetParameterRPC(
1095 int *last_item_contains_data,
1099 afs_status_t tst = 0;
1100 param_get_p param = (param_get_p) rpc_specific;
1101 char *ptr = (char *) ¶m->param[slot];
1103 tst = BOZO_GetInstanceParm(param->server, param->processName,
1104 param->next++, &ptr);
1108 } else if (tst == BZDOM) {
1112 *last_item_contains_data = 0;
1121 static int GetParameterFromCache(
1128 afs_status_t tst = 0;
1129 param_get_p param = (param_get_p) rpc_specific;
1131 strcpy((char *) dest, (char *) ¶m->param[slot]);
1141 * bos_ProcessParameterGetBegin - begin iterating over the parameters
1142 * of a particular process.
1146 * IN serverHandle - a previously opened serverHandle.
1148 * IN processName - the process whose parameters are returned.
1150 * OUT iter - an iterator that can be passed to bos_ProcessParameterGetNext
1151 * to retrieve the parameters.
1155 * No locks are obtained or released by this function
1159 * Returns != 0 upon successful completion.
1163 int ADMINAPI bos_ProcessParameterGetBegin(
1164 const void *serverHandle,
1165 const char *processName,
1166 void **iterationIdP,
1170 afs_status_t tst = 0;
1171 bos_server_p b_handle = (bos_server_p) serverHandle;
1172 afs_admin_iterator_p iter = (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1173 param_get_p param = (param_get_p) malloc(sizeof(param_get_t));
1175 if (!isValidServerHandle(b_handle, &tst)) {
1176 goto fail_bos_ProcessParameterGetBegin;
1179 if ((processName == NULL) || (*processName == 0)) {
1180 tst = ADMBOSPROCESSNAMENULL;
1181 goto fail_bos_ProcessParameterGetBegin;
1184 if (iterationIdP == NULL) {
1185 tst = ADMITERATIONIDPNULL;
1186 goto fail_bos_ProcessParameterGetBegin;
1189 if ((iter == NULL) || (param == NULL)) {
1191 goto fail_bos_ProcessParameterGetBegin;
1195 param->server = b_handle->server;
1196 strcpy(param->processName, processName);
1198 if (IteratorInit(iter, (void *) param, GetParameterRPC,
1199 GetParameterFromCache, NULL, NULL, &tst)) {
1200 *iterationIdP = (void *) iter;
1202 goto fail_bos_ProcessParameterGetBegin;
1206 fail_bos_ProcessParameterGetBegin:
1212 if (param != NULL) {
1224 * bos_ProcessParameterGetNext - retrieve the next parameter
1225 * from the bos server.
1229 * IN iterationId - an iterator previously returned by
1230 * bos_ProcessParameterGetBegin
1232 * OUT parameter - upon successful completion contains the next parameter
1233 * retrieved from the server.
1237 * No locks are obtained or released by this function
1241 * Returns != 0 upon successful completion.
1245 int ADMINAPI bos_ProcessParameterGetNext(
1246 const void *iterationId,
1251 afs_status_t tst = 0;
1252 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1254 if (iterationId == NULL) {
1255 tst = ADMITERATIONIDPNULL;
1256 goto fail_bos_ProcessParameterGetNext;
1259 if (parameter == NULL) {
1260 tst = ADMBOSPARAMETERNULL;
1261 goto fail_bos_ProcessParameterGetNext;
1264 rc = IteratorNext(iter, (void *) parameter, &tst);
1266 fail_bos_ProcessParameterGetNext:
1275 * bos_ProcessParameterGetDone - finish using a process name iterator.
1279 * IN iterationId - an iterator previously returned by
1280 * bos_ProcessParameterGetBegin
1284 * No locks are obtained or released by this function
1288 * Returns != 0 upon successful completion.
1292 int ADMINAPI bos_ProcessParameterGetDone(
1293 const void *iterationId,
1297 afs_status_t tst = 0;
1298 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1300 if (iterationId == NULL) {
1301 tst = ADMITERATIONIDPNULL;
1302 goto fail_bos_ProcessParameterGetDone;
1305 rc = IteratorDone(iter, &tst);
1307 fail_bos_ProcessParameterGetDone:
1316 * bos_ProcessNotifierGet - retrieve the notifier associated with a
1321 * IN serverHandle - a previously opened serverHandle.
1323 * IN processName - the process whose notifier we are retrieving.
1325 * OUT notifier - upon successful completion contains the notifier.
1329 * No locks are obtained or released by this function
1333 * Returns != 0 upon successful completion.
1337 int ADMINAPI bos_ProcessNotifierGet(
1338 const void *serverHandle,
1339 const char *processName,
1344 afs_status_t tst = 0;
1345 bos_server_p b_handle = (bos_server_p) serverHandle;
1347 if (!isValidServerHandle(b_handle, &tst)) {
1348 goto fail_bos_ProcessNotifierGet;
1351 if ((processName == NULL) || (*processName == 0)) {
1352 tst = ADMBOSPROCESSNAMENULL;
1353 goto fail_bos_ProcessNotifierGet;
1356 if (notifier == NULL) {
1357 tst = ADMBOSNOTIFIERNULL;
1358 goto fail_bos_ProcessNotifierGet;
1361 tst = BOZO_GetInstanceParm(b_handle->server, processName, 999, ¬ifier);
1367 fail_bos_ProcessNotifierGet:
1376 * bos_ProcessRestart - restart a particular process.
1380 * IN serverHandle - a previously opened serverHandle.
1382 * IN processName - the process to restart
1386 * No locks are obtained or released by this function
1390 * Returns != 0 upon successful completion.
1394 int ADMINAPI bos_ProcessRestart(
1395 const void *serverHandle,
1396 const char *processName,
1400 afs_status_t tst = 0;
1401 bos_server_p b_handle = (bos_server_p) serverHandle;
1403 if (!isValidServerHandle(b_handle, &tst)) {
1404 goto fail_bos_ProcessRestart;
1407 if ((processName == NULL) || (*processName == 0)) {
1408 tst = ADMBOSPROCESSNAMENULL;
1409 goto fail_bos_ProcessRestart;
1412 tst = BOZO_Restart(b_handle->server, processName);
1418 fail_bos_ProcessRestart:
1427 * bos_ProcessAllStop - stop all running processes at a server.
1431 * IN serverHandle - a previously opened serverHandle.
1435 * No locks are obtained or released by this function
1439 * Returns != 0 upon successful completion.
1443 int ADMINAPI bos_ProcessAllStop(
1444 const void *serverHandle,
1448 afs_status_t tst = 0;
1449 bos_server_p b_handle = (bos_server_p) serverHandle;
1451 if (!isValidServerHandle(b_handle, &tst)) {
1452 goto fail_bos_ProcessAllStop;
1455 tst = BOZO_ShutdownAll(b_handle->server);
1461 fail_bos_ProcessAllStop:
1470 * bos_ProcessAllStart - start all processes that should be running at a
1475 * IN serverHandle - a previously opened serverHandle.
1479 * No locks are obtained or released by this function
1483 * Returns != 0 upon successful completion.
1487 int ADMINAPI bos_ProcessAllStart(
1488 const void *serverHandle,
1492 afs_status_t tst = 0;
1493 bos_server_p b_handle = (bos_server_p) serverHandle;
1495 if (!isValidServerHandle(b_handle, &tst)) {
1496 goto fail_bos_ProcessAllStart;
1499 tst = BOZO_StartupAll(b_handle->server);
1505 fail_bos_ProcessAllStart:
1514 * bos_ProcessAllWaitStop - stop all processes, and block until they have
1519 * IN serverHandle - a previously opened serverHandle.
1523 * No locks are obtained or released by this function
1527 * Returns != 0 upon successful completion.
1531 int ADMINAPI bos_ProcessAllWaitStop(
1532 const void *serverHandle,
1536 afs_status_t tst = 0;
1537 bos_server_p b_handle = (bos_server_p) serverHandle;
1539 if (!isValidServerHandle(b_handle, &tst)) {
1540 goto fail_bos_ProcessAllWaitStop;
1543 if (!bos_ProcessAllStop(serverHandle, &tst)) {
1544 goto fail_bos_ProcessAllWaitStop;
1547 tst = BOZO_WaitAll(b_handle->server);
1553 fail_bos_ProcessAllWaitStop:
1562 * bos_ProcessAllWaitTransition - block until all processes at the bosserver
1563 * have reached their desired state.
1567 * IN serverHandle - a previously opened serverHandle.
1571 * No locks are obtained or released by this function
1575 * Returns != 0 upon successful completion.
1579 int ADMINAPI bos_ProcessAllWaitTransition(
1580 const void *serverHandle,
1584 afs_status_t tst = 0;
1585 bos_server_p b_handle = (bos_server_p) serverHandle;
1587 if (!isValidServerHandle(b_handle, &tst)) {
1588 goto fail_bos_ProcessAllWaitTransition;
1591 tst = BOZO_WaitAll(b_handle->server);
1597 fail_bos_ProcessAllWaitTransition:
1606 * bos_ProcessAllStopAndRestart - stop all the running processes, restart
1607 * them, and optionally restart the bosserver itself.
1612 * IN serverHandle - a previously opened serverHandle.
1614 * IN restartBosServer - flag to indicate whether to restart bosserver.
1618 * No locks are obtained or released by this function
1622 * Returns != 0 upon successful completion.
1626 int ADMINAPI bos_ProcessAllStopAndRestart(
1627 const void *serverHandle,
1628 bos_RestartBosServer_t restartBosServer,
1632 afs_status_t tst = 0;
1633 bos_server_p b_handle = (bos_server_p) serverHandle;
1635 if (!isValidServerHandle(b_handle, &tst)) {
1636 goto fail_bos_ProcessAllStopAndRestart;
1639 if (restartBosServer == BOS_RESTART_BOS_SERVER) {
1640 tst = BOZO_ReBozo(b_handle->server);
1642 goto fail_bos_ProcessAllStopAndRestart;
1646 tst = BOZO_RestartAll(b_handle->server);
1652 fail_bos_ProcessAllStopAndRestart:
1661 * bos_AdminCreate - create a new admin.
1665 * IN serverHandle - a previously opened serverHandle.
1667 * IN adminName - the new admin name.
1671 * No locks are obtained or released by this function
1675 * Returns != 0 upon successful completion.
1679 int ADMINAPI bos_AdminCreate(
1680 const void *serverHandle,
1681 const char *adminName,
1685 afs_status_t tst = 0;
1686 bos_server_p b_handle = (bos_server_p) serverHandle;
1688 if (!isValidServerHandle(b_handle, &tst)) {
1689 goto fail_bos_AdminCreate;
1692 if ((adminName == NULL) || (*adminName == 0)) {
1693 tst = ADMBOSADMINNAMENULL;
1694 goto fail_bos_AdminCreate;
1697 tst = BOZO_AddSUser(b_handle->server, adminName);
1703 fail_bos_AdminCreate:
1712 * bos_AdminDelete - delete a new admin.
1716 * IN serverHandle - a previously opened serverHandle.
1718 * IN adminName - the admin name.
1722 * No locks are obtained or released by this function
1726 * Returns != 0 upon successful completion.
1730 int ADMINAPI bos_AdminDelete(
1731 const void *serverHandle,
1732 const char *adminName,
1736 afs_status_t tst = 0;
1737 bos_server_p b_handle = (bos_server_p) serverHandle;
1739 if (!isValidServerHandle(b_handle, &tst)) {
1740 goto fail_bos_AdminDelete;
1743 if ((adminName == NULL) || (*adminName == 0)) {
1744 tst = ADMBOSADMINNAMENULL;
1745 goto fail_bos_AdminDelete;
1748 tst = BOZO_DeleteSUser(b_handle->server, adminName);
1754 fail_bos_AdminDelete:
1763 * The iterator functions and data for the admin retrieval functions
1766 typedef struct admin_get {
1768 struct rx_connection *server;
1769 char admin[CACHED_ITEMS][BOS_MAX_NAME_LEN];
1770 } admin_get_t, *admin_get_p;
1772 static int GetAdminRPC(
1776 int *last_item_contains_data,
1780 afs_status_t tst = 0;
1781 admin_get_p admin = (admin_get_p) rpc_specific;
1782 char *ptr = (char *) &admin->admin[slot];
1784 tst = BOZO_ListSUsers(admin->server, admin->next++, &ptr);
1787 * There's no way to tell the difference between an rpc failure
1788 * and the end of the list, so we assume that any error means the
1795 *last_item_contains_data = 0;
1805 static int GetAdminFromCache(
1812 afs_status_t tst = 0;
1813 admin_get_p admin = (admin_get_p) rpc_specific;
1815 strcpy((char *) dest, (char *) &admin->admin[slot]);
1825 * bos_AdminGetBegin - begin iterating over the administrators.
1829 * IN serverHandle - a previously opened serverHandle.
1831 * OUT iter - an iterator that can be passed to bos_AdminGetBegin
1832 * to retrieve the administrators.
1836 * No locks are obtained or released by this function
1840 * Returns != 0 upon successful completion.
1844 int ADMINAPI bos_AdminGetBegin(
1845 const void *serverHandle,
1846 void **iterationIdP,
1850 afs_status_t tst = 0;
1851 bos_server_p b_handle = (bos_server_p) serverHandle;
1852 afs_admin_iterator_p iter = (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
1853 admin_get_p admin = (admin_get_p) malloc(sizeof(admin_get_t));
1855 if (!isValidServerHandle(b_handle, &tst)) {
1856 goto fail_bos_AdminGetBegin;
1859 if (iterationIdP == NULL) {
1860 tst = ADMITERATIONIDPNULL;
1861 goto fail_bos_AdminGetBegin;
1864 if ((iter == NULL) || (admin == NULL)) {
1866 goto fail_bos_AdminGetBegin;
1870 admin->server = b_handle->server;
1872 if (IteratorInit(iter, (void *) admin, GetAdminRPC,
1873 GetAdminFromCache, NULL, NULL, &tst)) {
1874 *iterationIdP = (void *) iter;
1878 fail_bos_AdminGetBegin:
1884 if (admin != NULL) {
1896 * bos_AdminGetNext - retrieve the next administrator
1897 * from the bos server.
1901 * IN iterationId - an iterator previously returned by
1904 * OUT adminName - upon successful completion contains the next administrator
1905 * retrieved from the server.
1909 * No locks are obtained or released by this function
1913 * Returns != 0 upon successful completion.
1917 int ADMINAPI bos_AdminGetNext(
1918 const void *iterationId,
1923 afs_status_t tst = 0;
1924 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1926 if (iterationId == NULL) {
1927 tst = ADMITERATIONIDPNULL;
1928 goto fail_bos_AdminGetNext;
1931 if (adminName == NULL) {
1932 tst = ADMBOSADMINNAMENULL;
1933 goto fail_bos_AdminGetNext;
1936 rc = IteratorNext(iter, (void *) adminName, &tst);
1938 fail_bos_AdminGetNext:
1947 * bos_AdminGetDone - finish using a administrator iterator.
1951 * IN iterationId - an iterator previously returned by
1956 * No locks are obtained or released by this function
1960 * Returns != 0 upon successful completion.
1964 int ADMINAPI bos_AdminGetDone(
1965 const void *iterationId,
1969 afs_status_t tst = 0;
1970 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
1972 if (iterationId == NULL) {
1973 tst = ADMITERATIONIDPNULL;
1974 goto fail_bos_AdminGetDone;
1977 rc = IteratorDone(iter, &tst);
1979 fail_bos_AdminGetDone:
1988 * bos_KeyCreate - add a new key to the keyfile.
1992 * IN serverHandle - a previously opened serverHandle.
1994 * IN keyVersionNumber - the key version number.
1996 * IN key - the new key.
2000 * No locks are obtained or released by this function
2004 * Returns != 0 upon successful completion.
2008 int ADMINAPI bos_KeyCreate(
2009 const void *serverHandle,
2010 int keyVersionNumber,
2011 const kas_encryptionKey_p key,
2015 afs_status_t tst = 0;
2016 bos_server_p b_handle = (bos_server_p) serverHandle;
2018 if (!isValidServerHandle(b_handle, &tst)) {
2019 goto fail_bos_KeyCreate;
2023 tst = ADMBOSKEYNULL;
2024 goto fail_bos_KeyCreate;
2027 tst = BOZO_AddKey(b_handle->server_encrypt, keyVersionNumber, key);
2042 * bos_KeyDelete - delete an existing key from the keyfile.
2046 * IN serverHandle - a previously opened serverHandle.
2048 * IN keyVersionNumber - the key version number.
2052 * No locks are obtained or released by this function
2056 * Returns != 0 upon successful completion.
2060 int ADMINAPI bos_KeyDelete(
2061 const void *serverHandle,
2062 int keyVersionNumber,
2066 afs_status_t tst = 0;
2067 bos_server_p b_handle = (bos_server_p) serverHandle;
2069 if (!isValidServerHandle(b_handle, &tst)) {
2070 goto fail_bos_KeyDelete;
2073 tst = BOZO_DeleteKey(b_handle->server, keyVersionNumber);
2088 * The iterator functions and data for the key retrieval functions
2091 typedef struct key_get {
2093 struct rx_connection *server;
2094 bos_KeyInfo_t key[CACHED_ITEMS];
2095 } key_get_t, *key_get_p;
2097 static int GetKeyRPC(
2101 int *last_item_contains_data,
2105 afs_status_t tst = 0;
2106 key_get_p key = (key_get_p) rpc_specific;
2107 struct bozo_keyInfo keyInfo;
2109 tst = BOZO_ListKeys(key->server, key->next++,
2110 &key->key[slot].keyVersionNumber,
2111 &key->key[slot].key, &keyInfo);
2115 key->key[slot].keyStatus.lastModificationDate = keyInfo.mod_sec;
2116 key->key[slot].keyStatus.lastModificationMicroSeconds =
2118 key->key[slot].keyStatus.checkSum = keyInfo.keyCheckSum;
2120 } else if (tst == BZDOM) {
2124 *last_item_contains_data = 0;
2133 static int GetKeyFromCache(
2140 afs_status_t tst = 0;
2141 key_get_p key = (key_get_p) rpc_specific;
2143 memcpy(dest, &key->key[slot], sizeof(bos_KeyInfo_t));
2153 * bos_KeyGetBegin - begin iterating over the keys.
2157 * IN serverHandle - a previously opened serverHandle.
2159 * OUT iter - an iterator that can be passed to bos_KeyGetNext
2160 * to retrieve the keys.
2164 * No locks are obtained or released by this function
2168 * Returns != 0 upon successful completion.
2172 int ADMINAPI bos_KeyGetBegin(
2173 const void *serverHandle,
2174 void **iterationIdP,
2178 afs_status_t tst = 0;
2179 bos_server_p b_handle = (bos_server_p) serverHandle;
2180 afs_admin_iterator_p iter = (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
2181 key_get_p key = (key_get_p) malloc(sizeof(key_get_t));
2183 if (!isValidServerHandle(b_handle, &tst)) {
2184 goto fail_bos_KeyGetBegin;
2187 if (iterationIdP == NULL) {
2188 tst = ADMITERATIONIDPNULL;
2189 goto fail_bos_KeyGetBegin;
2192 if ((iter == NULL) || (key == NULL)) {
2194 goto fail_bos_KeyGetBegin;
2198 key->server = b_handle->server_encrypt;
2200 if (IteratorInit(iter, (void *) key, GetKeyRPC,
2201 GetKeyFromCache, NULL, NULL, &tst)) {
2202 *iterationIdP = (void *) iter;
2206 fail_bos_KeyGetBegin:
2224 * bos_KeyGetNext - retrieve the next key
2225 * from the bos server.
2229 * IN iterationId - an iterator previously returned by
2232 * OUT keyP - upon successful completion contains the next key
2233 * retrieved from the server.
2237 * No locks are obtained or released by this function
2241 * Returns != 0 upon successful completion.
2245 int ADMINAPI bos_KeyGetNext(
2246 const void *iterationId,
2251 afs_status_t tst = 0;
2252 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2254 if (iterationId == NULL) {
2255 tst = ADMITERATIONIDPNULL;
2256 goto fail_bos_KeyGetNext;
2260 tst = ADMBOSKEYPNULL;
2261 goto fail_bos_KeyGetNext;
2264 rc = IteratorNext(iter, (void *) keyP, &tst);
2266 fail_bos_KeyGetNext:
2275 * bos_KeyGetDone - finish using a key iterator.
2279 * IN iterationId - an iterator previously returned by
2284 * No locks are obtained or released by this function
2288 * Returns != 0 upon successful completion.
2292 int ADMINAPI bos_KeyGetDone(
2293 const void *iterationId,
2297 afs_status_t tst = 0;
2298 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2300 if (iterationId == NULL) {
2301 tst = ADMITERATIONIDPNULL;
2302 goto fail_bos_KeyGetDone;
2305 rc = IteratorDone(iter, &tst);
2307 fail_bos_KeyGetDone:
2316 * bos_CellSet - set the cell name at a bos server.
2320 * IN serverHandle - a previously opened serverHandle.
2322 * IN cellName - the new cell name.
2326 * No locks are obtained or released by this function
2330 * Returns != 0 upon successful completion.
2333 int ADMINAPI bos_CellSet(
2334 const void *serverHandle,
2335 const char *cellName,
2339 afs_status_t tst = 0;
2340 bos_server_p b_handle = (bos_server_p) serverHandle;
2342 if (!isValidServerHandle(b_handle, &tst)) {
2343 goto fail_bos_CellSet;
2346 if ((cellName == NULL) || (*cellName == 0)) {
2347 tst = ADMCLIENTCELLNAMENULL;
2348 goto fail_bos_CellSet;
2351 tst = BOZO_SetCellName(b_handle->server, cellName);
2366 * bos_CellGet - get the cell name at a bos server.
2370 * IN serverHandle - a previously opened serverHandle.
2372 * OUT cellName - the cell name.
2376 * No locks are obtained or released by this function
2380 * Returns != 0 upon successful completion.
2383 int ADMINAPI bos_CellGet(
2384 const void *serverHandle,
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_CellGet;
2396 if (cellName == NULL) {
2397 tst = ADMCLIENTCELLNAMENULL;
2398 goto fail_bos_CellGet;
2401 tst = BOZO_GetCellName(b_handle->server, &cellName);
2416 * bos_HostCreate - add a new host to the cell.
2420 * IN serverHandle - a previously opened serverHandle.
2422 * IN hostName - the new host.
2426 * No locks are obtained or released by this function
2430 * Returns != 0 upon successful completion.
2433 int ADMINAPI bos_HostCreate(
2434 const void *serverHandle,
2435 const char *hostName,
2439 afs_status_t tst = 0;
2440 bos_server_p b_handle = (bos_server_p) serverHandle;
2442 if (!isValidServerHandle(b_handle, &tst)) {
2443 goto fail_bos_HostCreate;
2446 if ((hostName == NULL) || (*hostName == 0)) {
2447 tst = ADMBOSHOSTNAMENULL;
2448 goto fail_bos_HostCreate;
2451 tst = BOZO_AddCellHost(b_handle->server, hostName);
2457 fail_bos_HostCreate:
2466 * bos_HostDelete - delete a host from the cell.
2470 * IN serverHandle - a previously opened serverHandle.
2472 * IN hostName - the host.
2476 * No locks are obtained or released by this function
2480 * Returns != 0 upon successful completion.
2483 int ADMINAPI bos_HostDelete(
2484 const void *serverHandle,
2485 const char *hostName,
2489 afs_status_t tst = 0;
2490 bos_server_p b_handle = (bos_server_p) serverHandle;
2492 if (!isValidServerHandle(b_handle, &tst)) {
2493 goto fail_bos_HostDelete;
2496 if ((hostName == NULL) || (*hostName == 0)) {
2497 tst = ADMBOSHOSTNAMENULL;
2498 goto fail_bos_HostDelete;
2501 tst = BOZO_DeleteCellHost(b_handle->server, hostName);
2507 fail_bos_HostDelete:
2516 * The iterator functions and data for the host retrieval functions
2519 typedef struct host_get {
2521 struct rx_connection *server;
2522 char host[CACHED_ITEMS][BOS_MAX_NAME_LEN];
2523 } host_get_t, *host_get_p;
2525 static int GetHostRPC(
2529 int *last_item_contains_data,
2533 afs_status_t tst = 0;
2534 host_get_p host = (host_get_p) rpc_specific;
2535 char *ptr = (char *) &host->host[slot];
2537 tst = BOZO_GetCellHost(host->server, host->next++, &ptr);
2541 } else if (tst == BZDOM) {
2545 *last_item_contains_data = 0;
2554 static int GetHostFromCache(
2561 afs_status_t tst = 0;
2562 host_get_p host = (host_get_p) rpc_specific;
2564 strcpy((char *) dest, (char *) &host->host[slot]);
2574 * bos_HostGetBegin - begin iterating over the hosts in a cell
2575 * at a particular bos server.
2579 * IN serverHandle - a previously opened serverHandle.
2581 * OUT iter - an iterator that can be passed to bos_HostGetNext
2582 * to retrieve the process names.
2586 * No locks are obtained or released by this function
2590 * Returns != 0 upon successful completion.
2594 int ADMINAPI bos_HostGetBegin(
2595 const void *serverHandle,
2596 void **iterationIdP,
2600 afs_status_t tst = 0;
2601 bos_server_p b_handle = (bos_server_p) serverHandle;
2602 afs_admin_iterator_p iter = (afs_admin_iterator_p) malloc(sizeof(afs_admin_iterator_t));
2603 host_get_p host = (host_get_p) malloc(sizeof(host_get_t));
2605 if (!isValidServerHandle(b_handle, &tst)) {
2606 goto fail_bos_HostGetBegin;
2609 if (iterationIdP == NULL) {
2610 tst = ADMITERATIONIDPNULL;
2611 goto fail_bos_HostGetBegin;
2614 if ((iter == NULL) || (host == NULL)) {
2616 goto fail_bos_HostGetBegin;
2620 host->server = b_handle->server;
2622 if (IteratorInit(iter, (void *) host, GetHostRPC,
2623 GetHostFromCache, NULL, NULL, &tst)) {
2624 *iterationIdP = (void *) iter;
2628 fail_bos_HostGetBegin:
2646 * bos_HostGetNext - retrieve the next host
2647 * from the bos server.
2651 * IN iterationId - an iterator previously returned by
2654 * OUT hostName - upon successful completion contains the next host
2655 * retrieved from the server.
2659 * No locks are obtained or released by this function
2663 * Returns != 0 upon successful completion.
2667 int ADMINAPI bos_HostGetNext(
2668 const void *iterationId,
2673 afs_status_t tst = 0;
2674 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2676 if (iterationId == NULL) {
2677 tst = ADMITERATIONIDPNULL;
2678 goto fail_bos_HostGetNext;
2681 if (hostName == NULL) {
2682 tst = ADMBOSHOSTNAMENULL;
2683 goto fail_bos_HostGetNext;
2686 rc = IteratorNext(iter, (void *) hostName, &tst);
2688 fail_bos_HostGetNext:
2697 * bos_HostGetDone - finish using a host iterator.
2701 * IN iterationId - an iterator previously returned by
2706 * No locks are obtained or released by this function
2710 * Returns != 0 upon successful completion.
2714 int ADMINAPI bos_HostGetDone(
2715 const void *iterationId,
2719 afs_status_t tst = 0;
2720 afs_admin_iterator_p iter = (afs_admin_iterator_p) iterationId;
2722 if (iterationId == NULL) {
2723 tst = ADMITERATIONIDPNULL;
2724 goto fail_bos_HostGetDone;
2727 rc = IteratorDone(iter, &tst);
2729 fail_bos_HostGetDone:
2738 * bos_ExecutableCreate - create a new executable at the bos server.
2742 * IN serverHandle - a previously opened serverHandle.
2744 * IN sourceFile - the executable to install at the bos server.
2746 * IN destFile - the location where the executable will be installed.
2750 * No locks are obtained or released by this function
2754 * Returns != 0 upon successful completion.
2758 int ADMINAPI bos_ExecutableCreate(
2759 const void *serverHandle,
2760 const char *sourceFile,
2761 const char *destFile,
2765 afs_status_t tst = 0;
2766 bos_server_p b_handle = (bos_server_p) serverHandle;
2769 struct rx_call *tcall;
2772 * Validate arguments
2775 if (!isValidServerHandle(b_handle, &tst)) {
2776 goto fail_bos_ExecutableCreate;
2779 if ((sourceFile == NULL) || (*sourceFile == 0)) {
2780 tst = ADMBOSSOURCEFILENULL;
2781 goto fail_bos_ExecutableCreate;
2784 if ((destFile == NULL) || (*destFile == 0)) {
2785 tst = ADMBOSDESTFILENULL;
2786 goto fail_bos_ExecutableCreate;
2790 * Open the file locally and compute its size
2793 fd = open(sourceFile, O_RDONLY);
2796 tst = ADMBOSCANTOPENSOURCEFILE;
2797 goto fail_bos_ExecutableCreate;
2800 if (fstat(fd, &estat)) {
2801 tst = ADMBOSCANTSTATSOURCEFILE;
2802 goto fail_bos_ExecutableCreate;
2806 * Start a split rpc to the bos server.
2809 tcall = rx_NewCall(b_handle->server);
2811 tst = StartBOZO_Install(tcall, destFile, estat.st_size,
2812 (afs_int32) estat.st_mode, estat.st_mtime);
2815 rx_EndCall(tcall, tst);
2816 goto fail_bos_ExecutableCreate;
2820 * Copy the data to the server
2826 len = read(fd, tbuffer, sizeof(tbuffer));
2828 tst = ADMBOSCANTREADSOURCEFILE;
2829 rx_EndCall(tcall, len);
2830 goto fail_bos_ExecutableCreate;
2836 tst = rx_Write(tcall, tbuffer, len);
2838 tst = ADMBOSSENDSOURCEFILE;
2839 rx_EndCall(tcall, tst);
2840 goto fail_bos_ExecutableCreate;
2845 * Terminate the rpc to the server
2848 tst = rx_EndCall(tcall, tst);
2854 fail_bos_ExecutableCreate:
2863 * bos_ExecutableRevert - revert an executable to a previous .BAK version.
2867 * IN serverHandle - a previously opened serverHandle.
2869 * IN execFile - the executable to revert at the bos server.
2873 * No locks are obtained or released by this function
2877 * Returns != 0 upon successful completion.
2881 int ADMINAPI bos_ExecutableRevert(
2882 const void *serverHandle,
2883 const char *execFile,
2887 afs_status_t tst = 0;
2888 bos_server_p b_handle = (bos_server_p) serverHandle;
2890 if (!isValidServerHandle(b_handle, &tst)) {
2891 goto fail_bos_ExecutableRevert;
2894 if ((execFile == NULL) || (*execFile == 0)) {
2895 tst = ADMBOSEXECFILENULL;
2896 goto fail_bos_ExecutableRevert;
2899 tst = BOZO_UnInstall(b_handle->server, execFile);
2905 fail_bos_ExecutableRevert:
2914 * bos_ExecutableTimestampGet - get the last mod times for an executable,
2915 * the .BAK version of the executable, and the .OLD version of the
2916 * executable if they exist.
2920 * IN serverHandle - a previously opened serverHandle.
2922 * IN execFile - the executable to revert at the bos server.
2926 * No locks are obtained or released by this function
2930 * Returns != 0 upon successful completion.
2934 int ADMINAPI bos_ExecutableTimestampGet(
2935 const void *serverHandle,
2936 const char *execFile,
2937 unsigned long *newTime,
2938 unsigned long *oldTime,
2939 unsigned long *bakTime,
2943 afs_status_t tst = 0;
2944 bos_server_p b_handle = (bos_server_p) serverHandle;
2946 if (!isValidServerHandle(b_handle, &tst)) {
2947 goto fail_bos_ExecutableTimestampGet;
2950 if ((execFile == NULL) || (*execFile == 0)) {
2951 tst = ADMBOSEXECFILENULL;
2952 goto fail_bos_ExecutableTimestampGet;
2955 if (newTime == NULL) {
2956 tst = ADMBOSNEWTIMENULL;
2957 goto fail_bos_ExecutableTimestampGet;
2960 if (oldTime == NULL) {
2961 tst = ADMBOSOLDTIMENULL;
2962 goto fail_bos_ExecutableTimestampGet;
2965 if (bakTime == NULL) {
2966 tst = ADMBOSBAKTIMENULL;
2967 goto fail_bos_ExecutableTimestampGet;
2970 tst = BOZO_GetDates(b_handle->server, execFile, newTime, bakTime, oldTime);
2976 fail_bos_ExecutableTimestampGet:
2985 * bos_ExecutablePrune - prune the bak, old, and core files off a server
2990 * IN serverHandle - a previously opened serverHandle.
2992 * IN oldFiles - prune .OLD files.
2994 * IN bakFiles - prune .BAK files.
2996 * IN coreFiles - prune core files.
3000 * No locks are obtained or released by this function
3004 * Returns != 0 upon successful completion.
3008 int ADMINAPI bos_ExecutablePrune(
3009 const void *serverHandle,
3010 bos_Prune_t oldFiles,
3011 bos_Prune_t bakFiles,
3012 bos_Prune_t coreFiles,
3016 afs_status_t tst = 0;
3017 bos_server_p b_handle = (bos_server_p) serverHandle;
3018 afs_int32 flags = 0;
3020 if (!isValidServerHandle(b_handle, &tst)) {
3021 goto fail_bos_ExecutablePrune;
3024 if (oldFiles == BOS_PRUNE) {
3025 flags |= BOZO_PRUNEOLD;
3028 if (bakFiles == BOS_PRUNE) {
3029 flags |= BOZO_PRUNEBAK;
3032 if (coreFiles == BOS_PRUNE) {
3033 flags |= BOZO_PRUNECORE;
3036 tst = BOZO_Prune(b_handle->server, flags);
3042 fail_bos_ExecutablePrune:
3051 * bos_ExecutableRestartTimeSet - set the restart time of the bos server
3056 * IN serverHandle - a previously opened serverHandle.
3058 * IN type - specifies either weekly restart or daily restart time.
3060 * IN time - the time to begin restarts.
3064 * No locks are obtained or released by this function
3068 * Returns != 0 upon successful completion.
3072 int ADMINAPI bos_ExecutableRestartTimeSet(
3073 const void *serverHandle,
3075 bos_RestartTime_t time,
3079 afs_status_t tst = 0;
3080 bos_server_p b_handle = (bos_server_p) serverHandle;
3081 afs_int32 restartType = 0;
3082 struct ktime restartTime;
3084 if (!isValidServerHandle(b_handle, &tst)) {
3085 goto fail_bos_ExecutableRestartTimeSet;
3088 if (type == BOS_RESTART_WEEKLY) {
3094 if ((time.mask & BOS_RESTART_TIME_HOUR) &&
3095 ((time.hour < 0) || (time.hour > 23))) {
3096 tst = ADMBOSHOURINVALID;
3097 goto fail_bos_ExecutableRestartTimeSet;
3100 if ((time.mask & BOS_RESTART_TIME_MINUTE) &&
3101 ((time.min < 0) || (time.min > 60))) {
3102 tst = ADMBOSMINUTEINVALID;
3103 goto fail_bos_ExecutableRestartTimeSet;
3106 if ((time.mask & BOS_RESTART_TIME_SECOND) &&
3107 ((time.sec < 0) || (time.sec > 60))) {
3108 tst = ADMBOSSECONDINVALID;
3109 goto fail_bos_ExecutableRestartTimeSet;
3112 if ((time.mask & BOS_RESTART_TIME_DAY) &&
3113 ((time.day < 0) || (time.day > 6))) {
3114 tst = ADMBOSDAYINVALID;
3115 goto fail_bos_ExecutableRestartTimeSet;
3118 restartTime.mask = time.mask;
3119 restartTime.hour = time.hour;
3120 restartTime.min = time.min;
3121 restartTime.sec = time.sec;
3122 restartTime.day = time.day;
3124 tst = BOZO_SetRestartTime(b_handle->server, restartType, &restartTime);
3130 fail_bos_ExecutableRestartTimeSet:
3139 * bos_ExecutableRestartTimeGet - get the restart time of the bos server
3144 * IN serverHandle - a previously opened serverHandle.
3146 * IN type - specifies either weekly restart or daily restart time.
3148 * OUT timeP - the time to begin restarts.
3152 * No locks are obtained or released by this function
3156 * Returns != 0 upon successful completion.
3160 int ADMINAPI bos_ExecutableRestartTimeGet(
3161 const void *serverHandle,
3163 bos_RestartTime_p timeP,
3167 afs_status_t tst = 0;
3168 bos_server_p b_handle = (bos_server_p) serverHandle;
3169 afs_int32 restartType = 0;
3170 struct ktime restartTime;
3172 if (!isValidServerHandle(b_handle, &tst)) {
3173 goto fail_bos_ExecutableRestartTimeGet;
3176 if (timeP == NULL) {
3177 tst = ADMBOSTIMEPNULL;
3178 goto fail_bos_ExecutableRestartTimeGet;
3181 if (type == BOS_RESTART_WEEKLY) {
3187 tst = BOZO_GetRestartTime(b_handle->server, restartType, &restartTime);
3190 goto fail_bos_ExecutableRestartTimeGet;
3193 timeP->mask = restartTime.mask;
3194 timeP->hour = restartTime.hour;
3195 timeP->min = restartTime.min;
3196 timeP->sec = restartTime.sec;
3197 timeP->day = restartTime.day;
3200 fail_bos_ExecutableRestartTimeGet:
3209 * bos_LogGet - get a log file from the bos server machine.
3213 * IN serverHandle - a previously opened serverHandle.
3215 * IN log - the log file to retrieve.
3217 * IN/OUT logBufferSizeP - the length of the logData buffer on input,
3218 * and upon successful completion, the length of data stored in the buffer.
3220 * OUT logData - the retrieved data upon successful completion.
3224 * No locks are obtained or released by this function
3228 * Returns != 0 upon successful completion.
3232 int ADMINAPI bos_LogGet(
3233 const void *serverHandle,
3235 unsigned long *logBufferSizeP,
3240 afs_status_t tst = 0;
3241 bos_server_p b_handle = (bos_server_p) serverHandle;
3242 struct rx_call *tcall = NULL;
3246 unsigned long bytes_read = 0;
3249 * Validate parameters
3252 if (!isValidServerHandle(b_handle, &tst)) {
3253 goto fail_bos_LogGet;
3256 if ((log == NULL) || (*log == 0)) {
3257 tst = ADMBOSLOGNULL;
3258 goto fail_bos_LogGet;
3261 if (logBufferSizeP == NULL) {
3262 tst = ADMBOSLOGBUFFERSIZEPNULL;
3263 goto fail_bos_LogGet;
3266 if (logData == NULL) {
3267 tst = ADMBOSLOGDATANULL;
3268 goto fail_bos_LogGet;
3272 * Begin to retrieve the data
3275 tcall = rx_NewCall(b_handle->server);
3277 tst = StartBOZO_GetLog(tcall, log);
3280 goto fail_bos_LogGet;
3284 * Read the log file data
3288 error = rx_Read(tcall, &buffer, 1);
3290 tst = ADMBOSLOGFILEERROR;
3291 goto fail_bos_LogGet;
3295 * check for the end of the log
3299 *logBufferSizeP = bytes_read;
3304 * We've successfully read another byte, copy it to logData
3309 if (bytes_read <= *logBufferSizeP) {
3310 *logData++ = buffer;
3322 rx_EndCall(tcall, 0);
3332 * bos_AuthSet - set the authorization level required at the bos server.
3336 * IN serverHandle - a previously opened serverHandle.
3338 * IN auth - specifies the new auth level.
3342 * No locks are obtained or released by this function
3346 * Returns != 0 upon successful completion.
3350 int ADMINAPI bos_AuthSet(
3351 const void *serverHandle,
3356 afs_status_t tst = 0;
3357 bos_server_p b_handle = (bos_server_p) serverHandle;
3358 afs_int32 level = 0;
3360 if (!isValidServerHandle(b_handle, &tst)) {
3361 goto fail_bos_AuthSet;
3364 if (auth == BOS_AUTH_REQUIRED) {
3370 tst = BOZO_SetNoAuthFlag(b_handle->server, level);
3385 * bos_CommandExecute - execute a command at the bos server.
3389 * IN serverHandle - a previously opened serverHandle.
3391 * IN command - the command to execute.
3395 * No locks are obtained or released by this function
3399 * Returns != 0 upon successful completion.
3403 int ADMINAPI bos_CommandExecute(
3404 const void *serverHandle,
3405 const char *command,
3409 afs_status_t tst = 0;
3410 bos_server_p b_handle = (bos_server_p) serverHandle;
3412 if (!isValidServerHandle(b_handle, &tst)) {
3413 goto fail_bos_CommandExecute;
3416 if ((command == NULL) || (*command == 0)) {
3417 tst = ADMBOSCOMMANDNULL;
3418 goto fail_bos_CommandExecute;
3421 tst = BOZO_Exec(b_handle->server, command);
3427 fail_bos_CommandExecute:
3436 * bos_Salvage - perform a remote salvage operation.
3440 * IN cellHandle - a previously opened cellHandle.
3442 * IN serverHandle - a previously opened serverHandle.
3444 * IN partitionName - the partition to salvage. Can be null.
3446 * IN volumeName - the volume to salvage. Can be null, if non-null,
3447 * partitionName cannot be null.
3449 * IN numSalvagers - the number of salvage processes to run in parallel.
3451 * IN tmpDir - directory to place temporary files. Can be null.
3453 * IN logFile - file where salvage log will be written. Can be null.
3455 * IN force - sets salvager -force flag.
3457 * IN salvageDamagedVolumes - sets salvager -oktozap flag.
3459 * IN writeInodes - sets salvager -inodes flag.
3461 * IN writeRootInodes - sets salvager -rootinodes flag.
3463 * IN forceDirectory - sets salvager -salvagedirs flag.
3465 * IN forceBlockRead - sets salvager -blockread flag.
3469 * No locks are obtained or released by this function
3473 * Returns != 0 upon successful completion.
3477 #define INITIAL_LOG_LEN 4096
3479 int ADMINAPI bos_Salvage(
3480 const void *cellHandle,
3481 const void *serverHandle,
3482 const char *partitionName,
3483 const char *volumeName,
3486 const char *logFile,
3488 bos_SalvageDamagedVolumes_t salvageDamagedVolumes,
3489 bos_WriteInodes_t writeInodes,
3490 bos_WriteRootInodes_t writeRootInodes,
3491 bos_ForceDirectory_t forceDirectory,
3492 bos_ForceBlockRead_t forceBlockRead,
3496 afs_status_t tst = 0;
3497 bos_server_p b_handle = (bos_server_p) serverHandle;
3498 afs_cell_handle_p c_handle = (afs_cell_handle_p) cellHandle;
3499 int have_partition = 0;
3500 int have_volume = 0;
3501 unsigned int part = 0;
3502 int try_to_stop_fileserver = 0;
3503 bos_ProcessType_t procType;
3504 bos_ProcessInfo_t procInfo;
3506 char command[BOS_MAX_NAME_LEN];
3507 int command_len = 0;
3509 char *logData = NULL;
3510 unsigned long logLen = INITIAL_LOG_LEN;
3513 * Validate arguments
3516 if (!IsValidCellHandle(c_handle, &tst)) {
3517 goto fail_bos_Salvage;
3520 if (!isValidServerHandle(b_handle, &tst)) {
3521 goto fail_bos_Salvage;
3524 if (c_handle->vos_valid == 0) {
3525 tst = ADMBOSCELLHANDLENOVOS;
3526 goto fail_bos_Salvage;
3529 if ((partitionName != NULL) && (*partitionName != 0)) {
3530 if (!vos_PartitionNameToId(partitionName, &part, &tst)) {
3531 goto fail_bos_Salvage;
3536 if ((volumeName != NULL) && (*volumeName != 0)) {
3537 if (!have_partition) {
3538 tst = ADMBOSSALVAGEVOLUME;
3539 goto fail_bos_Salvage;
3544 if ((logFile != NULL) && (*logFile != 0)) {
3545 log = fopen(logFile, "w");
3547 tst = ADMBOSSALVAGEBADLOG;
3548 goto fail_bos_Salvage;
3553 * If we are salvaging more than a single volume, stop the fileserver
3557 try_to_stop_fileserver = 1;
3561 * Only try to stop the fileserver if it is running
3564 if (try_to_stop_fileserver) {
3565 if (bos_ProcessInfoGet(serverHandle, "fs", &procType, &procInfo,
3567 if (procInfo.processGoal != BOS_PROCESS_RUNNING) {
3568 try_to_stop_fileserver = 0;
3574 * Make the call to stop the fileserver and wait for it to shutdown
3577 if (try_to_stop_fileserver) {
3578 if (!bos_ProcessExecutionStateSetTemporary(serverHandle, "fs",
3579 BOS_PROCESS_STOPPED,
3581 goto fail_bos_Salvage;
3583 bos_ProcessAllWaitTransition(serverHandle, &tst);
3587 * Create the salvage command line arguments
3590 command_len = sprintf(command, "%s ",
3591 AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH);
3592 if (have_partition) {
3593 command_len += sprintf(&command[command_len], "-partition %s ",
3598 command_len += sprintf(&command[command_len], "-volumeid %s ",
3602 if (salvageDamagedVolumes == BOS_DONT_SALVAGE_DAMAGED_VOLUMES) {
3603 command_len += sprintf(&command[command_len], "-nowrite ");
3606 if (writeInodes == BOS_SALVAGE_WRITE_INODES) {
3607 command_len += sprintf(&command[command_len], "-inodes ");
3610 if (force == VOS_FORCE) {
3611 command_len += sprintf(&command[command_len], "-force ");
3614 if (writeRootInodes == BOS_SALVAGE_WRITE_ROOT_INODES) {
3615 command_len += sprintf(&command[command_len], "-rootinodes ");
3618 if (forceDirectory == BOS_SALVAGE_FORCE_DIRECTORIES) {
3619 command_len += sprintf(&command[command_len], "-salvagedirs ");
3622 if (forceBlockRead == BOS_SALVAGE_FORCE_BLOCK_READS) {
3623 command_len += sprintf(&command[command_len], "-blockreads ");
3626 command_len += sprintf(&command[command_len], "-parallel %d ", numSalvagers);
3628 if ((tmpDir != NULL) && (*tmpDir != 0)) {
3629 command_len += sprintf(&command[command_len], "-tmpdir %s ", tmpDir);
3632 if (command_len > BOS_MAX_NAME_LEN) {
3633 tst = ADMBOSSALVAGEBADOPTIONS;
3634 goto fail_bos_Salvage;
3638 * Create the process at the bosserver and wait until it completes
3641 if (!bos_ProcessCreate(serverHandle, "salvage-tmp", BOS_PROCESS_CRON,
3642 command, "now", 0, &tst)) {
3643 goto fail_bos_Salvage;
3646 while ((poll_rc = bos_ProcessInfoGet(serverHandle, "salvage-tmp", &procType,
3647 &procInfo, &tst))) {
3651 if (tst != BZNOENT) {
3652 goto fail_bos_Salvage;
3656 * Print out the salvage log if required by the user
3661 logData = (char *) malloc(INITIAL_LOG_LEN);
3664 goto fail_bos_Salvage;
3667 while(!bos_LogGet(serverHandle,
3668 AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH,
3669 &logLen, logData, &tst)) {
3670 if (logLen > INITIAL_LOG_LEN) {
3671 logData = (char *) realloc(logData, (logLen + (logLen / 10)));
3672 if (logData == NULL) {
3674 goto fail_bos_Salvage;
3677 goto fail_bos_Salvage;
3680 fprintf(log, "SalvageLog:\n%s", logData);
3684 * Restart the fileserver if we had stopped it previously
3687 if (try_to_stop_fileserver) {
3688 try_to_stop_fileserver = 0;
3689 if (!bos_ProcessExecutionStateSetTemporary(serverHandle, "fs",
3690 BOS_PROCESS_RUNNING,
3692 goto fail_bos_Salvage;
3703 if (logData != NULL) {
3707 if (try_to_stop_fileserver) {
3708 bos_ProcessExecutionStateSetTemporary(serverHandle, "fs",
3709 BOS_PROCESS_RUNNING, 0);