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