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