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 <afs/param.h>
11 #include <afsconfig.h>
15 #include "lockprocs.h"
24 /* Finds an index in VLDB entry that matches the volume type, server, and partition.
25 * If type is zero, will match first index of ANY type (RW, BK, or RO).
26 * If server is zero, will match first index of ANY server and partition
27 * Zero is a valid partition field.
30 afs_cell_handle_p cellHandle,
31 struct nvldbentry *entry,
40 for (e=0; (e < entry->nServers) && !tst ; e++) {
41 if (!type || (entry->serverFlags[e] & type)) {
42 VLDB_IsSameAddrs(cellHandle, entry->serverNumber[e], server,
44 if ((!server || (entry->serverPartition[e] == part)) &&
48 if (type == ITSRWVOL) {
49 /* quit when we are looking for RW entry (there's only 1) */
55 if (e >= entry->nServers) {
56 return -1; /* Didn't find it */
59 return e; /* return the index */
62 /* Changes the rw site only */
63 static void SetAValue (
64 afs_cell_handle_p cellHandle,
65 struct nvldbentry *entry,
74 e = FindIndex(cellHandle, entry, oserver, opart, type);
76 return; /* If didn't find it, just return */
78 entry->serverNumber[e] = nserver;
79 entry->serverPartition[e] = npart;
81 /* Now move rest of entries up */
82 if ((nserver == 0L) && (npart == 0L)) {
83 for (e++; e<entry->nServers; e++) {
84 entry->serverNumber[e-1] = entry->serverNumber[e];
85 entry->serverPartition[e-1] = entry->serverPartition[e];
86 entry->serverFlags[e-1] = entry->serverFlags[e];
91 /* Changes the RW site only */
93 afs_cell_handle_p cellHandle,
94 struct nvldbentry *entry,
100 SetAValue (cellHandle, entry, oserver, opart, nserver, npart, ITSRWVOL);
103 /* Changes the RO site only */
105 afs_cell_handle_p cellHandle,
106 struct nvldbentry *entry,
112 SetAValue (cellHandle, entry, oserver, opart, nserver, npart, ITSROVOL);
115 /* Returns success if this server and partition matches the RW entry */
117 afs_cell_handle_p cellHandle,
118 struct nvldbentry *entry,
123 if (FindIndex(cellHandle, entry, server, part, ITSRWVOL) == -1)
128 /* Return the index of the RO entry (plus 1) if it exists, else return 0 */
130 afs_cell_handle_p cellHandle,
131 struct nvldbentry *entry,
136 return (FindIndex(cellHandle, entry,server,part,ITSROVOL) + 1);
139 /* Return the index of the RW entry if it exists, else return -1 */
141 afs_cell_handle_p cellHandle,
142 struct nvldbentry *entry,
145 return (FindIndex(cellHandle, entry,0,0,ITSRWVOL));
148 /*initialize queue pointed by <ahead>*/
153 ahead->next = (struct aqueue *)0;
156 /*add <elem> in front of queue <ahead> */
163 if(ahead->count == 0) {
166 elem->next = (struct aqueue *)0;
180 struct aqueue **elem,
186 while(cptr != (struct aqueue *)0) {
187 if(cptr->ids[RWVOL] == id) {
198 /*return the element in the beginning of the queue <ahead>, free
199 *the space used by that element . <success> indicates if enumeration was ok*/
209 if(ahead->count > 0) {/*more elements left */
212 ahead->next = ahead->next->next;
213 strncpy(elem->name,temp->name,VOLSER_OLDMAXVOLNAME);
214 for(i= 0; i < 3; i++){
215 elem->ids[i] = temp->ids[i];
216 elem->copyDate[i] = temp->copyDate[i];
217 elem->isValid[i] = temp->isValid[i];
219 elem->next = (struct aqueue *)0;
223 else /*queue is empty*/