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