ubik-call-sucks-20060703
[openafs.git] / src / bucoord / volstub.c
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 #include <afsconfig.h>
11 #include <afs/param.h>
12
13 RCSID
14     ("$Header$");
15
16 #include <sys/types.h>
17 #include <stdio.h>
18 #ifdef AFS_NT40_ENV
19 #include <winsock2.h>
20 #else
21 #include <sys/socket.h>
22 #include <netinet/in.h>
23 #include <netdb.h>
24 #endif
25 #include <rx/xdr.h>
26 #include <afs/vlserver.h>       /*Misc server-side Volume Location stuff */
27 #include <ubik.h>
28 #include "volser.h"
29 #include "bc.h"
30 #include <afs/volint.h>
31
32 extern char *whoami;
33
34 /* ********************************************************************* */
35 /* Volserver routines */
36 /* ********************************************************************* */
37
38 afs_int32
39 bc_GetEntryByID(uclient, volID, volType, vldbEntryPtr)
40      struct ubik_client *uclient;
41      afs_int32 volID;
42      afs_int32 volType;
43      struct vldbentry *vldbEntryPtr;
44 {
45     afs_int32 code = 0;
46
47     code =
48         ubik_VL_GetEntryByID(uclient, 0, volID, volType, vldbEntryPtr);
49     return (code);
50 }
51
52 /* volImageTime
53  *      Determine the time stamp to be recorded with the backup of this
54  *      volume. For backup and r/o volumes this is the clone time, for
55  *      r/w volumes, this is the current time. This timestamp is stored
56  *      directly into the cloneDate field of the bc_volumeDump structure
57  * exit:
58  *      0 - success
59  *      -1 - failed to get information. Sets cloneDate to 0.
60  */
61
62 afs_int32
63 volImageTime(serv, part, volid, voltype, clDatePtr)
64      afs_int32 serv;
65      afs_int32 part;
66      afs_int32 volid;
67      afs_int32 voltype;
68      afs_int32 *clDatePtr;
69 {
70     afs_int32 code = 0;
71     struct volintInfo *viptr;
72
73     if (voltype == RWVOL) {
74         *clDatePtr = time(0);
75         return (0);
76     }
77
78     code = UV_ListOneVolume(htonl(serv), part, volid, &viptr);
79     if (code) {
80         com_err(whoami, code,
81                 "Warning: Can't get clone time of volume %u - using 0",
82                 volid);
83         *clDatePtr = 0;
84         return (0);
85     }
86
87     /* volume types from vol/voldefs.h */
88     switch (viptr->type) {
89     case RWVOL:
90         /* For a r/w volume there may not be any foolproof way of
91          * preventing anomalies in the backups. Use the current time;
92          */
93         *clDatePtr = time(0);
94         break;
95
96     case ROVOL:
97     case BACKVOL:
98         *clDatePtr = viptr->creationDate;       /* use the creation time */
99         break;
100
101     default:
102         com_err(whoami, 0,
103                 "Can't get clone time of volume %u - unknown volume type",
104                 volid);
105         return (-1);
106     }
107     return (0);
108 }