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>
23 #include <afs/tcdata.h>
25 extern int debugLevel;
26 static struct dumpNode *dumpQHeader; /* ptr to head of the dumpNode list */
27 static struct dumpNode headNode; /* the dummy header of the node list */
28 static afs_int32 maxTaskID; /* the largest task Id allotted so far, this is never reused */
31 * allocate a dump (task) id
41 void static DisplayNode(nodePtr)
42 struct dumpNode *nodePtr;
44 TapeLog(99, nodePtr->dumpId, "Created dumpNode");
50 /* initialize the node list used to keep track of the active dumps */
51 void InitNodeList(portOffset)
54 maxTaskID = (portOffset * 1000) + 1; /* this is the first task id alotted */
57 headNode.dumps = (struct tc_dumpDesc *)0;
58 headNode.restores = (struct tc_restoreDesc *)0;
59 dumpQHeader = &headNode; /* noone in the list to start with */
63 * Create a <newNode> for the dump, put it in the list of active dumps
64 * and return a pointer to it
66 * newNode - for return ptr
68 * newNode ptr set to point to a node.
71 void CreateNode(newNode)
72 struct dumpNode **newNode;
75 *newNode = (struct dumpNode *) (malloc (sizeof (struct dumpNode)));
77 memset(*newNode, 0, sizeof(struct dumpNode));
79 (*newNode)->next = dumpQHeader->next;
80 dumpQHeader->next = *newNode;
81 (*newNode)->taskID = allocTaskId();
83 /* if (debugLevel) DisplayNode(*newNode); */
86 /* free the space allotted to the node with <taskID> */
90 struct dumpNode *oldPtr,*newPtr,*curPtr;
95 if(curPtr) newPtr = dumpQHeader->next;
98 while((!done) && (curPtr != NULL)) {
99 if(curPtr->taskID == taskID){
101 oldPtr->next = newPtr;
103 /* free the node and its structures */
104 if(curPtr->dumpName) free(curPtr->dumpName);
105 if(curPtr->volumeSetName) free(curPtr->volumeSetName);
106 if(curPtr->restores) free(curPtr->restores);
107 if(curPtr->dumps) free(curPtr->dumps);
113 if(newPtr) newPtr = newPtr->next;
121 afs_int32 GetNthNode(aindex, aresult)
123 afs_int32 *aresult; {
124 register struct dumpNode *tn;
127 tn = dumpQHeader->next;
129 if (!tn) return ENOENT;
130 /* see if this is the desired node ID */
132 *aresult = tn->taskID;
135 /* otherwise, skip to next one and keep looking */
140 /* return the node with <taskID> into <resultNode> */
141 afs_int32 GetNode(taskID, resultNode)
143 struct dumpNode **resultNode;
145 struct dumpNode *tmpPtr;
149 tmpPtr = dumpQHeader;
150 while((!done) && (tmpPtr != NULL)) {
151 if(tmpPtr->taskID == taskID) {
152 *resultNode = tmpPtr;
156 tmpPtr = tmpPtr->next;
159 else return TC_NODENOTFOUND;