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