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>
28 #include <afs/com_err.h>
30 #include <afs/bubasics.h>
31 #include <afs/tcdata.h>
33 #include "error_macros.h"
34 #include "butc_xbsa.h"
36 /* tape coordinator - task status management */
37 extern statusP findStatus();
38 extern afs_int32 xbsaType;
41 struct Lock statusQueueLock;
42 struct Lock cmdLineLock;
45 * get the status of a task
47 * taskId - task for which status required
49 * statusPtr - filled in with task status
53 STC_GetStatus(call, taskId, statusPtr)
56 struct tciStatusS *statusPtr;
61 if (callPermitted(call) == 0)
62 return (TC_NOTPERMITTED);
65 ptr = findStatus(taskId);
67 /* strcpy(statusPtr->status, ptr->status); */
69 strcpy(statusPtr->taskName, ptr->taskName);
70 strcpy(statusPtr->volumeName, ptr->volumeName);
71 statusPtr->taskId = ptr->taskId;
72 statusPtr->flags = ptr->flags;
73 statusPtr->nKBytes = ptr->nKBytes;
74 statusPtr->dbDumpId = ptr->dbDumpId;
75 statusPtr->lastPolled = ptr->lastPolled;
76 statusPtr->volsFailed = ptr->volsFailed;
77 ptr->lastPolled = time(0);
79 retval = TC_NODENOTFOUND;
86 STC_EndStatus(call, taskId)
93 if (callPermitted(call) == 0)
94 return (TC_NOTPERMITTED);
97 ptr = findStatus(taskId);
101 deleteStatusNode(ptr);
103 retval = TC_NODENOTFOUND;
109 STC_RequestAbort(call, taskId)
110 struct rx_call *call;
116 if (callPermitted(call) == 0)
117 return (TC_NOTPERMITTED);
120 ptr = findStatus(taskId);
122 ptr->flags |= ABORT_REQUEST;
124 retval = TC_NODENOTFOUND;
130 * Get status of all tasks on the butc, successively. Initial call
131 * should come in with TSK_STAT_FIRST flag set to initialize the
134 * taskId - specifies the task whose status is to be returned
135 * (unless TSK_STAT_FIRST set in which case it is ignored)
137 * taskId - id of next task in the list
138 * flags - TSK_STAT_END will be set when one reaches the end of
139 * the task list. taskId is not updated in this case.
142 * TC_NOTASKS - no tasks active
146 STC_ScanStatus(call, taskId, statusPtr, flags)
147 struct rx_call *call;
149 struct tciStatusS *statusPtr;
156 if (callPermitted(call) == 0)
157 return (TC_NOTPERMITTED);
162 *flags |= TSK_STAT_XBSA;
163 if (xbsaType == XBSA_SERVER_TYPE_ADSM)
164 *flags |= TSK_STAT_ADSM;
166 if (*flags & TSK_STAT_FIRST) {
167 /* find first status node */
168 dlqPtr = statusHead.dlq_next;
169 if (dlqPtr == &statusHead) {
170 /* no status nodes */
171 *flags |= (TSK_STAT_NOTFOUND | TSK_STAT_END);
175 ptr = (statusP) dlqPtr;
177 ptr = findStatus(*taskId);
179 /* in the event that the set of tasks has changed, just
180 * finish, letting the caller retry
183 *flags |= (TSK_STAT_NOTFOUND | TSK_STAT_END);
189 /* ptr is now set to the status node we wish to return. Determine
190 * what the next node will be
193 if (ptr->link.dlq_next == &statusHead)
194 *flags |= TSK_STAT_END;
196 *taskId = ((statusP) ptr->link.dlq_next)->taskId;
198 strcpy(statusPtr->taskName, ptr->taskName);
199 strcpy(statusPtr->volumeName, ptr->volumeName);
200 statusPtr->taskId = ptr->taskId;
201 statusPtr->flags = ptr->flags;
202 statusPtr->nKBytes = ptr->nKBytes;
203 statusPtr->lastPolled = ptr->lastPolled;
210 /* ---------------------------------
211 * misc. status management routines
212 * ---------------------------------
215 /* checkAbortByTaskId
218 * n - abort requested
221 checkAbortByTaskId(taskId)
227 extern statusP findStatus();
230 statusPtr = findStatus(taskId);
232 retval = statusPtr->flags & ABORT_REQUEST;
239 * For backwards compatibility. Queries flag status
246 getStatusFlag(taskId, flag)
252 extern statusP findStatus();
255 statusPtr = findStatus(taskId);
257 retval = statusPtr->flags & flag;