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 | #ifndef AFS_SRC_BUBASICS_BUTM_H | |
11 | #define AFS_SRC_BUBASICS_BUTM_H | |
12 | ||
13 | #include <afs/auth.h> | |
14 | #include <afs/bubasics.h> | |
15 | ||
16 | struct blockMark { | |
17 | int count; /* actual number of bytes valid in the block */ | |
18 | afs_int32 magic; | |
19 | afs_int32 spare1; | |
20 | afs_int32 spare2; | |
21 | afs_int32 spare3; | |
22 | afs_int32 spare4; | |
23 | }; | |
24 | ||
25 | /* The size of a tapeblock is 16KB: contains header info and data */ | |
26 | #define BUTM_BLOCKSIZE 16384 | |
27 | #define BUTM_HDRSIZE ((5*sizeof(afs_int32)) + sizeof(int)) /* sizeof blockMark */ | |
28 | #define BUTM_BLKSIZE (BUTM_BLOCKSIZE - BUTM_HDRSIZE) | |
29 | ||
30 | struct butm_tapeLabel; | |
31 | ||
32 | struct butm_tapeInfo { | |
33 | afs_int32 structVersion; | |
34 | struct { | |
35 | afs_int32(*mount) (struct butm_tapeInfo *, char *); | |
36 | afs_int32(*dismount) (struct butm_tapeInfo *); | |
37 | afs_int32(*create) (struct butm_tapeInfo *, struct butm_tapeLabel *, | |
38 | afs_int32); | |
39 | afs_int32(*readLabel) (struct butm_tapeInfo *, | |
40 | struct butm_tapeLabel *, | |
41 | afs_int32); | |
42 | afs_int32(*seek) (struct butm_tapeInfo *, afs_int32); | |
43 | afs_int32(*seekEODump) (struct butm_tapeInfo *, afs_int32); | |
44 | afs_int32(*readFileBegin) (struct butm_tapeInfo *); | |
45 | afs_int32(*readFileData) (struct butm_tapeInfo *, char *, int len, | |
46 | int *); | |
47 | afs_int32(*readFileEnd) (struct butm_tapeInfo *); | |
48 | afs_int32(*writeFileBegin) (struct butm_tapeInfo *); | |
49 | afs_int32(*writeFileData) (struct butm_tapeInfo *, char *, afs_int32, | |
50 | afs_int32); | |
51 | afs_int32(*writeFileEnd) (struct butm_tapeInfo *); | |
52 | afs_int32(*writeEOT) (struct butm_tapeInfo *); | |
53 | afs_int32(*setSize) (struct butm_tapeInfo *, afs_uint32); | |
54 | afs_int32(*getSize) (struct butm_tapeInfo *, afs_uint32 *); | |
55 | } ops; | |
56 | char name[BU_MAXTAPELEN]; | |
57 | afs_int32 position; /* current position of tape */ | |
58 | afs_uint32 posCount; /* position in bytes of the tape */ | |
59 | ||
60 | /* the next three fields are used for modeling tape usage */ | |
61 | afs_uint32 nBytes; /* number of bytes written */ | |
62 | afs_uint32 kBytes; /* number of Kbytes written */ | |
63 | afs_int32 nRecords; /* number of records written */ | |
64 | afs_int32 nFiles; /* number of files written */ | |
65 | ||
66 | /* These fields provide the coefficients for the above variables */ | |
67 | afs_int32 recordSize; /* bytes per record */ | |
68 | afs_uint32 tapeSize; /* length of tape */ | |
69 | afs_int32 coefBytes; /* length multiplier for bytes */ | |
70 | afs_int32 coefRecords; /* ditto records */ | |
71 | afs_int32 coefFiles; /* ditto files */ | |
72 | int simultaneousTapes; /* number of tapes mounted simultaneously */ | |
73 | int status; /* status of tape */ | |
74 | int flags; /* e.g. read-only, sequential */ | |
75 | char *tcRock; /* for random tape coordinator storage */ | |
76 | char *tmRock; /* for random tape module storage */ | |
77 | afs_int32 sizeflags; /* What the units of tape size are. */ | |
78 | ||
79 | afs_int32 debug; /* print debugging info */ | |
80 | afs_int32 error; /* Error code from butm module */ | |
81 | afs_int32 spare[8]; | |
82 | }; | |
83 | ||
84 | struct tapeConfig { | |
85 | char device[256]; | |
86 | afs_uint32 capacity; | |
87 | afs_int32 fileMarkSize; /* size of file marks, in bytes */ | |
88 | afs_int32 portOffset; | |
89 | }; | |
90 | ||
91 | /* returns answer in bytes */ | |
92 | #define butm_remainingSpace(i) (1024*((i)->tapeSize - (1024*(i)->kBytes*(i)->coefBytes + (i)->Bytes*(i)->coefBytes ))) | |
93 | ||
94 | /* returns answer in kbytes */ | |
95 | #define butm_remainingKSpace(i) ((i)->tapeSize - ((i)->kBytes*(i)->coefBytes )) | |
96 | ||
97 | #define BUTM_STATUS_OFFLINE (1<<0) /* tape not mounted */ | |
98 | #define BUTM_STATUS_TAPEERROR (1<<1) /* tape error encountered */ | |
99 | #define BUTM_STATUS_WRITEERROR (1<<2) /* tape error during write */ | |
100 | #define BUTM_STATUS_READERROR (1<<3) /* tape error during read */ | |
101 | #define BUTM_STATUS_SEEKERROR (1<<4) /* tape error during positioning */ | |
102 | #define BUTM_STATUS_EOF (1<<5) /* tape at EOF */ | |
103 | #define BUTM_STATUS_EOD (1<<6) /* end of tape reached */ | |
104 | ||
105 | #define BUTM_FLAGS_READONLY (1<<0) /* tape mounted read-only */ | |
106 | #define BUTM_FLAGS_SEQUENTIAL (1<<1) /* tape is sequential access: sort positions */ | |
107 | ||
108 | struct butm_tapeLabel { | |
109 | afs_int32 structVersion; /* structure version number */ | |
110 | Date creationTime; /* when tape was first labeled */ | |
111 | Date expirationDate; /* when tape can be relabelled */ | |
112 | char AFSName[BU_MAXTAPELEN]; /* AFS assigned tape name */ | |
113 | struct ktc_principal creator; /* person creating tape */ | |
114 | char cell[BU_MAXCELLLEN]; /* cell which owns tape. */ | |
115 | afs_uint32 dumpid; /* which dump on this tape */ | |
116 | afs_int32 useCount; /* # times written */ | |
117 | afs_int32 spare[8]; | |
118 | char comment[96]; | |
119 | char pName[BU_MAXTAPELEN]; /* permanent user assigned tape name */ | |
120 | afs_uint32 size; | |
121 | char dumpPath[BU_MAX_DUMP_PATH]; /* dump schedule path name */ | |
122 | }; | |
123 | ||
124 | #define TNAME(labelptr) \ | |
125 | ( strcmp((labelptr)->pName,"") ? (labelptr)->pName : \ | |
126 | ( strcmp((labelptr)->AFSName,"") ? (labelptr)->AFSName : "<NULL>" ) ) | |
127 | ||
128 | #define TAPENAME(tapename, name, dbDumpId) \ | |
129 | if (!strcmp("", name)) \ | |
130 | sprintf(tapename, "<NULL>"); \ | |
131 | else if (dbDumpId == 0) \ | |
132 | sprintf(tapename, "%s", name); \ | |
133 | else \ | |
134 | sprintf(tapename, "%s (%u)", name, dbDumpId); | |
135 | ||
136 | #define LABELNAME(tapename, labelptr) \ | |
137 | TAPENAME(tapename, TNAME(labelptr), (labelptr)->dumpid) | |
138 | ||
139 | /* now the procedure macros */ | |
140 | #define butm_Mount(i,t) (*((i)->ops.mount))(i,t) | |
141 | #define butm_Dismount(i) (*((i)->ops.dismount))(i) | |
142 | #define butm_Create(i,l,r) (*((i)->ops.create))(i,l,r) | |
143 | #define butm_ReadLabel(i,l,r) (*((i)->ops.readLabel))(i,l,r) | |
144 | #define butm_Seek(i,p) (*((i)->ops.seek))(i,p) | |
145 | #define butm_SeekEODump(i,p) (*((i)->ops.seekEODump))(i,p) | |
146 | #define butm_ReadFileBegin(i) (*((i)->ops.readFileBegin))(i) | |
147 | #define butm_ReadFileData(i,d,l,n) (*((i)->ops.readFileData))(i,d,l,n) | |
148 | #define butm_ReadFileEnd(i) (*((i)->ops.readFileEnd))(i) | |
149 | #define butm_WriteFileBegin(i) (*((i)->ops.writeFileBegin))(i) | |
150 | #define butm_WriteFileData(i,d,b,l) (*((i)->ops.writeFileData))(i,d,b,l) | |
151 | #define butm_WriteFileEnd(i) (*((i)->ops.writeFileEnd))(i) | |
152 | #define butm_WriteEOT(i) (*((i)->ops.writeEOT))(i) | |
153 | #define butm_SetSize(i,s) (*((i)->ops.setSize))(i,s) | |
154 | #define butm_GetSize(i,s) (*((i)->ops.getSize))(i,s) | |
155 | ||
156 | #endif |