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>
16 #include <sys/types.h>
20 #include <netinet/in.h>
22 #include <sys/socket.h>
27 #include <afs/com_err.h>
29 #include <afs/bubasics.h>
30 #include <afs/tcdata.h>
32 #include "error_macros.h"
33 #include "butc_xbsa.h"
35 /* tape coordinator - task status management */
36 extern statusP findStatus();
37 extern afs_int32 xbsaType;
40 struct Lock statusQueueLock;
41 struct Lock cmdLineLock;
44 * get the status of a task
46 * taskId - task for which status required
48 * statusPtr - filled in with task status
52 STC_GetStatus(call, taskId, statusPtr)
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(call, taskId)
92 if (callPermitted(call) == 0)
93 return (TC_NOTPERMITTED);
96 ptr = findStatus(taskId);
100 deleteStatusNode(ptr);
102 retval = TC_NODENOTFOUND;
108 STC_RequestAbort(call, taskId)
109 struct rx_call *call;
115 if (callPermitted(call) == 0)
116 return (TC_NOTPERMITTED);
119 ptr = findStatus(taskId);
121 ptr->flags |= ABORT_REQUEST;
123 retval = TC_NODENOTFOUND;
129 * Get status of all tasks on the butc, successively. Initial call
130 * should come in with TSK_STAT_FIRST flag set to initialize the
133 * taskId - specifies the task whose status is to be returned
134 * (unless TSK_STAT_FIRST set in which case it is ignored)
136 * taskId - id of next task in the list
137 * flags - TSK_STAT_END will be set when one reaches the end of
138 * the task list. taskId is not updated in this case.
141 * TC_NOTASKS - no tasks active
145 STC_ScanStatus(call, taskId, statusPtr, flags)
146 struct rx_call *call;
148 struct tciStatusS *statusPtr;
155 if (callPermitted(call) == 0)
156 return (TC_NOTPERMITTED);
161 *flags |= TSK_STAT_XBSA;
162 if (xbsaType == XBSA_SERVER_TYPE_ADSM)
163 *flags |= TSK_STAT_ADSM;
165 if (*flags & TSK_STAT_FIRST) {
166 /* find first status node */
167 dlqPtr = statusHead.dlq_next;
168 if (dlqPtr == &statusHead) {
169 /* no status nodes */
170 *flags |= (TSK_STAT_NOTFOUND | TSK_STAT_END);
174 ptr = (statusP) dlqPtr;
176 ptr = findStatus(*taskId);
178 /* in the event that the set of tasks has changed, just
179 * finish, letting the caller retry
182 *flags |= (TSK_STAT_NOTFOUND | TSK_STAT_END);
188 /* ptr is now set to the status node we wish to return. Determine
189 * what the next node will be
192 if (ptr->link.dlq_next == &statusHead)
193 *flags |= TSK_STAT_END;
195 *taskId = ((statusP) ptr->link.dlq_next)->taskId;
197 strcpy(statusPtr->taskName, ptr->taskName);
198 strcpy(statusPtr->volumeName, ptr->volumeName);
199 statusPtr->taskId = ptr->taskId;
200 statusPtr->flags = ptr->flags;
201 statusPtr->nKBytes = ptr->nKBytes;
202 statusPtr->lastPolled = ptr->lastPolled;
209 /* ---------------------------------
210 * misc. status management routines
211 * ---------------------------------
214 /* checkAbortByTaskId
217 * n - abort requested
220 checkAbortByTaskId(taskId)
226 extern statusP findStatus();
229 statusPtr = findStatus(taskId);
231 retval = statusPtr->flags & ABORT_REQUEST;
238 * For backwards compatibility. Queries flag status
245 getStatusFlag(taskId, flag)
251 extern statusP findStatus();
254 statusPtr = findStatus(taskId);
256 retval = statusPtr->flags & flag;