-/*===============================================================
- * Copyright (C) 1998 Transarc Corporation - All rights reserved
- *===============================================================*/
-
+/*
+ * Copyright 2000, International Business Machines Corporation and others.
+ * All Rights Reserved.
+ *
+ * This software has been released under the terms of the IBM Public
+ * License. For details, see the LICENSE file in the top-level source
+ * directory or online at http://www.openafs.org/dl/license10.html
+ */
+#include <afsconfig.h>
#include <afs/param.h>
-#include <sys/types.h>
-#ifdef AFS_NT40_ENV
-#include <winsock2.h>
-#else
-#include <netinet/in.h>
-#include <netdb.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <strings.h>
-#endif
-#include <stdio.h>
+
+#include <roken.h>
+
#include <afs/com_err.h>
#include <lock.h>
#include <afs/bubasics.h>
#include <afs/tcdata.h>
#include <afs/butc.h>
+#include <afs/budb_client.h>
+#include <afs/bucoord_prototypes.h>
+
+#include "butc_internal.h"
#include "error_macros.h"
#include "butc_xbsa.h"
+#include "afs/audit.h"
/* tape coordinator - task status management */
-extern statusP findStatus();
extern afs_int32 xbsaType;
-dlqlinkT statusHead;
+dlqlinkT statusHead;
struct Lock statusQueueLock;
struct Lock cmdLineLock;
+static afs_int32 SGetStatus(struct rx_call *call, afs_uint32 taskId,
+ struct tciStatusS *statusPtr);
+static afs_int32 SEndStatus(struct rx_call *call, afs_uint32 taskId);
+static afs_int32 SRequestAbort(struct rx_call *call, afs_uint32 taskId);
+static afs_int32 SScanStatus(struct rx_call *call, afs_uint32 *taskId,
+ struct tciStatusS *statusPtr, afs_uint32 *flags);
+
/* STC_GetStatus
* get the status of a task
* entry:
* statusPtr - filled in with task status
*/
-STC_GetStatus(call, taskId, statusPtr)
- struct rx_call *call;
- afs_uint32 taskId;
- struct tciStatusS *statusPtr;
+afs_int32
+STC_GetStatus(struct rx_call *call, afs_uint32 taskId,
+ struct tciStatusS *status)
+{
+ afs_int32 code;
+
+ code = SGetStatus(call, taskId, status);
+ osi_auditU(call, TC_GetStatusEvent, code,
+ AUD_INT, taskId, AUD_TSTT, status, AUD_END);
+ return code;
+}
+
+static afs_int32
+SGetStatus(struct rx_call *call, afs_uint32 taskId,
+ struct tciStatusS *statusPtr)
{
statusP ptr;
int retval = 0;
- if ( callPermitted(call) == 0 )
- return(TC_NOTPERMITTED);
+ memset(statusPtr, 0, sizeof(*statusPtr));
+ if (callPermitted(call) == 0)
+ return (TC_NOTPERMITTED);
lock_Status();
ptr = findStatus(taskId);
- if ( ptr )
- {
- /* strcpy(statusPtr->status, ptr->status); */
-
+ if (ptr) {
strcpy(statusPtr->taskName, ptr->taskName);
strcpy(statusPtr->volumeName, ptr->volumeName);
- statusPtr->taskId = ptr->taskId;
- statusPtr->flags = ptr->flags;
- statusPtr->nKBytes = ptr->nKBytes;
- statusPtr->dbDumpId = ptr->dbDumpId;
+ statusPtr->taskId = ptr->taskId;
+ statusPtr->flags = ptr->flags;
+ statusPtr->nKBytes = ptr->nKBytes;
+ statusPtr->dbDumpId = ptr->dbDumpId;
statusPtr->lastPolled = ptr->lastPolled;
statusPtr->volsFailed = ptr->volsFailed;
ptr->lastPolled = time(0);
- }
- else
+ } else
retval = TC_NODENOTFOUND;
unlock_Status();
- return(retval);
+ return (retval);
+}
+
+afs_int32
+STC_EndStatus(struct rx_call *call, afs_uint32 taskId)
+{
+ afs_int32 code;
+
+ code = SEndStatus(call, taskId);
+ osi_auditU(call, TC_EndStatusEvent, code, AUD_INT, taskId, AUD_END);
+ return code;
}
-STC_EndStatus(call, taskId )
- struct rx_call *call;
- afs_uint32 taskId;
+static afs_int32
+SEndStatus(struct rx_call *call, afs_uint32 taskId)
{
statusP ptr;
int retval = 0;
- if ( callPermitted(call) == 0 )
- return(TC_NOTPERMITTED);
+ if (callPermitted(call) == 0)
+ return (TC_NOTPERMITTED);
lock_Status();
ptr = findStatus(taskId);
unlock_Status();
- if ( ptr ) deleteStatusNode(ptr);
- else retval = TC_NODENOTFOUND;
+ if (ptr)
+ deleteStatusNode(ptr);
+ else
+ retval = TC_NODENOTFOUND;
+
+ return (retval);
+}
+
+afs_int32
+STC_RequestAbort(struct rx_call *call, afs_uint32 taskId)
+{
+ afs_int32 code;
- return(retval);
+ code = SRequestAbort(call, taskId);
+ osi_auditU(call, TC_RequestAbortEvent, code, AUD_INT, taskId, AUD_END);
+ return code;
}
-STC_RequestAbort(call, taskId )
- struct rx_call *call;
- afs_uint32 taskId;
+static afs_int32
+SRequestAbort(struct rx_call *call, afs_uint32 taskId)
{
statusP ptr;
int retval = 0;
- if ( callPermitted(call) == 0 )
- return(TC_NOTPERMITTED);
+ if (callPermitted(call) == 0)
+ return (TC_NOTPERMITTED);
lock_Status();
ptr = findStatus(taskId);
- if ( ptr )
+ if (ptr)
ptr->flags |= ABORT_REQUEST;
else
retval = TC_NODENOTFOUND;
unlock_Status();
- return(retval);
+ return (retval);
}
/* STC_ScanStatus
* TC_NOTASKS - no tasks active
*/
-STC_ScanStatus(call, taskId, statusPtr, flags)
- struct rx_call *call;
- afs_uint32 *taskId;
- struct tciStatusS *statusPtr;
- afs_uint32 *flags;
+afs_int32
+STC_ScanStatus(struct rx_call *call, afs_uint32 *taskId,
+ struct tciStatusS *status, afs_uint32 *flags)
+{
+ afs_int32 code;
+
+ code = SScanStatus(call, taskId, status, flags);
+ osi_auditU(call, TC_ScanStatusEvent, code,
+ AUD_INT, *taskId, AUD_TSTT, status, AUD_INT, *flags, AUD_END);
+ return code;
+}
+
+static afs_int32
+SScanStatus(struct rx_call *call, afs_uint32 *taskId,
+ struct tciStatusS *statusPtr, afs_uint32 *flags)
{
statusP ptr = 0;
- statusP nextPtr = 0;
dlqlinkP dlqPtr;
- if ( callPermitted(call) == 0 )
- return(TC_NOTPERMITTED);
+ memset(statusPtr, 0, sizeof(*statusPtr));
+ if (callPermitted(call) == 0)
+ return (TC_NOTPERMITTED);
lock_Status();
- if (CONF_XBSA) *flags |= TSK_STAT_XBSA;
- if (xbsaType == XBSA_SERVER_TYPE_ADSM) *flags |= TSK_STAT_ADSM;
+ if (CONF_XBSA)
+ *flags |= TSK_STAT_XBSA;
+ if (xbsaType == XBSA_SERVER_TYPE_ADSM)
+ *flags |= TSK_STAT_ADSM;
- if ( *flags & TSK_STAT_FIRST )
- {
+ if (*flags & TSK_STAT_FIRST) {
/* find first status node */
dlqPtr = statusHead.dlq_next;
- if ( dlqPtr == &statusHead )
- {
+ if (dlqPtr == &statusHead) {
/* no status nodes */
*flags |= (TSK_STAT_NOTFOUND | TSK_STAT_END);
unlock_Status();
- return(0);
+ return (0);
}
ptr = (statusP) dlqPtr;
- }
- else
- {
+ } else {
ptr = findStatus(*taskId);
- if ( ptr == 0 )
- {
+ if (ptr == 0) {
/* in the event that the set of tasks has changed, just
* finish, letting the caller retry
*/
*flags |= (TSK_STAT_NOTFOUND | TSK_STAT_END);
- unlock_Status();
- return(0);
+ unlock_Status();
+ return (0);
}
}
* what the next node will be
*/
- if ( ptr->link.dlq_next == &statusHead )
+ if (ptr->link.dlq_next == &statusHead)
*flags |= TSK_STAT_END;
else
*taskId = ((statusP) ptr->link.dlq_next)->taskId;
- strcpy(statusPtr->taskName, ptr->taskName);
+ strcpy(statusPtr->taskName, ptr->taskName);
strcpy(statusPtr->volumeName, ptr->volumeName);
- statusPtr->taskId = ptr->taskId;
- statusPtr->flags = ptr->flags;
- statusPtr->nKBytes = ptr->nKBytes;
+ statusPtr->taskId = ptr->taskId;
+ statusPtr->flags = ptr->flags;
+ statusPtr->nKBytes = ptr->nKBytes;
statusPtr->lastPolled = ptr->lastPolled;
unlock_Status();
- return(0);
+ return (0);
}
* n - abort requested
*/
-checkAbortByTaskId(taskId)
- afs_uint32 taskId;
+int
+checkAbortByTaskId(afs_uint32 taskId)
{
statusP statusPtr;
int retval = 0;
- extern statusP findStatus();
-
lock_Status();
statusPtr = findStatus(taskId);
- if ( statusPtr )
- {
+ if (statusPtr) {
retval = statusPtr->flags & ABORT_REQUEST;
}
unlock_Status();
- return(retval);
+ return (retval);
}
/* getStatusFlag
*/
afs_uint32
-getStatusFlag(taskId, flag)
- afs_uint32 taskId;
- afs_uint32 flag;
+getStatusFlag(afs_uint32 taskId, afs_uint32 flag)
{
statusP statusPtr;
int retval = 0;
- extern statusP findStatus();
lock_Status();
statusPtr = findStatus(taskId);
- if ( statusPtr )
- {
- retval = statusPtr->flags & flag;
+ if (statusPtr) {
+ retval = statusPtr->flags & flag;
}
unlock_Status();
- return(retval);
+ return (retval);
}