Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / bubasics / tcdata.p.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 _TCDATA_
11 #define _TCDATA_ 1
12
13 #include <afs/butc.h>
14 #include <afs/budb.h>
15 #include <afs/bubasics.h>
16 #include "butm.h"
17
18 /* node with info on each dump of interest, associated with taskID
19 * Key:
20 * G - generated by butc
21 */
22
23 struct dumpNode {
24 /* administrative fields */
25 afs_int32 taskID; /* the task id */
26 struct dumpNode *next; /* ptr to the next node on the list */
27 statusP statusNodePtr; /* status node pointer */
28
29 /* common to dumps and restores */
30 afs_int32 arraySize; /* Size of dump/restore array */
31
32 /* specific to dumps */
33 char dumpSetName[TC_MAXNAMELEN]; /* name of the dump "<volset>.<dump>" */
34 char *dumpName; /* full dump path */
35 char *volumeSetName; /* volume set */
36 struct tc_tapeSet tapeSetDesc; /* description of the tape set */
37 struct tc_dumpDesc *dumps; /* list of vols to dump */
38 afs_int32 parent; /* parent dump ID, from main call */
39 afs_int32 level; /* this dump's level, from main call */
40 int doAppend; /* Append this dump to a dump set */
41
42 /* restore specific */
43 struct tc_restoreDesc *restores; /* info needed to restore volumes */
44 };
45
46 struct deviceSyncNode {
47 struct Lock lock; /* this is used to synchronise access to tape drive */
48 afs_int32 flags;
49 };
50
51 /* flags used to monitor status of dumps/restores */
52 #define INPROGRESS 0x01 /*dump is in progress */
53 #define ABORT 0x02 /*abort this dump */
54 #define ABORTED 0x04 /*aborted this dump */
55 #define DONE 0x08 /*done with this dump */
56 #define WAITING 0x10 /*someone is waiting on this dump */
57 #define ERROR 0x20 /*error in operation */
58 #define PARTIAL 0x40 /*partial failure in operation */
59
60 /* define the opcodes */
61 #define DUMP 0x01 /*dumping */
62 #define RESTORE 0x02 /*restoring */
63
64 /*these definitions are temporary */
65 #define TCPORT 7010
66 #define TCSERVICE_ID 10
67
68 #define TC_GCTIME 300 /* the interval after which the GC is invoked */
69 #define TC_ABORTTIME 30 /*time alotted for process to respond to abort */
70 #define TC_MAXVOLNAME 64 /*this should come from VNAMESIZE in volume header */
71 /*define some magic numbers to be used with volume headers and trailors on tape */
72 #define TC_VOLBEGINMAGIC 0xb0258191 /*32 bit magic numbers */
73 #define TC_VOLENDMAGIC 0x9167345a
74 #define TC_VOLCONTD 0xffffffff
75 /*
76 #define TC_HEADERFORMAT "H++NAME#%s#ID#%u#SERVER#%x#PART#%u#FROM#%u#FRAG#%d#BM#%u#--H"
77 #define TC_TRAILORFORMAT "T--NAME#%s#ID#%u#SERVER#%x#PART#%u#FROM#%u#FRAG#%d#CONTD#%x#EM#%u#++T"
78 */
79 #define TC_TRAILERBEGIN "+=!@#$%><%$#@!=+" /*indicates that trailer follows */
80 #define TC_MAXTAPENAMELEN 100 /*dont know how to estimate these numbers */
81 #define TC_DEVICEINUSE 0x1000 /* used to indicate use of device by somebody */
82 #define TC_NULLTAPENAME "<NULL>" /* default tape name */
83 #define TC_QUOTEDNULLTAPENAME "\"<NULL>\"" /* null tapename in quotes */
84
85 /* for user prompt generation */
86 #define READOPCODE 0 /* read tape - for restore */
87 #define WRITEOPCODE 1 /* write tape - for dump */
88 #define LABELOPCODE 2 /* label a tape */
89 #define READLABELOPCODE 3 /* read tape label */
90 #define SCANOPCODE 4 /* scan tape contents */
91 #define APPENDOPCODE 5 /* append write tape - for dump */
92 #define SAVEDBOPCODE 6 /* save a database tape */
93 #define RESTOREDBOPCODE 7 /* restore a database tape */
94 #define CLOSEOPCODE 8 /* close a tape drive - for callout */
95
96 /* marker used on tape. A header is placed (as a separate block) before the
97 * volume data, and is appended (contiguously with the data) to the volume
98 * data
99 */
100 struct volumeHeader {
101 char preamble[9];
102 char postamble[9];
103 char volumeName[TC_MAXVOLNAME];
104 char pad[2];
105 afs_int32 volumeID;
106 afs_uint32 server; /* which server */
107 afs_int32 part; /* partition vol. was on */
108 afs_int32 from; /* clone date of vol ?? */
109 int frag;
110 afs_int32 magic; /* just for checking */
111 afs_int32 contd;
112 char dumpSetName[TC_MAXNAMELEN];
113 afs_int32 dumpID; /* ID of enclosing dump */
114 afs_int32 level; /* dump level, 0=full */
115 afs_int32 parentID; /* ID of parent dump */
116 afs_int32 endTime;
117 afs_int32 versionflags; /* previously spare[0] */
118 afs_int32 cloneDate; /* when this vol. was cloned */
119 afs_int32 spares[2]; /* spare used to be spare[4] */
120 };
121
122 /* Interface structure for STC_LabelTape */
123
124 struct labelTapeIf {
125 struct tc_tapeLabel label;
126 afs_uint32 taskId;
127 };
128
129 struct scanTapeIf {
130 afs_int32 addDbFlag;
131 afs_uint32 taskId;
132 };
133
134 /* Interface structure for STC_SaveDb */
135
136 struct saveDbIf {
137 Date archiveTime;
138 afs_uint32 taskId;
139 statusP statusPtr;
140 };
141
142 /* Iterface structure for STC_DeleteDump */
143 struct deleteDumpIf {
144 afs_uint32 dumpID;
145 afs_uint32 taskId;
146 };
147
148 #endif