volid-unsigned-int32-20090323
[openafs.git] / src / volser / volint.xg
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 /*
11  *  Module:         Volint.xg
12  *  System:         Volser
13  *  Instituition:           ITC, CMU
14  *  Date:                   December, 88
15  */
16
17 package AFSVol
18 prefix S
19 statindex 16
20
21 #define     VOLCREATEVOLUME     100
22 #define     VOLDELETEVOLUME     101
23 #define     VOLRESTORE          102
24 #define     VOLFORWARD          103
25 #define     VOLENDTRANS         104
26 #define     VOLCLONE            105
27 #define     VOLSETFLAGS         106
28 #define     VOLGETFLAGS         107
29 #define     VOLTRANSCREATE      108
30 #define     VOLDUMP             109
31 #define     VOLGETNTHVOLUME     110
32 #define     VOLSETFORWARDING    111  /* defunct */
33 #define     VOLGETNAME          112
34 #define     VOLGETSTATUS        113
35 #define             VOLSIGRESTORE       114
36 #define     VOLLISTPARTITIONS   115
37 #define     VOLLISTVOLS         116
38 #define             VOLSETIDSTYPES      117
39 #define             VOLMONITOR          118
40 #define             VOLDISKPART 119
41 #define         VOLRECLONE      120
42 #define     VOLLISTONEVOL       121
43 #define         VOLNUKE         122
44 #define         VOLSETDATE      123
45 #define         VOLXLISTVOLS    124
46 #define         VOLXLISTONEVOL  125
47 #define     VOLSETINFO          126
48 #define     VOLXLISTPARTITIONS  127
49 #define     VOLFORWARDMULTIPLE  128
50 #define     VOLCONVERTRO        65536
51 #define     VOLGETSIZE          65537
52 #define     VOLDUMPV2           65538
53 #define     VOLDISKPART64       65539
54
55 /* Bits for flags for DumpV2 */
56 %#define     VOLDUMPV2_OMITDIRS 1
57
58 const SIZE = 1024;
59
60 struct volser_status {
61         afs_uint32 volID;               /* Volume id--unique over all systems */
62         afs_int32 nextUnique;           /* Next vnode uniquifier for this volume */
63         int type;                       /* readwrite, etc. */
64         afs_uint32 parentID;            /* Id of parent, if type==readonly or backup */
65         afs_uint32 cloneID;             /* Latest read-only clone, if type==readwrite */
66         afs_uint32 backupID;            /* Latest backup copy of this read write volume */
67         afs_uint32 restoredFromID;      /* The id in a dump this volume was restored from--used simply
68                                    to make sure that an incremental dump is not restored on top
69                                    of something inappropriate:  Note:  this field itself is NEVER
70                                    dumped!!! */
71         afs_int32 maxQuota;             /* Quota maximum, 1K blocks */
72         afs_int32 minQuota;             /* Quota minimum, 1K blocks */
73         afs_int32 owner;                /* The person responsible for this volume */
74         afs_int32 creationDate;         /* Creation date for a read/write
75                                    volume; cloning date for original copy of
76                                    a readonly volume (replicated volumes have
77                                    the same creation date) */
78         afs_int32 accessDate;           /* Last access time by a user, large granularity */
79         afs_int32 updateDate;           /* Last modification by user */
80         afs_int32 expirationDate;               /* 0 if it never expires */
81         afs_int32 backupDate;           /* last time a backup clone was taken */
82         afs_int32 copyDate;             /* Time that this copy of this volume was created */
83 };
84
85 struct destServer {
86     afs_int32 destHost;
87     afs_int32 destPort;
88     afs_int32 destSSID;
89 };
90
91
92 struct volintInfo {
93 #define VNAMESIZE 32
94     char name[VNAMESIZE];
95     afs_uint32 volid;           /* volume's id */
96     afs_int32 type;             /* read-only, read-write, backup */
97     afs_uint32 backupID;
98     afs_uint32 parentID;
99     afs_uint32 cloneID;
100     afs_int32 status;
101     afs_int32 copyDate;
102     unsigned char inUse;
103     unsigned char needsSalvaged;
104     unsigned char destroyMe;
105     afs_int32 creationDate;
106     afs_int32 accessDate;
107     afs_int32 updateDate;
108     afs_int32 backupDate;
109     int dayUse;
110     int filecount;
111     int maxquota;
112     int size;
113     afs_int32 flags;            /* used by the backup system */
114     afs_int32 spare0;           /* Used to hold the minquota value */
115     afs_int32 spare1;           /* Used to hold the weekuse value */
116     afs_int32 spare2;           /* Used to hold volUpdateCounter */
117     afs_int32 spare3;
118 };
119
120 /*
121  * Define some values needed for the detailed volume info structure.
122  */
123 const VOLINT_STATS_NUM_RWINFO_FIELDS = 4;
124
125 const VOLINT_STATS_SAME_NET      = 0;   /*Within same site (total)*/
126 const VOLINT_STATS_SAME_NET_AUTH = 1;   /*Within same site (authenticated);
127                                           (must be 1 more than above)*/
128 const VOLINT_STATS_DIFF_NET      = 2;   /*From external site (total)*/
129 const VOLINT_STATS_DIFF_NET_AUTH = 3;   /*From external site (authenticated)
130                                           (must be 1 more than above)*/
131
132 const VOLINT_STATS_NUM_TIME_RANGES = 6;
133
134 const VOLINT_STATS_TIME_CAP_0   =     60;  /*60 seconds*/
135 const VOLINT_STATS_TIME_CAP_1   =    600;  /*10 minutes, in seconds*/
136 const VOLINT_STATS_TIME_CAP_2   =   3600;  /*1 hour, in seconds*/
137 const VOLINT_STATS_TIME_CAP_3   =  86400;  /*1 day, in seconds*/
138 const VOLINT_STATS_TIME_CAP_4   = 604800;  /*1 week, in seconds*/
139
140 const VOLINT_STATS_NUM_TIME_FIELDS = 6;
141
142 const VOLINT_STATS_TIME_IDX_0 = 0;      /*0 secs to 60 secs*/
143 const VOLINT_STATS_TIME_IDX_1 = 1;      /*1 min to 10 mins*/
144 const VOLINT_STATS_TIME_IDX_2 = 2;      /*10 mins to 60 mins*/
145 const VOLINT_STATS_TIME_IDX_3 = 3;      /*1 hr to 24 hrs*/
146 const VOLINT_STATS_TIME_IDX_4 = 4;      /*1 day to 7 days*/
147 const VOLINT_STATS_TIME_IDX_5 = 5;      /*Greater than 1 week*/
148
149 /*
150  * More detailed volume info
151  */
152 struct volintXInfo {
153     char name[VNAMESIZE];
154     afs_uint32 volid;                   /*Volume's ID*/
155     afs_int32 type;                     /*RWVOL, ROVOL, BACKVOL*/
156     afs_uint32 backupID;                /*Backup volume ID*/
157     afs_uint32 parentID;                /*Parent volume ID*/
158     afs_uint32 cloneID;         /*Clone volume ID*/
159     afs_int32 status;           /*Volume status*/
160     afs_int32 copyDate;         /*Date when this volume INSTANCE created*/
161     unsigned char inUse;        /*In use at time of last crash?*/
162     afs_int32 creationDate;             /*Date when this volume was created*/
163     afs_int32 accessDate;               /*Date when this volume was last accessed*/
164     afs_int32 updateDate;               /*Date when this volume was last updated*/
165     afs_int32 backupDate;               /*Date when this volume was last backed up*/
166     int dayUse;                 /*Number of accesses since midnight*/
167     int filecount;              /*Number of files in the volume*/
168     int maxquota;               /*Max volume quota, in Kbytes*/
169     int size;                   /*Current size in Kbytes*/
170     /*
171      * Detailed statistics for reads/writes and authorship.
172      */
173     afs_int32 stat_reads[VOLINT_STATS_NUM_RWINFO_FIELDS];
174     afs_int32 stat_writes[VOLINT_STATS_NUM_RWINFO_FIELDS];
175     afs_int32 stat_fileSameAuthor[VOLINT_STATS_NUM_TIME_FIELDS];
176     afs_int32 stat_fileDiffAuthor[VOLINT_STATS_NUM_TIME_FIELDS];
177     afs_int32 stat_dirSameAuthor[VOLINT_STATS_NUM_TIME_FIELDS];
178     afs_int32 stat_dirDiffAuthor[VOLINT_STATS_NUM_TIME_FIELDS];
179 };
180
181 struct transDebugInfo {
182         afs_int32 tid;           /*transaction id */
183         afs_int32 time;  /* time transaction was last active (for timeouts) */
184         afs_int32 creationTime;    /* time the transaction started */
185         afs_int32 returnCode;       /* transaction error code */
186         afs_uint32 volid;       /*sequence number of the next packet to be read*/ /* open volume's id */
187         afs_int32 partition;        /* open volume's partition */
188         short iflags;       /* initial attach mode flags (IT*) */
189         char vflags;        /* current volume status flags (VT*) */
190         char tflags;        /* transaction flags (TT*) */
191         char lastProcName[30];  /* name of the last procedure which used transaction */
192         int callValid;  /*flag which determines if following data is valid*/
193         afs_int32 readNext;     /*sequence number of the next packet to be read*/
194         afs_int32 transmitNext; /*sequence number of the next packet to be transmitted*/
195         int lastSendTime;
196         int lastReceiveTime;
197 };
198
199 struct pIDs {
200         afs_int32 partIds[26];
201 };
202
203 struct diskPartition {
204          char   name[32];       /* Mounted partition name */
205          char   devName[32];    
206          int    lock_fd;
207         int     totalUsable;
208         int     free;
209         int     minFree;
210
211 };
212
213 struct diskPartition64 {
214     char        name[256];      /* Mounted partition name */
215     char        devName[256];   
216     int         lock_fd;
217     afs_int64   totalUsable;
218     afs_int64   free;
219     afs_int64   minFree;
220
221 };
222
223 struct restoreCookie {
224         char name[32];
225         afs_int32 type;
226         afs_uint32 clone;
227         afs_uint32 parent;
228 };
229
230 struct replica {
231         afs_int32 trans;
232         struct destServer server;
233 };
234
235 /*  Various size parameters of the volume  */
236 struct volintSize {
237     afs_uint64 dump_size;
238 };
239
240 typedef  replica manyDests<>;
241 typedef  afs_int32 manyResults<>;
242 typedef  transDebugInfo transDebugEntries<>;
243 typedef  volintInfo volEntries<>;
244 typedef  afs_int32 partEntries<>;
245 typedef  volintXInfo volXEntries<>;
246
247 proc CreateVolume(
248   IN afs_int32 partition,
249   string name<>,
250   IN afs_int32 type,
251   IN afs_uint32 parent,
252   INOUT afs_uint32 *volid,
253   OUT afs_int32 *trans
254 ) = VOLCREATEVOLUME;
255
256 proc DeleteVolume(
257   IN afs_int32 trans
258 ) = VOLDELETEVOLUME;
259
260 proc Restore(
261   IN afs_int32 toTrans,
262   IN afs_int32 flags,
263   IN struct restoreCookie *cookie
264 ) split = VOLRESTORE;
265
266 proc Forward(
267   IN afs_int32 fromTrans,
268   IN afs_int32 fromDate,
269   IN struct destServer *destination,
270   IN afs_int32 destTrans,
271   IN struct restoreCookie *cookie
272 ) = VOLFORWARD;
273
274 proc EndTrans(
275   IN afs_int32 trans,
276   OUT afs_int32 *rcode
277 ) = VOLENDTRANS;
278
279 proc Clone(
280   IN afs_int32 trans,
281   IN afs_uint32 purgeVol,
282   IN afs_int32 newType,
283   IN string newName<>,
284   INOUT afs_uint32 *newVol
285 ) = VOLCLONE;
286
287 proc SetFlags(
288   IN afs_int32 trans,
289   IN afs_int32 flags
290 ) = VOLSETFLAGS;
291
292 proc GetFlags(
293   IN afs_int32 trans,
294   OUT afs_int32 *flags
295 ) = VOLGETFLAGS;
296
297 proc TransCreate(
298   IN afs_uint32 volume,
299   IN afs_int32 partition,
300   IN afs_int32 flags,
301   OUT afs_int32 *trans
302 ) = VOLTRANSCREATE;
303
304 proc Dump(
305   IN afs_int32 fromTrans,
306   IN afs_int32 fromDate
307 ) split = VOLDUMP;
308
309 proc GetNthVolume(
310   IN afs_int32 index,
311   OUT afs_uint32 *volume,
312   OUT afs_int32 *partition
313 ) = VOLGETNTHVOLUME;
314
315 proc SetForwarding(
316   IN afs_int32 tid,
317   IN afs_int32 newsite
318 ) = VOLSETFORWARDING;
319
320 proc GetName(
321   IN afs_int32 tid,
322   OUT string tname<256>
323 ) = VOLGETNAME;
324
325 proc GetStatus(
326   IN afs_int32 tid,
327   OUT struct volser_status *status
328 ) = VOLGETSTATUS;
329
330 proc SignalRestore(
331   IN string name<>,
332   int type,
333   afs_uint32 pid,
334   afs_uint32 cloneid
335 ) = VOLSIGRESTORE;
336
337 proc ListPartitions(
338   OUT struct pIDs *partIDs
339 ) = VOLLISTPARTITIONS;
340
341 proc ListVolumes(
342   IN afs_int32 partID,
343   afs_int32 flags,
344   OUT volEntries *resultEntries
345 ) = VOLLISTVOLS;
346
347 proc SetIdsTypes(
348   IN afs_int32 tId,
349   string name<>,
350   afs_int32 type,
351   afs_uint32 pId,
352   afs_uint32 cloneId,
353   afs_uint32 backupId
354 ) = VOLSETIDSTYPES;
355
356 proc Monitor(
357   OUT transDebugEntries *result
358 ) = VOLMONITOR;
359
360 proc PartitionInfo(
361   IN string name<>,
362   OUT struct diskPartition *partition
363 ) = VOLDISKPART;
364
365 proc ReClone(
366   IN afs_int32 tid,
367   afs_uint32 cloneID
368 ) = VOLRECLONE;
369
370 proc ListOneVolume(
371   IN afs_int32 partID,
372   afs_uint32 volid,
373   OUT volEntries *resultEntries
374 ) = VOLLISTONEVOL;
375
376 proc NukeVolume(
377   IN afs_int32 partID,
378   afs_uint32 volID
379 ) = VOLNUKE;
380
381 proc SetDate(
382   IN afs_int32 tid,
383   afs_int32 newDate
384 ) = VOLSETDATE;
385
386 proc XListVolumes(
387   IN afs_int32 partID,
388   afs_int32 flags,
389   OUT volXEntries *resultXEntriesP
390 ) = VOLXLISTVOLS;
391
392 proc XListOneVolume(
393   IN afs_int32 partID,
394   afs_uint32 volid,
395   OUT volXEntries *resultXEntries
396 ) = VOLXLISTONEVOL;
397
398 proc SetInfo(
399   IN afs_int32 tid,
400   struct volintInfo *status
401 ) = VOLSETINFO;
402
403 proc XListPartitions(
404   OUT struct partEntries *partIDs
405 ) = VOLXLISTPARTITIONS;
406
407 proc ForwardMultiple(
408   IN afs_int32 fromTrans,
409   IN afs_int32 fromDate,
410   IN manyDests *destinations,
411   IN afs_int32 spare,
412   IN struct restoreCookie *cookie,
413   OUT manyResults *results
414 ) = VOLFORWARDMULTIPLE;
415
416 proc ConvertROtoRWvolume(
417   IN afs_int32 partid,
418   IN afs_uint32 volid
419 ) = VOLCONVERTRO;
420
421 proc GetSize(
422   IN afs_int32 fromTrans,
423   IN afs_int32 fromDate,
424   OUT struct volintSize *size
425 ) = VOLGETSIZE;
426
427 proc DumpV2(
428   IN afs_int32 fromTrans,
429   IN afs_int32 fromDate,
430   IN afs_int32 flags
431 ) split = VOLDUMPV2;
432
433 proc PartitionInfo64(
434     IN string name<>,
435     OUT struct diskPartition64 *partition
436 ) = VOLDISKPART64;