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