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>
14 #include <sys/types.h>
18 #include <netinet/in.h>
20 #include <sys/socket.h>
26 #include <afs/com_err.h>
28 #include <afs/bubasics.h>
29 #include <afs/tcdata.h>
31 #include "error_macros.h"
32 #include "butc_xbsa.h"
34 /* tape coordinator - task status management */
35 extern statusP findStatus();
36 extern afs_int32 xbsaType;
39 struct Lock statusQueueLock;
40 struct Lock cmdLineLock;
43 * get the status of a task
45 * taskId - task for which status required
47 * statusPtr - filled in with task status
51 STC_GetStatus(call, taskId, statusPtr)
54 struct tciStatusS *statusPtr;
59 if (callPermitted(call) == 0)
60 return (TC_NOTPERMITTED);
63 ptr = findStatus(taskId);
65 /* strcpy(statusPtr->status, ptr->status); */
67 strcpy(statusPtr->taskName, ptr->taskName);
68 strcpy(statusPtr->volumeName, ptr->volumeName);
69 statusPtr->taskId = ptr->taskId;
70 statusPtr->flags = ptr->flags;
71 statusPtr->nKBytes = ptr->nKBytes;
72 statusPtr->dbDumpId = ptr->dbDumpId;
73 statusPtr->lastPolled = ptr->lastPolled;
74 statusPtr->volsFailed = ptr->volsFailed;
75 ptr->lastPolled = time(0);
77 retval = TC_NODENOTFOUND;
84 STC_EndStatus(call, taskId)
91 if (callPermitted(call) == 0)
92 return (TC_NOTPERMITTED);
95 ptr = findStatus(taskId);
99 deleteStatusNode(ptr);
101 retval = TC_NODENOTFOUND;
107 STC_RequestAbort(call, taskId)
108 struct rx_call *call;
114 if (callPermitted(call) == 0)
115 return (TC_NOTPERMITTED);
118 ptr = findStatus(taskId);
120 ptr->flags |= ABORT_REQUEST;
122 retval = TC_NODENOTFOUND;
128 * Get status of all tasks on the butc, successively. Initial call
129 * should come in with TSK_STAT_FIRST flag set to initialize the
132 * taskId - specifies the task whose status is to be returned
133 * (unless TSK_STAT_FIRST set in which case it is ignored)
135 * taskId - id of next task in the list
136 * flags - TSK_STAT_END will be set when one reaches the end of
137 * the task list. taskId is not updated in this case.
140 * TC_NOTASKS - no tasks active
144 STC_ScanStatus(call, taskId, statusPtr, flags)
145 struct rx_call *call;
147 struct tciStatusS *statusPtr;
154 if (callPermitted(call) == 0)
155 return (TC_NOTPERMITTED);
160 *flags |= TSK_STAT_XBSA;
161 if (xbsaType == XBSA_SERVER_TYPE_ADSM)
162 *flags |= TSK_STAT_ADSM;
164 if (*flags & TSK_STAT_FIRST) {
165 /* find first status node */
166 dlqPtr = statusHead.dlq_next;
167 if (dlqPtr == &statusHead) {
168 /* no status nodes */
169 *flags |= (TSK_STAT_NOTFOUND | TSK_STAT_END);
173 ptr = (statusP) dlqPtr;
175 ptr = findStatus(*taskId);
177 /* in the event that the set of tasks has changed, just
178 * finish, letting the caller retry
181 *flags |= (TSK_STAT_NOTFOUND | TSK_STAT_END);
187 /* ptr is now set to the status node we wish to return. Determine
188 * what the next node will be
191 if (ptr->link.dlq_next == &statusHead)
192 *flags |= TSK_STAT_END;
194 *taskId = ((statusP) ptr->link.dlq_next)->taskId;
196 strcpy(statusPtr->taskName, ptr->taskName);
197 strcpy(statusPtr->volumeName, ptr->volumeName);
198 statusPtr->taskId = ptr->taskId;
199 statusPtr->flags = ptr->flags;
200 statusPtr->nKBytes = ptr->nKBytes;
201 statusPtr->lastPolled = ptr->lastPolled;
208 /* ---------------------------------
209 * misc. status management routines
210 * ---------------------------------
213 /* checkAbortByTaskId
216 * n - abort requested
219 checkAbortByTaskId(taskId)
225 extern statusP findStatus();
228 statusPtr = findStatus(taskId);
230 retval = statusPtr->flags & ABORT_REQUEST;
237 * For backwards compatibility. Queries flag status
244 getStatusFlag(taskId, flag)
250 extern statusP findStatus();
253 statusPtr = findStatus(taskId);
255 retval = statusPtr->flags & flag;