freebsd60-20050708
[openafs.git] / src / volser / volser.p.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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
8  */
9
10 #ifndef _VOLSER_
11 #define _VOLSER_ 1
12
13 #ifdef AFS_PTHREAD_ENV
14 #include <assert.h>
15 #include <pthread.h>
16 #endif
17
18 /* vflags, representing state of the volume */
19 #define VTDeleteOnSalvage       1       /* delete on next salvage */
20 #define VTOutOfService          2       /* never put this volume online */
21 #define VTDeleted               4       /* deleted, don't do anything else */
22
23 /* iflags, representing "attach mode" for this volume at the start of this transaction */
24 #define ITOffline       1       /* volume offline on server (returns VOFFLINE) */
25 #define ITBusy          2       /* volume busy on server (returns VBUSY) */
26 #define ITReadOnly      8       /* volume readonly on client, readwrite on server -DO NOT USE */
27 #define ITCreate        0x10    /* volume does not exist correctly yet */
28 #define ITCreateVolID   0x1000  /* create volid */
29
30 /* tflags, representing transaction state */
31 #define TTDeleted       1       /* delete transaction not yet freed due  to high refCount */
32
33 /* other names for volumes in voldefs.h */
34 #define volser_RW       0
35 #define volser_RO       1
36 #define volser_BACK     2
37
38 #define THOLD(tt)       ((tt)->refCount++)
39
40 struct volser_trans {
41     struct volser_trans *next;  /* next ptr in active trans list */
42     afs_int32 tid;              /* transaction id */
43     afs_int32 time;             /* time transaction was last active (for timeouts) */
44     afs_int32 creationTime;     /* time the transaction started */
45     afs_int32 returnCode;       /* transaction error code */
46     struct Volume *volume;      /* pointer to open volume */
47     afs_int32 volid;            /* open volume's id */
48     afs_int32 partition;        /* open volume's partition */
49     afs_int32 dumpTransId;      /* other side's trans id during a dump */
50     afs_int32 dumpSeq;          /* next sequence number to use during a dump */
51     short refCount;             /* reference count on this structure */
52     short iflags;               /* initial attach mode flags (IT*) */
53     char vflags;                /* current volume status flags (VT*) */
54     char tflags;                /* transaction flags (TT*) */
55     char incremental;           /* do an incremental restore */
56     /* the fields below are useful for debugging */
57     char lastProcName[30];      /* name of the last procedure which used transaction */
58     struct rx_call *rxCallPtr;  /* pointer to latest associated rx_call */
59
60 };
61
62 /* This is how often the garbage collection thread wakes up and 
63  * checks for transactions that have timed out: BKGLoop()
64  */
65 #define GCWAKEUP            30
66
67 struct volser_dest {
68     afs_int32 destHost;
69     afs_int32 destPort;
70     afs_int32 destSSID;
71 };
72
73 #define MAXHELPERS          10
74 /* flags for vol helper busyFlags array.  First, VHIdle goes on when a server
75  * becomes idle.  Next, idle flag is cleared and VHRequest goes on when
76  * trans is queued.  Finally, VHRequest goes off (but VHIdle stays off) when
77  * helper is done.  VHIdle goes on again when an lwp waits for work.
78  */
79 #define VHIdle              1   /* vol helper is waiting for a request here */
80 #define VHRequest           2   /* a request has been queued here */
81 extern struct volser_trans *QI_GlobalWriteTrans;
82
83 /* the stuff below is from errors.h in vol directory */
84 #define VICE_SPECIAL_ERRORS     101     /* Lowest special error code */
85
86 #define VSALVAGE        101     /* Volume needs salvage */
87 #define VNOVNODE        102     /* Bad vnode number quoted */
88 #define VNOVOL          103     /* Volume not attached, doesn't exist, 
89                                  * not created or not online */
90 #define VVOLEXISTS      104     /* Volume already exists */
91 #define VNOSERVICE      105     /* Volume is not in service (i.e. it's
92                                  * is out of funds, is obsolete, or somesuch) */
93 #define VOFFLINE        106     /* Volume is off line, for the reason
94                                  * given in the offline message */
95 #define VONLINE         107     /* Volume is already on line */
96 #define VDISKFULL       108     /* Partition is "full", i.e. rougly within
97                                  * n% of full */
98 #define VOVERQUOTA      109     /* Volume max quota exceeded */
99 #define VBUSY           110     /* Volume temporarily unavailable; try again.
100                                  * The volume should be available again shortly; if
101                                  * it isn't something is wrong.  Not normally to be
102                                  * propagated to the application level */
103 #define VMOVED          111     /* Volume has moved to another server; do a VGetVolumeInfo
104                                  * to THIS server to find out where */
105
106 #define MyPort 5003
107 #define NameLen 80
108 #define VLDB_MAXSERVERS 10
109 #define VOLSERVICE_ID 4
110 #define INVALID_BID 0
111 #define VOLSER_MAXVOLNAME 65
112 #define VOLSER_OLDMAXVOLNAME 32
113 #define VOLMAXPARTS     255
114
115 /*flags used for interfacing with the  backup system */
116 struct volDescription {         /*used for interfacing with the backup system */
117     char volName[VOLSER_MAXVOLNAME];    /* should be VNAMESIZE as defined in volume.h */
118     afs_int32 volId;
119     int volSize;
120     afs_int32 volFlags;
121     afs_int32 volCloneId;
122 };
123
124 struct partList {               /*used by the backup system */
125     afs_int32 partId[VOLMAXPARTS];
126     afs_int32 partFlags[VOLMAXPARTS];
127 };
128
129 #define STDERR  stderr
130 #define STDOUT  stdout
131
132 #define ISNAMEVALID(name) (strlen(name) < (VOLSER_OLDMAXVOLNAME - 9))
133
134 /* values for flags in struct nvldbEntry */
135 #define RW_EXISTS 0x1000
136 #define RO_EXISTS 0x2000
137 #define BACK_EXISTS 0x4000
138
139 /* values for serverFlags in struct nvldbEntry */
140 #define NEW_REPSITE 0x01
141 #define ITSROVOL    0x02
142 #define ITSRWVOL    0x04
143 #define ITSBACKVOL  0x08
144 #define RO_DONTUSE  0x20
145
146 #define VLOP_RESTORE 0x100      /*this is bogus, clashes with VLOP_DUMP */
147 #define VLOP_ADDSITE 0x80       /*this is bogus, clashes with VLOP_DELETE */
148 #define PARTVALID 0x01
149 #define CLONEVALID 0x02
150 #define CLONEZAPPED 0x04
151 #define IDVALID 0x08
152 #define NAMEVALID 0x10
153 #define SIZEVALID 0x20
154 #define ENTRYVALID 0x40
155 #define REUSECLONEID 0x80
156 #define VOK 0x02
157
158 /* Values for the UV_RestoreVolume flags parameter */
159 /* Also used for UV_CopyVolume and UV_CloneVolume */
160 #define RV_FULLRST      0x00001
161 #define RV_OFFLINE      0x00002
162 #define RV_CRDUMP       0x00010
163 #define RV_CRKEEP       0x00020
164 #define RV_CRNEW        0x00040
165 #define RV_LUDUMP       0x00100
166 #define RV_LUKEEP       0x00200
167 #define RV_LUNEW        0x00400
168 #define RV_RDONLY       0x10000
169 #define RV_CPINCR       0x20000
170 #define RV_NOVLDB       0x40000
171 #define RV_NOCLONE      0x80000
172
173 struct ubik_client;
174 extern afs_uint32 vsu_GetVolumeID(char *astring, struct ubik_client *acstruct, afs_int32 *errp);
175 extern int vsu_ExtractName(char rname[], char name[]);
176 extern afs_int32 vsu_ClientInit(int noAuthFlag, char *confDir, char *cellName, afs_int32 sauth, struct ubik_client **uclientp, int (*secproc)());
177 extern void vsu_SetCrypt(int cryptflag);
178
179 #endif /* _VOLSER_ */