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 <afs/budb_client.h>
32 #include <afs/bucoord_prototypes.h>
33 #include "butc_internal.h"
35 #include "error_macros.h"
36 #include "butc_xbsa.h"
37 /* tape coordinator - task status management */
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(struct rx_call *call, afs_uint32 taskId,
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(struct rx_call *call, afs_uint32 taskId)
89 if (callPermitted(call) == 0)
90 return (TC_NOTPERMITTED);
93 ptr = findStatus(taskId);
97 deleteStatusNode(ptr);
99 retval = TC_NODENOTFOUND;
105 STC_RequestAbort(struct rx_call *call, afs_uint32 taskId)
110 if (callPermitted(call) == 0)
111 return (TC_NOTPERMITTED);
114 ptr = findStatus(taskId);
116 ptr->flags |= ABORT_REQUEST;
118 retval = TC_NODENOTFOUND;
124 * Get status of all tasks on the butc, successively. Initial call
125 * should come in with TSK_STAT_FIRST flag set to initialize the
128 * taskId - specifies the task whose status is to be returned
129 * (unless TSK_STAT_FIRST set in which case it is ignored)
131 * taskId - id of next task in the list
132 * flags - TSK_STAT_END will be set when one reaches the end of
133 * the task list. taskId is not updated in this case.
136 * TC_NOTASKS - no tasks active
140 STC_ScanStatus(struct rx_call *call, afs_uint32 *taskId,
141 struct tciStatusS *statusPtr, afs_uint32 *flags)
146 if (callPermitted(call) == 0)
147 return (TC_NOTPERMITTED);
152 *flags |= TSK_STAT_XBSA;
153 if (xbsaType == XBSA_SERVER_TYPE_ADSM)
154 *flags |= TSK_STAT_ADSM;
156 if (*flags & TSK_STAT_FIRST) {
157 /* find first status node */
158 dlqPtr = statusHead.dlq_next;
159 if (dlqPtr == &statusHead) {
160 /* no status nodes */
161 *flags |= (TSK_STAT_NOTFOUND | TSK_STAT_END);
165 ptr = (statusP) dlqPtr;
167 ptr = findStatus(*taskId);
169 /* in the event that the set of tasks has changed, just
170 * finish, letting the caller retry
173 *flags |= (TSK_STAT_NOTFOUND | TSK_STAT_END);
179 /* ptr is now set to the status node we wish to return. Determine
180 * what the next node will be
183 if (ptr->link.dlq_next == &statusHead)
184 *flags |= TSK_STAT_END;
186 *taskId = ((statusP) ptr->link.dlq_next)->taskId;
188 strcpy(statusPtr->taskName, ptr->taskName);
189 strcpy(statusPtr->volumeName, ptr->volumeName);
190 statusPtr->taskId = ptr->taskId;
191 statusPtr->flags = ptr->flags;
192 statusPtr->nKBytes = ptr->nKBytes;
193 statusPtr->lastPolled = ptr->lastPolled;
200 /* ---------------------------------
201 * misc. status management routines
202 * ---------------------------------
205 /* checkAbortByTaskId
208 * n - abort requested
212 checkAbortByTaskId(afs_uint32 taskId)
218 statusPtr = findStatus(taskId);
220 retval = statusPtr->flags & ABORT_REQUEST;
227 * For backwards compatibility. Queries flag status
234 getStatusFlag(afs_uint32 taskId, afs_uint32 flag)
240 statusPtr = findStatus(taskId);
242 retval = statusPtr->flags & flag;