#ifndef lint
static const char rcsid[] =
- "$Id: rmt.c,v 1.27 2003/10/26 16:05:49 stelian Exp $";
+ "$Id: rmt.c,v 1.29 2010/06/11 11:19:18 stelian Exp $";
#endif /* not linux */
/*
getstring(pos);
DEBUG2("rmtd: L %s %s\n", count, pos);
if (!magtape) { /* traditional */
- rval = LSEEK(tape, (OFF_T)atoll(count), atoi(pos));
+ switch (atoi(pos)) {
+ case SEEK_SET:
+ case SEEK_CUR:
+ case SEEK_END:
+ rval = LSEEK(tape, (OFF_T)atoll(count), atoi(pos));
+ break;
+#ifdef USE_QFA
+ case LSEEK_GET_TAPEPOS:
+ rval = LSEEK(tape, (OFF_T)0, SEEK_CUR);
+ break;
+ case LSEEK_GO2_TAPEPOS:
+ rval = LSEEK(tape, (OFF_T)atoll(count), SEEK_SET);
+ break;
+#endif /* USE_QFA */
+ default:
+ errno = EINVAL;
+ goto ioerror;
+ break;
+ }
}
else {
switch (atoi(pos)) {
cp = record;
#endif
(void)sprintf(resp, "A%lld\n", (long long)rval);
- (void)write(1, resp, strlen(resp));
- (void)write(1, cp, rval);
+ if (write(1, resp, strlen(resp)) != strlen(resp))
+ goto ioerror;
+ if (write(1, cp, rval) != rval)
+ goto ioerror;
block += n >> 10;
goto top;
mtget.mt_fileno = swaplong(mtget.mt_fileno);
mtget.mt_blkno = swaplong(mtget.mt_blkno);
(void)sprintf(resp, "A%lld\n", (long long)rval);
- (void)write(1, resp, strlen(resp));
- (void)write(1, (char *)&mtget, sizeof (mtget));
+ if (write(1, resp, strlen(resp)) != strlen(resp))
+ goto ioerror;
+ if (write(1, (char *)&mtget, sizeof (mtget)) != sizeof(mtget))
+ goto ioerror;
} else {
rval = sizeof (mtget);
(void)sprintf(resp, "A%lld\n", (long long)rval);
- (void)write(1, resp, strlen(resp));
- (void)write(1, (char *)&mtget, sizeof (mtget));
+ if (write(1, resp, strlen(resp)) != strlen(resp))
+ goto ioerror;
+ if (write(1, (char *)&mtget, sizeof (mtget)) != sizeof(mtget))
+ goto ioerror;
}
goto top;
}
respond:
DEBUG1("rmtd: A %lld\n", (long long)rval);
(void)sprintf(resp, "A%lld\n", (long long)rval);
- (void)write(1, resp, strlen(resp));
+ if (write(1, resp, strlen(resp)) != strlen(resp))
+ goto ioerror;
goto top;
ioerror:
error(errno);
DEBUG2("rmtd: E %d (%s)\n", num, strerror(num));
(void)snprintf(resp, sizeof(resp), "E%d\n%s\n", num, strerror(num));
- (void)write(1, resp, strlen(resp));
+ if (write(1, resp, strlen(resp)) != strlen(resp))
+ DEBUG("rmtd: write error\n");
}
static unsigned long