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