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 <afs/com_err.h>
17 #include <afs/bubasics.h>
18 #include <afs/tcdata.h>
20 #include <afs/budb_client.h>
21 #include <afs/bucoord_prototypes.h>
23 #include "butc_internal.h"
24 #include "error_macros.h"
25 #include "butc_xbsa.h"
27 /* tape coordinator - task status management */
28 extern afs_int32 xbsaType;
31 struct Lock statusQueueLock;
32 struct Lock cmdLineLock;
35 * get the status of a task
37 * taskId - task for which status required
39 * statusPtr - filled in with task status
43 STC_GetStatus(struct rx_call *call, afs_uint32 taskId,
44 struct tciStatusS *statusPtr)
49 memset(statusPtr, 0, sizeof(*statusPtr));
50 if (callPermitted(call) == 0)
51 return (TC_NOTPERMITTED);
54 ptr = findStatus(taskId);
56 strcpy(statusPtr->taskName, ptr->taskName);
57 strcpy(statusPtr->volumeName, ptr->volumeName);
58 statusPtr->taskId = ptr->taskId;
59 statusPtr->flags = ptr->flags;
60 statusPtr->nKBytes = ptr->nKBytes;
61 statusPtr->dbDumpId = ptr->dbDumpId;
62 statusPtr->lastPolled = ptr->lastPolled;
63 statusPtr->volsFailed = ptr->volsFailed;
64 ptr->lastPolled = time(0);
66 retval = TC_NODENOTFOUND;
73 STC_EndStatus(struct rx_call *call, afs_uint32 taskId)
78 if (callPermitted(call) == 0)
79 return (TC_NOTPERMITTED);
82 ptr = findStatus(taskId);
86 deleteStatusNode(ptr);
88 retval = TC_NODENOTFOUND;
94 STC_RequestAbort(struct rx_call *call, afs_uint32 taskId)
99 if (callPermitted(call) == 0)
100 return (TC_NOTPERMITTED);
103 ptr = findStatus(taskId);
105 ptr->flags |= ABORT_REQUEST;
107 retval = TC_NODENOTFOUND;
113 * Get status of all tasks on the butc, successively. Initial call
114 * should come in with TSK_STAT_FIRST flag set to initialize the
117 * taskId - specifies the task whose status is to be returned
118 * (unless TSK_STAT_FIRST set in which case it is ignored)
120 * taskId - id of next task in the list
121 * flags - TSK_STAT_END will be set when one reaches the end of
122 * the task list. taskId is not updated in this case.
125 * TC_NOTASKS - no tasks active
129 STC_ScanStatus(struct rx_call *call, afs_uint32 *taskId,
130 struct tciStatusS *statusPtr, afs_uint32 *flags)
135 memset(statusPtr, 0, sizeof(*statusPtr));
136 if (callPermitted(call) == 0)
137 return (TC_NOTPERMITTED);
142 *flags |= TSK_STAT_XBSA;
143 if (xbsaType == XBSA_SERVER_TYPE_ADSM)
144 *flags |= TSK_STAT_ADSM;
146 if (*flags & TSK_STAT_FIRST) {
147 /* find first status node */
148 dlqPtr = statusHead.dlq_next;
149 if (dlqPtr == &statusHead) {
150 /* no status nodes */
151 *flags |= (TSK_STAT_NOTFOUND | TSK_STAT_END);
155 ptr = (statusP) dlqPtr;
157 ptr = findStatus(*taskId);
159 /* in the event that the set of tasks has changed, just
160 * finish, letting the caller retry
163 *flags |= (TSK_STAT_NOTFOUND | TSK_STAT_END);
169 /* ptr is now set to the status node we wish to return. Determine
170 * what the next node will be
173 if (ptr->link.dlq_next == &statusHead)
174 *flags |= TSK_STAT_END;
176 *taskId = ((statusP) ptr->link.dlq_next)->taskId;
178 strcpy(statusPtr->taskName, ptr->taskName);
179 strcpy(statusPtr->volumeName, ptr->volumeName);
180 statusPtr->taskId = ptr->taskId;
181 statusPtr->flags = ptr->flags;
182 statusPtr->nKBytes = ptr->nKBytes;
183 statusPtr->lastPolled = ptr->lastPolled;
190 /* ---------------------------------
191 * misc. status management routines
192 * ---------------------------------
195 /* checkAbortByTaskId
198 * n - abort requested
202 checkAbortByTaskId(afs_uint32 taskId)
208 statusPtr = findStatus(taskId);
210 retval = statusPtr->flags & ABORT_REQUEST;
217 * For backwards compatibility. Queries flag status
224 getStatusFlag(afs_uint32 taskId, afs_uint32 flag)
230 statusPtr = findStatus(taskId);
232 retval = statusPtr->flags & flag;