-$Id: CHANGES,v 1.189 2002/07/25 09:56:47 stelian Exp $
+$Id: CHANGES,v 1.190 2002/07/29 12:00:30 stelian Exp $
+
+Changes between versions 0.4b30 and 0.4b31 (released ?????????????)
+===================================================================
+
+1. Fixed rmt open flags transmission (GNU's symbolic syntax over
+ rmt) which I broke in 0.4b29. Thanks to Eros Albertazzi
+ <eros@lamel.bo.cnr.it> for reporting the bug.
Changes between versions 0.4b29 and 0.4b30 (released July 25, 2002)
===================================================================
#ifndef lint
static const char rcsid[] =
- "$Id: dumprmt.c,v 1.22 2002/07/19 14:57:39 stelian Exp $";
+ "$Id: dumprmt.c,v 1.23 2002/07/29 12:00:33 stelian Exp $";
#endif /* not lint */
#include <config.h>
#include <sys/mtio.h>
#include <sys/socket.h>
#include <sys/time.h>
+#include <fcntl.h>
#ifdef __linux__
#include <sys/types.h>
#ifdef HAVE_EXT2FS_EXT2_FS_H
#include <ctype.h>
#include <errno.h>
#include <compaterr.h>
+#include <rmtflags.h>
#include <netdb.h>
#include <pwd.h>
#include <stdio.h>
}
int
-rmtopen(const char *tape, const char *mode)
+rmtopen(const char *tape, const int mode)
{
char buf[MAXPATHLEN];
-
- (void)snprintf(buf, sizeof (buf), "O%s\n%s\n", tape, mode);
+ char *rmtflags;
+
+ rmtflags = rmtflags_tochar(mode);
+ (void)snprintf(buf, sizeof (buf), "O%s\n%d %s\n",
+ tape,
+ mode & O_ACCMODE,
+ rmtflags);
+ free(rmtflags);
rmtstate = TS_OPEN;
return (rmtcall(tape, buf));
}
--- /dev/null
+/*
+ * Ported to Linux's Second Extended File System as part of the
+ * dump and restore backup suit
+ * Remy Card <card@Linux.EU.Org>, 1994-1997
+ * Stelian Pop <stelian@popies.net>, 1999-2000
+ * Stelian Pop <stelian@popies.net> - Alcôve <www.alcove.com>, 2000-2002
+ *
+ * $Id: rmtflags.h,v 1.1 2002/07/29 12:00:33 stelian Exp $
+ */
+
+/*
+ * Copyright (c) 1983, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _RMTFLAGS_H_
+#define _RMTFLAGS_H_
+
+int rmtflags_toint(char *filemode);
+char *rmtflags_tochar(int filemode);
+
+#endif
-# $Id: Makefile.in,v 1.5 2001/07/18 12:54:06 stelian Exp $
+# $Id: Makefile.in,v 1.6 2002/07/29 12:00:33 stelian Exp $
top_srcdir= @top_srcdir@
srcdir= @srcdir@
INC= -I$(top_srcdir)/compat/include
CFLAGS= @CCOPTS@ -pipe $(OPT) $(GINC) $(INC) $(DEFS)
-SRCS= compaterr.c fstab.c compatglob.c bylabel.c system.c
-OBJS= compaterr.o fstab.o compatglob.o bylabel.o system.o
+SRCS= compaterr.c fstab.c compatglob.c bylabel.c system.c rmtflags.c
+OBJS= compaterr.o fstab.o compatglob.o bylabel.o system.o rmtflags.o
LIB= libcompat.a
all:: $(LIB)
--- /dev/null
+/*
+ * Ported to Linux's Second Extended File System as part of the
+ * dump and restore backup suit
+ * Remy Card <card@Linux.EU.Org>, 1994-1997
+ * Stelian Pop <stelian@popies.net>, 1999-2000
+ * Stelian Pop <stelian@popies.net> - Alcôve <www.alcove.com>, 2000-2002
+ */
+
+/*
+ * Copyright (c) 1983, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+ "$Id: rmtflags.c,v 1.1 2002/07/29 12:00:33 stelian Exp $";
+#endif /* not linux */
+
+/*
+ * rmt
+ */
+#include <config.h>
+#include <fcntl.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <malloc.h>
+
+struct openflags {
+ char *name;
+ int value;
+} openflags[] = {
+ { "O_RDONLY", O_RDONLY },
+ { "O_WRONLY", O_WRONLY },
+ { "O_RDWR", O_RDWR },
+#ifdef O_CREAT
+ { "O_CREAT", O_CREAT },
+#endif
+#ifdef O_EXCL
+ { "O_EXCL", O_EXCL },
+#endif
+#ifdef O_NOCTTY
+ { "O_NOCTTY", O_NOCTTY },
+#endif
+#ifdef O_TRUNC
+ { "O_TRUNC", O_TRUNC },
+#endif
+#ifdef O_APPEND
+ { "O_APPEND", O_APPEND },
+#endif
+#ifdef O_NONBLOCK
+ { "O_NONBLOCK", O_NONBLOCK },
+#endif
+#ifdef O_NDELAY
+ { "O_NDELAY", O_NDELAY },
+#endif
+#ifdef O_SYNC
+ { "O_SYNC", O_SYNC },
+#endif
+#ifdef O_FSYNC
+ { "O_FSYNC", O_FSYNC },
+#endif
+#ifdef O_ASYNC
+ { "O_ASYNC", O_ASYNC },
+#endif
+#ifdef O_TEXT
+ { "O_TEXT", O_TEXT },
+#endif
+#ifdef O_DSYNC
+ { "O_DSYNC", O_DSYNC },
+#endif
+#ifdef O_RSYNC
+ { "O_RSYNC", O_RSYNC },
+#endif
+#ifdef O_PRIV
+ { "O_PRIV", O_PRIV },
+#endif
+#ifdef O_LARGEFILE
+ { "O_LARGEFILE",O_LARGEFILE },
+#endif
+ { NULL, 0 }
+};
+
+/* Parts of this stolen again from Jörg Schilling's star package... */
+int
+rmtflags_toint(char *filemode)
+{
+ char *p = filemode;
+ struct openflags *op;
+ int result = 0;
+ int numresult = 0;
+ int seentext = 0;
+
+ do {
+ /* skip space */
+ while (*p != '\0' && *p == ' ')
+ p++;
+ /* get O_XXXX constant */
+ if (p[0] != 'O' || p[1] != '_') {
+ /* numeric syntax detected */
+ numresult = atoi(filemode);
+ numresult &= O_RDONLY | O_WRONLY | O_RDWR;
+ while (*p != ' ' && *p != '\0')
+ p++;
+ while (*p != '\0' && *p == ' ')
+ p++;
+ }
+
+ if (*p == '\0')
+ break;
+
+ /* translate O_XXXX constant */
+ for (op = openflags; op->name; op++) {
+ int slen = strlen(op->name);
+ if ((strncmp(op->name, p, slen) == 0) &&
+ (p[slen] == '|' || p[slen] == ' ' ||
+ p[slen] == '\0')) {
+ seentext = 1;
+ result |= op->value;
+ break;
+ }
+ }
+
+ /* goto next constant */
+ p = strchr(p, '|');
+ } while (p && *p++ == '|');
+
+ if (!seentext)
+ result = numresult;
+ return result;
+}
+
+char *
+rmtflags_tochar(int filemode)
+{
+ struct openflags *op;
+ char *result = (char *) malloc(4096); /* enough space */
+
+ switch (filemode & O_ACCMODE) {
+ case O_RDONLY:
+ strcpy(result, "O_RDONLY");
+ break;
+ case O_WRONLY:
+ strcpy(result, "O_WRONLY");
+ break;
+ case O_RDWR:
+ strcpy(result, "O_RDWR");
+ break;
+ default:
+ strcat(result, "ERROR");
+ }
+ for (op = openflags; op->name; op++) {
+ if (op->value == O_RDONLY ||
+ op->value == O_WRONLY ||
+ op->value == O_RDWR)
+ continue;
+ if (filemode & op->value) {
+ strcat(result, "|");
+ strcat(result, op->name);
+ }
+ }
+ return result;
+}
* Stelian Pop <stelian@popies.net>, 1999-2000
* Stelian Pop <stelian@popies.net> - Alcôve <www.alcove.com>, 2000-2002
*
- * $Id: dump.h,v 1.39 2002/06/05 13:29:15 stelian Exp $
+ * $Id: dump.h,v 1.40 2002/07/29 12:00:33 stelian Exp $
*/
/*-
/* rdump routines */
#ifdef RDUMP
int rmthost __P((const char *host));
-int rmtopen __P((const char *tape, const char *mode));
+int rmtopen __P((const char *tape, const int mode));
void rmtclose __P((void));
int rmtread __P((char *buf, size_t count));
int rmtwrite __P((const char *buf, size_t count));
#ifndef lint
static const char rcsid[] =
- "$Id: tape.c,v 1.70 2002/07/19 14:57:39 stelian Exp $";
+ "$Id: tape.c,v 1.71 2002/07/29 12:00:33 stelian Exp $";
#endif /* not lint */
#include <config.h>
#ifdef RDUMP
if (host) {
rmtclose();
- while (rmtopen(tape, "O_RDONLY") < 0)
+ while (rmtopen(tape, O_RDONLY) < 0)
sleep(10);
rmtclose();
}
msg("Dumping volume %d on %s\n", tapeno, tape);
}
#ifdef RDUMP
- while ((tapefd = (host ? rmtopen(tape, "O_WRONLY|O_CREAT|O_TRUNC") : pipeout ?
+ while ((tapefd = (host ? rmtopen(tape, O_WRONLY|O_CREAT|O_TRUNC) : pipeout ?
fileno(stdout) :
OPEN(tape, O_WRONLY|O_CREAT|O_TRUNC, 0666))) < 0)
#else
* Stelian Pop <stelian@popies.net>, 1999-2000
* Stelian Pop <stelian@popies.net> - Alcôve <www.alcove.com>, 2000-2002
*
- * $Id: extern.h,v 1.18 2002/05/21 15:48:46 stelian Exp $
+ * $Id: extern.h,v 1.19 2002/07/29 12:00:34 stelian Exp $
*/
/*-
void rmtclose __P((void));
int rmthost __P((const char *));
int rmtioctl __P((int, int));
-int rmtopen __P((const char *, const char *));
+int rmtopen __P((const char *, const int));
int rmtread __P((const char *, int));
int rmtseek __P((int, int));
#ifndef lint
static const char rcsid[] =
- "$Id: tape.c,v 1.63 2002/07/19 14:57:40 stelian Exp $";
+ "$Id: tape.c,v 1.64 2002/07/29 12:00:34 stelian Exp $";
#endif /* not lint */
#include <config.h>
#ifdef RRESTORE
if (host)
- mt = rmtopen(temptape, "O_RDONLY");
+ mt = rmtopen(temptape, O_RDONLY);
else
#endif
if (pipein)
}
#ifdef RRESTORE
if (host)
- mt = rmtopen(magtape, "O_RDONLY");
+ mt = rmtopen(magtape, O_RDONLY);
else
#endif
mt = OPEN(magtape, O_RDONLY, 0);
-# $Id: Makefile.in,v 1.6 2002/01/02 10:13:16 stelian Exp $
+# $Id: Makefile.in,v 1.7 2002/07/29 12:00:34 stelian Exp $
top_srcdir= @top_srcdir@
srcdir= @srcdir@
CFLAGS= @CCOPTS@ -pipe $(OPT) $(GINC) $(INC) $(DEFS)
LDFLAGS= @LDOPTS@ @STATIC@
LIBS= $(GLIBS)
-
-#DEBUG= -DFDEBUG -DTDEBUG -DWRITEDEBUG
-#INC= -I../compat/include
-#CFLAGS= -pipe $(DEFS) $(DEBUG) $(INC) $(GINC) $(OPT)
-#DEPLIBS= ../compat/lib/libcompat.a
-#LIBS= $(GLIBS) -L../compat/lib -lcompat
+DEPLIBS= ../compat/lib/libcompat.a
PROG= rmt
SRCS= rmt.c
OBJS= rmt.o
MAN8= rmt.8
-all:: $(PROG) rmt.8
+all:: $(PROG) $(MAN8)
$(PROG): $(OBJS) $(DEPLIBS)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $(PROG) $(OBJS) $(LIBS)
+ $(LD) $(CFLAGS) $(LDFLAGS) -o $(PROG) $(OBJS) $(LIBS)
-rmt.8: rmt.8.in
+$(MAN8): rmt.8.in
sed -e "s|__DATE__|$(DATE)|g" \
-e "s|__VERSION__|$(VERSION)|g" $< > $@
#ifndef lint
static const char rcsid[] =
- "$Id: rmt.c,v 1.20 2002/05/21 15:48:46 stelian Exp $";
+ "$Id: rmt.c,v 1.21 2002/07/29 12:00:34 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>
char *checkbuf __P((char *, int));
void error __P((int));
void getstring __P((char *));
-int getopenflags __P((char *));
int
main(int argc, char *argv[])
/*
* Translate extended GNU syntax into its numeric platform equivalent
*/
- oflags = getopenflags(filemode);
+ oflags = rmtflags_toint(filemode);
#ifdef O_TEXT
/*
* Default to O_BINARY the client may not know that we need it.
(void)snprintf(resp, sizeof(resp), "E%d\n%s\n", num, strerror(num));
(void)write(1, resp, strlen(resp));
}
-
-struct openflags {
- char *name;
- int value;
-} openflags[] = {
- { "O_RDONLY", O_RDONLY },
- { "O_WRONLY", O_WRONLY },
- { "O_RDWR", O_RDWR },
-#ifdef O_CREAT
- { "O_CREAT", O_CREAT },
-#endif
-#ifdef O_EXCL
- { "O_EXCL", O_EXCL },
-#endif
-#ifdef O_NOCTTY
- { "O_NOCTTY", O_NOCTTY },
-#endif
-#ifdef O_TRUNC
- { "O_TRUNC", O_TRUNC },
-#endif
-#ifdef O_APPEND
- { "O_APPEND", O_APPEND },
-#endif
-#ifdef O_NONBLOCK
- { "O_NONBLOCK", O_NONBLOCK },
-#endif
-#ifdef O_NDELAY
- { "O_NDELAY", O_NDELAY },
-#endif
-#ifdef O_SYNC
- { "O_SYNC", O_SYNC },
-#endif
-#ifdef O_FSYNC
- { "O_FSYNC", O_FSYNC },
-#endif
-#ifdef O_ASYNC
- { "O_ASYNC", O_ASYNC },
-#endif
-#ifdef O_TEXT
- { "O_TEXT", O_TEXT },
-#endif
-#ifdef O_DSYNC
- { "O_DSYNC", O_DSYNC },
-#endif
-#ifdef O_RSYNC
- { "O_RSYNC", O_RSYNC },
-#endif
-#ifdef O_PRIV
- { "O_PRIV", O_PRIV },
-#endif
-#ifdef O_LARGEFILE
- { "O_LARGEFILE",O_LARGEFILE },
-#endif
- { NULL, 0 }
-};
-
-/* Parts of this stolen again from Jörg Schilling's star package... */
-int
-getopenflags(char *filemode)
-{
- char *p = filemode;
- struct openflags *op;
- int result = 0;
-
- do {
- /* skip space */
- while (*p != '\0' && *p == ' ')
- p++;
- /* get O_XXXX constant */
- if (p[0] != 'O' || p[1] != '_') {
- /* numeric syntax detected */
- result = atoi(filemode);
- result &= O_RDONLY | O_WRONLY | O_RDWR;
- return result;
- }
-
- /* translate O_XXXX constant */
- for (op = openflags; op->name; op++) {
- int slen = strlen(op->name);
- if ((strncmp(op->name, p, slen) == 0) &&
- (p[slen] == '|' || p[slen] == ' ' ||
- p[slen] == '\0')) {
- result |= op->value;
- break;
- }
- }
-
- /* goto next constant */
- p = strchr(p, '|');
- } while (p && *p++ == '|');
-
- return result;
-}