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>
15 #include <sys/types.h>
19 #include <netinet/in.h>
21 #include <sys/socket.h>
27 #include <afs/com_err.h>
29 #include <afs/bubasics.h>
30 #include <afs/tcdata.h>
32 #include <afs/budb_client.h>
33 #include <afs/bucoord_prototypes.h>
34 #include "butc_internal.h"
36 #include "error_macros.h"
37 #include "butc_xbsa.h"
38 /* tape coordinator - task status management */
39 extern afs_int32 xbsaType;
42 struct Lock statusQueueLock;
43 struct Lock cmdLineLock;
46 * get the status of a task
48 * taskId - task for which status required
50 * statusPtr - filled in with task status
54 STC_GetStatus(struct rx_call *call, afs_uint32 taskId,
55 struct tciStatusS *statusPtr)
60 if (callPermitted(call) == 0)
61 return (TC_NOTPERMITTED);
64 ptr = findStatus(taskId);
66 /* strcpy(statusPtr->status, ptr->status); */
68 strcpy(statusPtr->taskName, ptr->taskName);
69 strcpy(statusPtr->volumeName, ptr->volumeName);
70 statusPtr->taskId = ptr->taskId;
71 statusPtr->flags = ptr->flags;
72 statusPtr->nKBytes = ptr->nKBytes;
73 statusPtr->dbDumpId = ptr->dbDumpId;
74 statusPtr->lastPolled = ptr->lastPolled;
75 statusPtr->volsFailed = ptr->volsFailed;
76 ptr->lastPolled = time(0);
78 retval = TC_NODENOTFOUND;
85 STC_EndStatus(struct rx_call *call, afs_uint32 taskId)
90 if (callPermitted(call) == 0)
91 return (TC_NOTPERMITTED);
94 ptr = findStatus(taskId);
98 deleteStatusNode(ptr);
100 retval = TC_NODENOTFOUND;
106 STC_RequestAbort(struct rx_call *call, afs_uint32 taskId)
111 if (callPermitted(call) == 0)
112 return (TC_NOTPERMITTED);
115 ptr = findStatus(taskId);
117 ptr->flags |= ABORT_REQUEST;
119 retval = TC_NODENOTFOUND;
125 * Get status of all tasks on the butc, successively. Initial call
126 * should come in with TSK_STAT_FIRST flag set to initialize the
129 * taskId - specifies the task whose status is to be returned
130 * (unless TSK_STAT_FIRST set in which case it is ignored)
132 * taskId - id of next task in the list
133 * flags - TSK_STAT_END will be set when one reaches the end of
134 * the task list. taskId is not updated in this case.
137 * TC_NOTASKS - no tasks active
141 STC_ScanStatus(struct rx_call *call, afs_uint32 *taskId,
142 struct tciStatusS *statusPtr, afs_uint32 *flags)
147 if (callPermitted(call) == 0)
148 return (TC_NOTPERMITTED);
153 *flags |= TSK_STAT_XBSA;
154 if (xbsaType == XBSA_SERVER_TYPE_ADSM)
155 *flags |= TSK_STAT_ADSM;
157 if (*flags & TSK_STAT_FIRST) {
158 /* find first status node */
159 dlqPtr = statusHead.dlq_next;
160 if (dlqPtr == &statusHead) {
161 /* no status nodes */
162 *flags |= (TSK_STAT_NOTFOUND | TSK_STAT_END);
166 ptr = (statusP) dlqPtr;
168 ptr = findStatus(*taskId);
170 /* in the event that the set of tasks has changed, just
171 * finish, letting the caller retry
174 *flags |= (TSK_STAT_NOTFOUND | TSK_STAT_END);
180 /* ptr is now set to the status node we wish to return. Determine
181 * what the next node will be
184 if (ptr->link.dlq_next == &statusHead)
185 *flags |= TSK_STAT_END;
187 *taskId = ((statusP) ptr->link.dlq_next)->taskId;
189 strcpy(statusPtr->taskName, ptr->taskName);
190 strcpy(statusPtr->volumeName, ptr->volumeName);
191 statusPtr->taskId = ptr->taskId;
192 statusPtr->flags = ptr->flags;
193 statusPtr->nKBytes = ptr->nKBytes;
194 statusPtr->lastPolled = ptr->lastPolled;
201 /* ---------------------------------
202 * misc. status management routines
203 * ---------------------------------
206 /* checkAbortByTaskId
209 * n - abort requested
213 checkAbortByTaskId(afs_uint32 taskId)
219 statusPtr = findStatus(taskId);
221 retval = statusPtr->flags & ABORT_REQUEST;
228 * For backwards compatibility. Queries flag status
235 getStatusFlag(afs_uint32 taskId, afs_uint32 flag)
241 statusPtr = findStatus(taskId);
243 retval = statusPtr->flags & flag;