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