#ifndef lint
static const char rcsid[] =
- "$Id: rmt.c,v 1.18 2002/04/15 11:57:29 stelian Exp $";
+ "$Id: rmt.c,v 1.22 2003/01/10 14:42:51 stelian Exp $";
#endif /* not linux */
/*
*/
#include <config.h>
#include <compatlfs.h>
+#include <rmtflags.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/mtio.h>
* and relicensed by his permission from GPL to BSD for use in dump.
*
* rmt_version is 0 for regular clients (Linux included)
- * rmt_version is 1 for extended clients (Sun especially). In this cas
+ * rmt_version is 1 for extended clients (Sun especially). In this case
* we support some extended commands (see below) and we remap
* the ioctl commands to the UNIX "standard", as per:
* ftp://ftp.fokus.gmd.de/pub/unix/star/README.mtio
{
int rval = 0;
char c;
- int n, i, cc;
+ int n, i, cc, oflags;
unsigned long block = 0;
argc--, argv++;
getstring(device);
getstring(filemode);
DEBUG2("rmtd: O %s %s\n", device, filemode);
+ /*
+ * Translate extended GNU syntax into its numeric platform equivalent
+ */
+ oflags = rmtflags_toint(filemode);
+#ifdef O_TEXT
+ /*
+ * Default to O_BINARY the client may not know that we need it.
+ */
+ if ((oflags & O_TEXT) == 0)
+ oflags |= O_BINARY;
+#endif
+ DEBUG2("rmtd: O %s %d\n", device, oflags);
/*
* XXX the rmt protocol does not provide a means to
* specify the permission bits; allow rw for everyone,
* as modified by the users umask
*/
- tape = OPEN(device, atoi(filemode), 0666);
+ tape = OPEN(device, oflags, 0666);
if (tape < 0)
goto ioerror;
block = 0;
getstring(count);
getstring(pos);
DEBUG2("rmtd: L %s %s\n", count, pos);
- rval = LSEEK(tape, (off_t)atol(count), atoi(pos));
+ rval = LSEEK(tape, (OFF_T)atoll(count), atoi(pos));
if (rval < 0)
goto ioerror;
goto respond;