fe0a5c200440a0456a6eeb0f8b6e4c6a66db7572
[openafs.git] / src / libadmin / vos / afs_vosAdmin.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 OPENAFS_VOS_ADMIN_H
11 #define OPENAFS_VOS_ADMIN_H
12
13 #include <afs/param.h>
14 #include <afs/afs_Admin.h>
15 #include <sys/types.h>
16 #ifdef AFS_NT40_ENV
17 #ifndef _MFC_VER
18 #include <winsock2.h>
19 #endif /* _MFC_VER */
20 #else
21 #include <sys/socket.h>
22 #endif
23
24 #define VOS_MAX_PARTITION_NAME_LEN 32
25 #define VOS_MAX_VOLUME_NAME_LEN 32
26 #define VOS_MAX_VOLUME_TYPES 3
27 #define VOS_MAX_REPLICA_SITES 13
28 #define VOS_MAX_SERVER_ADDRESS 16
29
30 typedef enum {
31     VOS_NORMAL,
32     VOS_FORCE
33 } vos_force_t, *vos_force_p;
34
35 typedef enum {
36     VOS_INCLUDE,
37     VOS_EXCLUDE
38 } vos_exclude_t, *vos_exclude_p;
39
40 typedef enum {
41     VOS_OK,
42     VOS_SALVAGE,
43     VOS_NO_VNODE,
44     VOS_NO_VOL,
45     VOS_VOL_EXISTS,
46     VOS_NO_SERVICE,
47     VOS_OFFLINE,
48     VOS_ONLINE,
49     VOS_DISK_FULL,
50     VOS_OVER_QUOTA,
51     VOS_BUSY,
52     VOS_MOVED
53 } vos_volumeStatus_t, *vos_volumeStatus_p;
54
55 typedef enum {
56     VOS_READ_WRITE_VOLUME,
57     VOS_READ_ONLY_VOLUME,
58     VOS_BACKUP_VOLUME
59 } vos_volumeType_t, *vos_volumeType_p;
60
61 typedef struct vos_fileServerEntry {
62     int serverAddress[VOS_MAX_SERVER_ADDRESS];
63     int count;
64 } vos_fileServerEntry_t, *vos_fileServerEntry_p;
65
66 typedef enum {
67     VOS_VOLUME_READ_WRITE_STATS_SAME_NETWORK,
68     VOS_VOLUME_READ_WRITE_STATS_SAME_NETWORK_AUTHENTICATED,
69     VOS_VOLUME_READ_WRITE_STATS_DIFFERENT_NETWORK,
70     VOS_VOLUME_READ_WRITE_STATS_DIFFERENT_NETWORK_AUTHENTICATED
71 } vos_volumeReadWriteStats_t, *vos_volumeReadWriteStats_p;
72
73 #define VOS_VOLUME_READ_WRITE_STATS_NUMBER 4
74
75 typedef enum {
76     VOS_VOLUME_TIME_STATS_0_TO_60_SECONDS,
77     VOS_VOLUME_TIME_STATS_1_TO_10_MINUTES,
78     VOS_VOLUME_TIME_STATS_10_TO_60_MINUTES,
79     VOS_VOLUME_TIME_STATS_1_TO_24_HOURS,
80     VOS_VOLUME_TIME_STATS_1_TO_7_DAYS,
81     VOS_VOLUME_TIME_STATS_GREATER_THAN_7_DAYS
82 } vos_volumeTimeStats_t, *vos_volumeTimeStats_p;
83
84 #define VOS_VOLUME_TIME_STATS_NUMBER 6
85
86 typedef struct vos_volumeEntry {
87     unsigned int id;
88     unsigned int readWriteId;
89     unsigned int readOnlyId;
90     unsigned int backupId;
91     unsigned long creationDate;
92     unsigned long lastAccessDate;
93     unsigned long lastUpdateDate;
94     unsigned long lastBackupDate;
95     unsigned long copyCreationDate;
96     int accessesSinceMidnight;
97     int fileCount;
98     int maxQuota;
99     int currentSize;
100     int readStats[VOS_VOLUME_READ_WRITE_STATS_NUMBER];
101     int writeStats[VOS_VOLUME_READ_WRITE_STATS_NUMBER];
102     int fileAuthorWriteSameNetwork[VOS_VOLUME_TIME_STATS_NUMBER];
103     int fileAuthorWriteDifferentNetwork[VOS_VOLUME_TIME_STATS_NUMBER];
104     int dirAuthorWriteSameNetwork[VOS_VOLUME_TIME_STATS_NUMBER];
105     int dirAuthorWriteDifferentNetwork[VOS_VOLUME_TIME_STATS_NUMBER];
106     vos_volumeStatus_t status;
107     vos_volumeStatus_t volumeDisposition;
108     vos_volumeType_t type;
109     char name[VOS_MAX_VOLUME_NAME_LEN];
110 } vos_volumeEntry_t, *vos_volumeEntry_p;
111
112 typedef struct vos_partitionEntry {
113     char name[VOS_MAX_PARTITION_NAME_LEN];
114     char deviceName[VOS_MAX_PARTITION_NAME_LEN];
115     int lockFileDescriptor;
116     int totalSpace;
117     int totalFreeSpace;
118 } vos_partitionEntry_t, *vos_partitionEntry_p;
119
120 typedef enum {
121     VOS_VLDB_ENTRY_OK = 0x1,
122     VOS_VLDB_ENTRY_MOVE = 0x2,
123     VOS_VLDB_ENTRY_RELEASE = 0x4,
124     VOS_VLDB_ENTRY_BACKUP = 0x8,
125     VOS_VLDB_ENTRY_DELETE = 0x10,
126     VOS_VLDB_ENTRY_DUMP = 0x20,
127     VOS_VLDB_ENTRY_LOCKED = 0x40,
128     VOS_VLDB_ENTRY_RWEXISTS = 0x1000,
129     VOS_VLDB_ENTRY_ROEXISTS = 0x2000,
130     VOS_VLDB_ENTRY_BACKEXISTS = 0x4000
131 } vos_vldbEntryStatus_t, *vos_vldbEntryStatus_p;
132
133 typedef enum {
134     VOS_VLDB_NEW_REPSITE = 0x1,
135     VOS_VLDB_READ_ONLY = 0x2,
136     VOS_VLDB_READ_WRITE = 0x4,
137     VOS_VLDB_BACKUP = 0x8,
138     VOS_VLDB_DONT_USE = 0x10
139 } vos_vldbServerFlag_t, *vos_vldbServerFlag_p;
140
141 typedef struct vos_vldbEntry {
142     int numServers;
143     unsigned int volumeId[VOS_MAX_VOLUME_TYPES];
144     unsigned int cloneId;
145     vos_vldbEntryStatus_t status;
146     struct {
147         int serverAddress;
148         int serverPartition;
149         vos_vldbServerFlag_t serverFlags;
150     } volumeSites[VOS_MAX_REPLICA_SITES];
151     char name[VOS_MAX_VOLUME_NAME_LEN];
152 } vos_vldbEntry_t, *vos_vldbEntry_p;
153
154 #define VOS_PROCEDURE_NAME_LEN 30
155
156 typedef enum {
157     VOS_VOLUME_ATTACH_MODE_OK,
158     VOS_VOLUME_ATTACH_MODE_OFFLINE,
159     VOS_VOLUME_ATTACH_MODE_BUSY,
160     VOS_VOLUME_ATTACH_MODE_READONLY,
161     VOS_VOLUME_ATTACH_MODE_CREATE,
162     VOS_VOLUME_ATTACH_MODE_CREATE_VOLID
163 } vol_volumeAttachMode_t, *vol_volumeAttachMode_p;
164
165 typedef enum {
166     VOS_VOLUME_ACTIVE_STATUS_OK,
167     VOS_VOLUME_ACTIVE_STATUS_DELETE_ON_SALVAGE,
168     VOS_VOLUME_ACTIVE_STATUS_OUT_OF_SERVICE,
169     VOS_VOLUME_ACTIVE_STATUS_DELETED
170 } vos_volumeActiveStatus_t, *vos_volumeActiveStatus_p;
171
172 typedef enum {
173     VOS_VOLUME_TRANSACTION_STATUS_OK,
174     VOS_VOLUME_TRANSACTION_STATUS_DELETED
175 } vos_volumeTransactionStatus_t, *vos_volumeTransactionStatus_p;
176
177 typedef struct vos_serverTransactionStatus {
178     int transactionId;
179     int lastActiveTime;
180     int creationTime;
181     int errorCode;
182     unsigned int volumeId;
183     int partition;
184     char lastProcedureName[VOS_PROCEDURE_NAME_LEN];
185     int nextReceivePacketSequenceNumber;
186     int nextSendPacketSequenceNumber;
187     int lastReceiveTime;
188     int lastSendTime;
189     vol_volumeAttachMode_t volumeAttachMode;
190     vos_volumeActiveStatus_t volumeActiveStatus;
191     vos_volumeTransactionStatus_t volumeTransactionStatus;
192 } vos_serverTransactionStatus_t, *vos_serverTransactionStatus_p;
193
194 typedef enum {
195     VOS_RESTORE_FULL,
196     VOS_RESTORE_INCREMENTAL
197 } vos_volumeRestoreType_t, *vos_volumeRestoreType_p;
198
199 typedef enum {
200     VOS_ONLINE_BUSY,
201     VOS_ONLINE_OFFLINE
202 } vos_volumeOnlineType_t, *vos_volumeOnlineType_p;
203
204 typedef enum {
205     VOS_DEBUG_MESSAGE = 0x1,
206     VOS_ERROR_MESSAGE = 0x2,
207     VOS_VERBOSE_MESSAGE = 0x4
208 } vos_messageType_t, *vos_messageType_p;
209
210 typedef void
211   (ADMINAPI * vos_MessageCallBack_t) (vos_messageType_t type, char *message);
212
213 extern int ADMINAPI vos_BackupVolumeCreate(const void *cellHandle,
214                                            vos_MessageCallBack_t callBack,
215                                            unsigned int volumeId,
216                                            afs_status_p st);
217
218 extern int ADMINAPI vos_BackupVolumeCreateMultiple(const void *cellHandle,
219                                                    const void *serverHandle,
220                                                    vos_MessageCallBack_t
221                                                    callBack,
222                                                    const unsigned int
223                                                    *partition,
224                                                    const char *volumePrefix,
225                                                    vos_exclude_t
226                                                    excludePrefix,
227                                                    afs_status_p st);
228
229 extern int ADMINAPI vos_PartitionGet(const void *cellHandle,
230                                      const void *serverHandle,
231                                      vos_MessageCallBack_t callBack,
232                                      unsigned int partition,
233                                      vos_partitionEntry_p partitionP,
234                                      afs_status_p st);
235
236 extern int ADMINAPI vos_PartitionGetBegin(const void *cellHandle,
237                                           const void *serverHandle,
238                                           vos_MessageCallBack_t callBack,
239                                           void **iterationIdP,
240                                           afs_status_p st);
241
242 extern int ADMINAPI vos_PartitionGetNext(const void *iterationId,
243                                          vos_partitionEntry_p partitionP,
244                                          afs_status_p st);
245
246 extern int ADMINAPI vos_PartitionGetDone(const void *iterationId,
247                                          afs_status_p st);
248
249 extern int ADMINAPI vos_ServerOpen(const void *cellHandle,
250                                    const char *serverName,
251                                    void **serverHandleP, afs_status_p st);
252
253 extern int ADMINAPI vos_ServerClose(const void *serverHandle,
254                                     afs_status_p st);
255
256 extern int ADMINAPI vos_ServerSync(const void *cellHandle,
257                                    const void *serverHandle,
258                                    vos_MessageCallBack_t callBack,
259                                    const unsigned int *partition,
260                                    afs_status_p st);
261
262 extern int ADMINAPI vos_FileServerAddressChange(const void *cellHandle,
263                                                 vos_MessageCallBack_t
264                                                 callBack, int oldAddress,
265                                                 int newAddress,
266                                                 afs_status_p st);
267
268 extern int ADMINAPI vos_FileServerAddressRemove(const void *cellHandle,
269                                                 vos_MessageCallBack_t
270                                                 callBack, int serverAddress,
271                                                 afs_status_p st);
272
273 extern int ADMINAPI vos_FileServerGetBegin(const void *cellHandle,
274                                            vos_MessageCallBack_t callBack,
275                                            void **iterationIdP,
276                                            afs_status_p st);
277
278 extern int ADMINAPI vos_FileServerGetNext(void *iterationId,
279                                           vos_fileServerEntry_p serverEntryP,
280                                           afs_status_p st);
281
282 extern int ADMINAPI vos_FileServerGetDone(void *iterationId, afs_status_p st);
283
284 extern int ADMINAPI vos_ServerTransactionStatusGetBegin(const void
285                                                         *cellHandle, const void
286                                                         *serverHandle,
287                                                         vos_MessageCallBack_t
288                                                         callBack,
289                                                         void **iterationIdP,
290                                                         afs_status_p st);
291
292 extern int ADMINAPI vos_ServerTransactionStatusGetNext(const void
293                                                        *iterationId,
294                                                        vos_serverTransactionStatus_p
295                                                        serverTransactionStatusP,
296                                                        afs_status_p st);
297
298 extern int ADMINAPI vos_ServerTransactionStatusGetDone(const void
299                                                        *iterationId,
300                                                        afs_status_p st);
301
302 extern int ADMINAPI vos_VLDBGet(const void *cellHandle,
303                                 vos_MessageCallBack_t callBack,
304                                 const unsigned int *volumeId,
305                                 const char *volumeName,
306                                 vos_vldbEntry_p vldbEntry, afs_status_p st);
307
308 extern int ADMINAPI vos_VLDBGetBegin(const void *cellHandle,
309                                      const void *serverHandle,
310                                      vos_MessageCallBack_t callBack,
311                                      unsigned int *partition,
312                                      void **iterationIdP, afs_status_p st);
313
314 extern int ADMINAPI vos_VLDBGetNext(const void *iterationId,
315                                     vos_vldbEntry_p vldbEntry,
316                                     afs_status_p st);
317
318 extern int ADMINAPI vos_VLDBGetDone(const void *iterationId, afs_status_p st);
319
320 extern int ADMINAPI vos_VLDBEntryRemove(const void *cellHandle,
321                                         const void *serverHandle,
322                                         vos_MessageCallBack_t callBack,
323                                         const unsigned int *partition,
324                                         unsigned int *volumeId,
325                                         afs_status_p st);
326
327 extern int ADMINAPI vos_VLDBUnlock(const void *cellHandle,
328                                    const void *serverHandle,
329                                    vos_MessageCallBack_t callBack,
330                                    const unsigned int *partition,
331                                    afs_status_p st);
332
333 extern int ADMINAPI vos_VLDBEntryLock(const void *cellHandle,
334                                       vos_MessageCallBack_t callBack,
335                                       unsigned int volumeId, afs_status_p st);
336
337 extern int ADMINAPI vos_VLDBEntryUnlock(const void *cellHandle,
338                                         vos_MessageCallBack_t callBack,
339                                         unsigned int volumeId,
340                                         afs_status_p st);
341
342 extern int ADMINAPI vos_VLDBReadOnlySiteCreate(const void *cellHandle,
343                                                const void *serverHandle,
344                                                vos_MessageCallBack_t callBack,
345                                                unsigned int partition,
346                                                unsigned int volumeId,
347                                                afs_status_p st);
348
349 extern int ADMINAPI vos_VLDBReadOnlySiteDelete(const void *cellHandle,
350                                                const void *serverHandle,
351                                                vos_MessageCallBack_t callBack,
352                                                unsigned int partition,
353                                                unsigned int volumeId,
354                                                afs_status_p st);
355
356 extern int ADMINAPI vos_VLDBSync(const void *cellHandle,
357                                  const void *serverHandle,
358                                  vos_MessageCallBack_t callBack,
359                                  const unsigned int *partition,
360                                  vos_force_t force, afs_status_p st);
361
362 extern int ADMINAPI vos_VolumeCreate(const void *cellHandle,
363                                      const void *serverHandle,
364                                      vos_MessageCallBack_t callBack,
365                                      unsigned int partition,
366                                      const char *volumeName,
367                                      unsigned int quota,
368                                      unsigned int *volumeId, afs_status_p st);
369
370 extern int ADMINAPI vos_VolumeDelete(const void *cellHandle,
371                                      const void *serverHandle,
372                                      vos_MessageCallBack_t callBack,
373                                      unsigned int partition,
374                                      unsigned int volumeId, afs_status_p st);
375
376 extern int ADMINAPI vos_VolumeRename(const void *cellHandle,
377                                      vos_MessageCallBack_t callBack,
378                                      unsigned int readWriteVolumeId,
379                                      const char *newVolumeName,
380                                      afs_status_p st);
381
382 extern int ADMINAPI vos_VolumeDump(const void *cellHandle,
383                                    const void *serverHandle,
384                                    vos_MessageCallBack_t callBack,
385                                    unsigned int *partition,
386                                    unsigned int volumeId,
387                                    unsigned int startTime,
388                                    const char *dumpFile, afs_status_p st);
389
390 extern int ADMINAPI vos_VolumeRestore(const void *cellHandle,
391                                       const void *serverHandle,
392                                       vos_MessageCallBack_t callBack,
393                                       unsigned int partition,
394                                       unsigned int *volumeId,
395                                       const char *volumeName,
396                                       const char *dumpFile,
397                                       vos_volumeRestoreType_t dumpType,
398                                       afs_status_p st);
399
400 extern int ADMINAPI vos_VolumeOnline(const void *serverHandle,
401                                      vos_MessageCallBack_t callBack,
402                                      unsigned int partition,
403                                      unsigned int volumeId,
404                                      unsigned int sleepTime,
405                                      vos_volumeOnlineType_t volumeStatus,
406                                      afs_status_p st);
407
408 extern int ADMINAPI vos_VolumeOffline(const void *serverHandle,
409                                       vos_MessageCallBack_t callBack,
410                                       unsigned int partition,
411                                       unsigned int volumeId, afs_status_p st);
412
413 extern int ADMINAPI vos_VolumeGet(const void *cellHandle,
414                                   const void *serverHandle,
415                                   vos_MessageCallBack_t callBack,
416                                   unsigned int partition,
417                                   unsigned int volumeId,
418                                   vos_volumeEntry_p volumeP, afs_status_p st);
419
420 extern int ADMINAPI vos_VolumeGetBegin(const void *cellHandle,
421                                        const void *serverHandle,
422                                        vos_MessageCallBack_t callBack,
423                                        unsigned int partition,
424                                        void **iterationIdP, afs_status_p st);
425
426 extern int ADMINAPI vos_VolumeGetNext(const void *iterationId,
427                                       vos_volumeEntry_p volumeP,
428                                       afs_status_p st);
429
430 extern int ADMINAPI vos_VolumeGetDone(const void *iterationId,
431                                       afs_status_p st);
432
433 extern int ADMINAPI vos_VolumeMove(const void *cellHandle,
434                                    vos_MessageCallBack_t callBack,
435                                    unsigned int volumeId,
436                                    const void *fromServer,
437                                    unsigned int fromPartition,
438                                    const void *toServer,
439                                    unsigned int toPartition, afs_status_p st);
440
441 extern int ADMINAPI vos_VolumeRelease(const void *cellHandle,
442                                       vos_MessageCallBack_t callBack,
443                                       unsigned int volumeId,
444                                       vos_force_t force, afs_status_p st);
445
446 extern int ADMINAPI vos_VolumeZap(const void *cellHandle,
447                                   const void *serverHandle,
448                                   vos_MessageCallBack_t callBack,
449                                   unsigned int partition,
450                                   unsigned int volumeId, vos_force_t force,
451                                   afs_status_p st);
452
453 extern int ADMINAPI vos_PartitionNameToId(const char *partitionName,
454                                           unsigned int *partitionId,
455                                           afs_status_p st);
456
457 extern int ADMINAPI vos_PartitionIdToName(unsigned int partitionId,
458                                           char *partitionName,
459                                           afs_status_p st);
460
461 extern int ADMINAPI vos_VolumeQuotaChange(const void *cellHandle,
462                                           const void *serverHandle,
463                                           vos_MessageCallBack_t callBack,
464                                           unsigned int partition,
465                                           unsigned int volumeId,
466                                           unsigned int volumeQuota,
467                                           afs_status_p st);
468
469 #endif /* OPENAFS_VOS_ADMIN_H */