11 #define write faketape_write
12 #define open faketape_open
13 #define read faketape_read
14 #define close faketape_close
15 #define ioctl faketape_ioctl
16 #define debug(x) faketape_debug(x)
25 ioctl(fd, MTIOCGET, &mt_get);
26 printf("*** file:block %i:%i BOT=%u EOD=%u EOF=%u\n",
27 mt_get.mt_fileno, mt_get.mt_blkno,
28 GMT_BOT(mt_get.mt_gstat) != 0,
29 GMT_EOD(mt_get.mt_gstat) != 0,
30 GMT_EOF(mt_get.mt_gstat) != 0
34 int main(int argc, char **argv)
44 fd = open("/dev/lto2", O_CREAT | O_RDWR, 0700);
46 perror("Can't open fd");
53 printf("\n*** rewind\n");
56 r1 = ioctl(fd, MTIOCTOP, &mt_com);
60 printf("\n*** write something (3 writes)\n");
61 write(fd, "abcdefghijklmnopqrstuvwyz", strlen("abcdefghijklmnopqrstuvwyz")+1);
62 write(fd, "abcdefghijklmnopqrstuvwyz", strlen("abcdefghijklmnopqrstuvwyz")+1);
63 write(fd, "abcdefghijklmnopqrstuvwyz", strlen("abcdefghijklmnopqrstuvwyz")+1);
67 printf("\n*** WEOF\n");
68 mt_com.mt_op = MTWEOF;
70 r1 = ioctl(fd, MTIOCTOP, &mt_com);
73 /* write a second file */
74 printf("\n*** write something\n");
75 write(fd, "abcdefghijklmnopqrstuvwyz", strlen("abcdefghijklmnopqrstuvwyz")+1);
79 printf("\n*** rewind\n");
82 r1 = ioctl(fd, MTIOCTOP, &mt_com);
84 /* read something with error */
85 printf("\n*** read c=%s len=%i\n", c, r1);
93 printf("\n*** read c=%s len=%i\n", c, r1);
95 r1 = read(fd, c, 200);
100 printf("\n*** write something\n");
101 write(fd, "abcdefghijklmnopqrstuvwyz", strlen("abcdefghijklmnopqrstuvwyz")+1);
105 printf("\n*** rewind\n");
107 mt_com.mt_op = MTREW;
108 r1 = ioctl(fd, MTIOCTOP, &mt_com);
109 r1 = read(fd, c, 200);
111 printf("\n*** read c=%s len=%i\n", c, r1);
112 r1 = read(fd, c, 200);
114 printf("\n*** read c=%s len=%i\n", c, r1);
117 printf("\n*** WEOF");
118 mt_com.mt_op = MTWEOF;
120 r1 = ioctl(fd, MTIOCTOP, &mt_com);
121 printf(" r=%i\n", r1);
125 printf("\n*** fsf x1");
126 mt_com.mt_op = MTFSF;
128 r1 = ioctl(fd, MTIOCTOP, &mt_com);
129 printf(" r=%i\n", r1);
132 /* write something */
133 printf("\n*** write something\n");
134 write(fd, "abcdefghijklmnopqrstuvwyz", strlen("abcdefghijklmnopqrstuvwyz")+1);
139 mt_com.mt_op = MTFSF;
141 r1 = ioctl(fd, MTIOCTOP, &mt_com);
142 printf(" r=%i\n", r1);
146 printf("\n*** weof 3");
147 mt_com.mt_op = MTWEOF;
149 r1 = ioctl(fd, MTIOCTOP, &mt_com);
150 printf(" r=%i\n", r1);
154 printf("\n*** rewind\n");
156 mt_com.mt_op = MTREW;
157 r1 = ioctl(fd, MTIOCTOP, &mt_com);
161 printf("\n*** fsr x10");
162 mt_com.mt_op = MTFSR;
163 mt_com.mt_count = 10;
164 r1 = ioctl(fd, MTIOCTOP, &mt_com);
165 printf(" r=%i\n", r1);
169 printf("\n*** goto eom");
171 mt_com.mt_op = MTEOM;
172 r1 = ioctl(fd, MTIOCTOP, &mt_com);
173 printf(" r=%i\n", r1);
179 mt_com.mt_op = MTFSR;
180 r1 = ioctl(fd, MTIOCTOP, &mt_com);
181 printf(" r=%i\n", r1);
184 /* write something */
185 printf("\n*** write something\n");
186 write(fd, "abcdefghijklmnopqrstuvwyz", strlen("abcdefghijklmnopqrstuvwyz")+1);
190 printf("\n*** rewind");
192 mt_com.mt_op = MTREW;
193 r1 = ioctl(fd, MTIOCTOP, &mt_com);
194 printf(" r=%i\n", r1);
197 printf("\n*** fsf x2");
198 mt_com.mt_op = MTFSF;
200 r1 = ioctl(fd, MTIOCTOP, &mt_com);
201 printf(" r=%i\n", r1);
205 mt_com.mt_op = MTFSR;
207 r1 = ioctl(fd, MTIOCTOP, &mt_com);
208 printf(" r=%i\n", r1);
211 /* write something */
212 printf("\n*** write something\n");
213 write(fd, "abcdefghijklmnopqrstuvwyz", strlen("abcdefghijklmnopqrstuvwyz")+1);
216 printf("\n*** bsf x2");
217 mt_com.mt_op = MTBSF;
219 r1 = ioctl(fd, MTIOCTOP, &mt_com);
220 printf(" r=%i\n", r1);
223 printf("\n*** bsf x10");
224 mt_com.mt_op = MTBSF;
225 mt_com.mt_count = 10;
226 r1 = ioctl(fd, MTIOCTOP, &mt_com);
227 printf(" r=%i\n", r1);
231 mt_com.mt_op = MTEOM;
233 r1 = ioctl(fd, MTIOCTOP, &mt_com);
234 printf(" r=%i\n", r1);
237 printf("\n*** bsr x10");
238 mt_com.mt_op = MTBSR;
239 mt_com.mt_count = 10;
240 r1 = ioctl(fd, MTIOCTOP, &mt_com);
241 printf(" r=%i\n", r1);
245 mt_com.mt_op = MTEOM;
247 r1 = ioctl(fd, MTIOCTOP, &mt_com);
248 printf(" r=%i\n", r1);
252 mt_com.mt_op = MTFSR;
254 r1 = ioctl(fd, MTIOCTOP, &mt_com);
255 printf(" r=%i\n", r1);