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 <sys/types.h>
19 #include <netinet/in.h>
21 #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
50 STC_GetStatus(call, taskId, statusPtr)
53 struct tciStatusS *statusPtr;
58 if ( callPermitted(call) == 0 )
59 return(TC_NOTPERMITTED);
62 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);
78 retval = TC_NODENOTFOUND;
84 STC_EndStatus(call, taskId )
91 if ( callPermitted(call) == 0 )
92 return(TC_NOTPERMITTED);
95 ptr = findStatus(taskId);
98 if ( ptr ) deleteStatusNode(ptr);
99 else retval = TC_NODENOTFOUND;
104 STC_RequestAbort(call, taskId )
105 struct rx_call *call;
111 if ( callPermitted(call) == 0 )
112 return(TC_NOTPERMITTED);
115 ptr = findStatus(taskId);
117 ptr->flags |= ABORT_REQUEST;
119 retval = TC_NODENOTFOUND;
125 * Get status of all tasks on the butc, successively. Initial call
126 * should come in with TSK_STAT_FIRST flag set to initialize the
129 * taskId - specifies the task whose status is to be returned
130 * (unless TSK_STAT_FIRST set in which case it is ignored)
132 * taskId - id of next task in the list
133 * flags - TSK_STAT_END will be set when one reaches the end of
134 * the task list. taskId is not updated in this case.
137 * TC_NOTASKS - no tasks active
140 STC_ScanStatus(call, taskId, statusPtr, flags)
141 struct rx_call *call;
143 struct tciStatusS *statusPtr;
150 if ( callPermitted(call) == 0 )
151 return(TC_NOTPERMITTED);
155 if (CONF_XBSA) *flags |= TSK_STAT_XBSA;
156 if (xbsaType == XBSA_SERVER_TYPE_ADSM) *flags |= TSK_STAT_ADSM;
158 if ( *flags & TSK_STAT_FIRST )
160 /* find first status node */
161 dlqPtr = statusHead.dlq_next;
162 if ( dlqPtr == &statusHead )
164 /* no status nodes */
165 *flags |= (TSK_STAT_NOTFOUND | TSK_STAT_END);
169 ptr = (statusP) dlqPtr;
173 ptr = findStatus(*taskId);
176 /* in the event that the set of tasks has changed, just
177 * finish, letting the caller retry
180 *flags |= (TSK_STAT_NOTFOUND | TSK_STAT_END);
186 /* ptr is now set to the status node we wish to return. Determine
187 * what the next node will be
190 if ( ptr->link.dlq_next == &statusHead )
191 *flags |= TSK_STAT_END;
193 *taskId = ((statusP) ptr->link.dlq_next)->taskId;
195 strcpy(statusPtr->taskName, ptr->taskName);
196 strcpy(statusPtr->volumeName, ptr->volumeName);
197 statusPtr->taskId = ptr->taskId;
198 statusPtr->flags = ptr->flags;
199 statusPtr->nKBytes = ptr->nKBytes;
200 statusPtr->lastPolled = ptr->lastPolled;
207 /* ---------------------------------
208 * misc. status management routines
209 * ---------------------------------
212 /* checkAbortByTaskId
215 * n - abort requested
218 checkAbortByTaskId(taskId)
224 extern statusP findStatus();
227 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);
256 retval = statusPtr->flags & flag;