-$Id: CHANGES,v 1.121 2001/07/18 11:46:31 stelian Exp $
+$Id: CHANGES,v 1.122 2001/07/18 12:54:06 stelian Exp $
Changes between versions 0.4b22 and 0.4b23 (released ????????????)
==================================================================
7. Fixed a bug in reading the operator typed file/tape path for
the next volume in restore.
+8. Implemented a "-F script" option to restore which permits the
+ user to specify a script which will be launched at the
+ beginning of each tape, useful for automatic programming of
+ tape changers for example. See the restore man page for the
+ script parameters and return codes.
+
Changes between versions 0.4b21 and 0.4b22 (released May 12, 2001)
==================================================================
-$Id: TODO,v 1.19 2001/05/10 20:55:09 stelian Exp $
+$Id: TODO,v 1.20 2001/07/18 12:54:06 stelian Exp $
Need to verify:
---------------
10. Better readline completition in restore (escape spaces etc).
-11. Implement a -F option for restore.
-
-12. Dump compiled with RedHat's 7.0 gcc seems to hang for some
+11. Dump compiled with RedHat's 7.0 gcc seems to hang for some
people. When compiled with kgcc all the problems disappear.
Will the RedHat's 7.1 gcc resolve this ?
-13. Dump uses /dev/tty for reporting some messages. When invoked
+12. Dump uses /dev/tty for reporting some messages. When invoked
from a script, /dev/tty may not exist. Why not using just
stderr ?
--- /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 <pop@noos.fr>, 1999-2000
+ * Stelian Pop <pop@noos.fr> - Alcôve <www.alcove.fr>, 2000
+ */
+
+/*-
+ * Copyright (c) 1980, 1991, 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.
+ *
+ * $Id: system.h,v 1.1 2001/07/18 12:54:06 stelian Exp $
+ */
+
+#ifndef _SYSTEM_H_
+#define _SYSTEM_H_
+
+int system_command(const char *command, const char *device, int volnum);
+
+#endif
-# $Id: Makefile.in,v 1.4 2000/08/20 19:41:24 stelian Exp $
+# $Id: Makefile.in,v 1.5 2001/07/18 12:54:06 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
-OBJS= compaterr.o fstab.o compatglob.o bylabel.o
+SRCS= compaterr.c fstab.c compatglob.c bylabel.c system.c
+OBJS= compaterr.o fstab.o compatglob.o bylabel.o system.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 <pop@noos.fr>, 1999-2000
+ * Stelian Pop <pop@noos.fr> - Alcôve <www.alcove.fr>, 2000
+ */
+
+/*-
+ * Copyright (c) 1980, 1991, 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: system.c,v 1.1 2001/07/18 12:54:06 stelian Exp $";
+#endif /* not lint */
+
+#include <config.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+/*
+ * Executes the command in a shell.
+ * Returns -1 if an error occured, the exit status of
+ * the command on success.
+ */
+int system_command(const char *command, const char *device, int volnum) {
+ int pid, status;
+ char commandstr[4096];
+
+ pid = fork();
+ if (pid == -1) {
+ perror(" DUMP: unable to fork");
+ return -1;
+ }
+ if (pid == 0) {
+ setuid(getuid());
+ setgid(getgid());
+#if OLD_STYLE_FSCRIPT
+ snprintf(commandstr, sizeof(commandstr), "%s", command);
+#else
+ snprintf(commandstr, sizeof(commandstr), "%s %s %d", command, device, volnum);
+#endif
+ commandstr[sizeof(commandstr) - 1] = '\0';
+ execl("/bin/sh", "sh", "-c", commandstr, NULL);
+ perror("unable to execute shell");
+ exit(-1);
+ }
+ do {
+ if (waitpid(pid, &status, 0) == -1) {
+ if (errno != EINTR) {
+ perror("waitpid error");
+ return -1;
+ }
+ } else {
+ if (WIFEXITED(status))
+ return WEXITSTATUS(status);
+ else
+ return -1;
+ }
+ } while(1);
+}
+
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: dump.8.in,v 1.27 2001/07/18 09:50:48 stelian Exp $
+.\" $Id: dump.8.in,v 1.28 2001/07/18 12:54:06 stelian Exp $
.\"
.Dd __DATE__
.Dt DUMP 8
.Nm
should continue without asking the user to change the tape, 1 if
.Nm
-dump should continue but ask the user to change the tape.
+should continue but ask the user to change the tape.
Any other exit code will cause
.Nm
to abort.
#ifndef lint
static const char rcsid[] =
- "$Id: tape.c,v 1.49 2001/07/18 09:50:48 stelian Exp $";
+ "$Id: tape.c,v 1.50 2001/07/18 12:54:06 stelian Exp $";
#endif /* not lint */
#include <config.h>
#include <signal.h>
#include <stdio.h>
#include <compaterr.h>
+#include <system.h>
#ifdef __STDC__
#include <stdlib.h>
#include <string.h>
static void flushtape __P((void));
static void killall __P((void));
static void rollforward __P((void));
-static int system_command __P((const char *, const char *, int));
/*
* Concurrent dump mods (Caltech) - disk block reading and tape writing
timeest();
}
-/*
- * Executes the command in a shell.
- * Returns -1 if an error occured, the exit status of
- * the command on success.
- */
-int system_command(const char *command, const char *device, int volnum) {
- int pid, status;
- char commandstr[4096];
-
- pid = fork();
- if (pid == -1) {
- perror(" DUMP: unable to fork");
- return -1;
- }
- if (pid == 0) {
- setuid(getuid());
- setgid(getgid());
-#if OLD_STYLE_FSCRIPT
- snprintf(commandstr, sizeof(commandstr), "%s", command);
-#else
- snprintf(commandstr, sizeof(commandstr), "%s %s %d", command, device, volnum);
-#endif
- commandstr[sizeof(commandstr) - 1] = '\0';
- execl("/bin/sh", "sh", "-c", commandstr, NULL);
- perror(" DUMP: unable to execute shell");
- exit(-1);
- }
- do {
- if (waitpid(pid, &status, 0) == -1) {
- if (errno != EINTR) {
- perror(" DUMP: waitpid error");
- return -1;
- }
- } else {
- if (WIFEXITED(status))
- return WEXITSTATUS(status);
- else
- return -1;
- }
- } while(1);
-}
-
time_t
trewind(void)
{
#ifndef lint
static const char rcsid[] =
- "$Id: main.c,v 1.24 2001/04/27 15:22:47 stelian Exp $";
+ "$Id: main.c,v 1.25 2001/07/18 12:54:06 stelian Exp $";
#endif /* not lint */
#include <config.h>
int compare_errors;
char filesys[NAMELEN];
static const char *stdin_opt = NULL;
+char *bot_script = NULL;
#ifdef __linux__
char *__progname;
;
obsolete(&argc, &argv);
while ((ch = getopt(argc, argv,
- "b:CcdD:f:hi"
+ "b:CcdD:f:F:hi"
#ifdef KERBEROS
"k"
#endif
use_stdin("-f");
inputdev = optarg;
break;
+ case 'F':
+ bot_script = optarg;
+ break;
case 'h':
hflag = 0;
break;
(void)fprintf(stderr,
"usage:\t%s%s\n\t%s%s\n\t%s%s\n\t%s%s\n\t%s%s\n\t%s%s\n",
- __progname, " -C [-c" kerbflag "Mvy] [-b blocksize] [-D filesystem] [-f file] [-s fileno]",
- __progname, " -i [-ch" kerbflag "mMuvy] [-b blocksize] [-f file] " qfaflag "[-s fileno]",
- __progname, " -r [-c" kerbflag "Muvy] [-b blocksize] [-f file] [-s fileno] [-T directory]",
- __progname, " -R [-c" kerbflag "Muvy] [-b blocksize] [-f file] [-s fileno] [-T directory]",
- __progname, " -t [-ch" kerbflag "Muvy] [-b blocksize] [-f file] " qfaflag "[-s fileno] [-X filelist] [file ...]",
- __progname, " -x [-ch" kerbflag "mMuvy] [-b blocksize] [-f file] " qfaflag "[-s fileno] [-X filelist] [file ...]");
+ __progname, " -C [-c" kerbflag "Mvy] [-b blocksize] [-D filesystem] [-f file] [-F script ] [-s fileno]",
+ __progname, " -i [-ch" kerbflag "mMuvy] [-b blocksize] [-f file] [-F script] " qfaflag "[-s fileno]",
+ __progname, " -r [-c" kerbflag "Muvy] [-b blocksize] [-f file] [-F script] [-s fileno] [-T directory]",
+ __progname, " -R [-c" kerbflag "Muvy] [-b blocksize] [-f file] [-F script] [-s fileno] [-T directory]",
+ __progname, " -t [-ch" kerbflag "Muvy] [-b blocksize] [-f file] [-F script] " qfaflag "[-s fileno] [-X filelist] [file ...]",
+ __progname, " -x [-ch" kerbflag "mMuvy] [-b blocksize] [-f file] [-F script] " qfaflag "[-s fileno] [-X filelist] [file ...]");
exit(1);
}
case 'b':
case 'D':
case 'f':
+ case 'F':
case 'Q':
case 's':
case 'T':
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: restore.8.in,v 1.14 2001/04/24 15:04:59 stelian Exp $
+.\" $Id: restore.8.in,v 1.15 2001/07/18 12:54:06 stelian Exp $
.\"
.Dd __DATE__
.Dt RESTORE 8
.Op Fl b Ar blocksize
.Op Fl D Ar filesystem
.Op Fl f Ar file
+.Op Fl F Ar script
.Op Fl s Ar fileno
.Op Fl T Ar directory
.Nm restore
.Op Fl chkmMNuvy
.Op Fl b Ar blocksize
.Op Fl f Ar file
+.Op Fl F Ar script
.Op Fl Q Ar file
.Op Fl s Ar fileno
.Op Fl T Ar directory
.Op Fl ckMNuvy
.Op Fl b Ar blocksize
.Op Fl f Ar file
+.Op Fl F Ar script
.Op Fl s Ar fileno
.Op Fl T Ar directory
.Nm restore
.Op Fl ckMNuvy
.Op Fl b Ar blocksize
.Op Fl f Ar file
+.Op Fl F Ar script
.Op Fl s Ar fileno
.Op Fl T Ar directory
.Nm restore
.Op Fl chkMNuvy
.Op Fl b Ar blocksize
.Op Fl f Ar file
+.Op Fl F Ar script
.Op Fl Q Ar file
.Op Fl s Ar fileno
.Op Fl T Ar directory
.Op Fl chkmMNuvy
.Op Fl b Ar blocksize
.Op Fl f Ar file
+.Op Fl F Ar script
.Op Fl Q Ar file
.Op Fl s Ar fileno
.Op Fl T Ar directory
reads from the named file on the remote host using
.Xr rmt 8 .
.Pp
+.It Fl F Ar script
+Run script at the beginning of each tape. The device name and the
+current volume number are passed on the command line.
+The script must return 0 if
+.Nm
+should continue without asking the user to change the tape, 1 if
+.Nm
+should continue but ask the user to change the tape.
+Any other exit code will cause
+.Nm
+to abort.
+For security reasons,
+.Nm
+reverts back to the real user ID and the real group ID before
+running the script.
.It Fl k
Use Kerberos authentication when contacting the remote tape server.
(Only available if this options was enabled when
* Stelian Pop <pop@noos.fr>, 1999-2000
* Stelian Pop <pop@noos.fr> - Alcôve <www.alcove.fr>, 2000
*
- * $Id: restore.h,v 1.15 2001/04/10 12:46:53 stelian Exp $
+ * $Id: restore.h,v 1.16 2001/07/18 12:54:06 stelian Exp $
*/
/*
extern int vflag; /* print out actions taken */
extern int yflag; /* always try to recover from tape errors */
extern int zflag; /* tape is in compressed format */
+extern char* bot_script; /* beginning of tape script */
/*
* Global variables
*/
#ifndef lint
static const char rcsid[] =
- "$Id: tape.c,v 1.41 2001/07/18 11:46:31 stelian Exp $";
+ "$Id: tape.c,v 1.42 2001/07/18 12:54:06 stelian Exp $";
#endif /* not lint */
#include <config.h>
#include <compatlfs.h>
#include <errno.h>
#include <compaterr.h>
+#include <system.h>
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
void
setup(void)
{
- int i, j, *ip;
+ int i, j, *ip, bot_code;
struct STAT stbuf;
Vprintf(stdout, "Verify tape and initialize maps\n");
+ if (bot_script) {
+ msg("Launching %s\n", bot_script);
+ bot_code = system_command(bot_script, magtape, 1);
+ if (bot_code != 0 && bot_code != 1) {
+ msg("Restore aborted by the beginning of tape script\n");
+ exit(1);
+ }
+ }
#ifdef RRESTORE
if (host)
mt = rmtopen(magtape, 0);
union u_spcl tmpspcl;
# define tmpbuf tmpspcl.s_spcl
char buf[TP_BSIZE];
- int haderror = 0;
+ int haderror = 0, bot_code;
if (nextvol == 1) {
tapesread = 0;
snprintf(magtape, MAXPATHLEN, "%s%03ld", magtapeprefix, newvol);
magtape[MAXPATHLEN - 1] = '\0';
}
- if (!Mflag || haderror) {
+ if (bot_script && !haderror) {
+ msg("Launching %s\n", bot_script);
+ bot_code = system_command(bot_script, magtape, newvol);
+ if (bot_code != 0 && bot_code != 1) {
+ msg("Restore aborted by the beginning of tape script\n");
+ exit(1);
+ }
+ }
+ if (haderror || (bot_code && !Mflag)) {
haderror = 0;
fprintf(stderr, "Mount tape volume %ld\n", (long)newvol);
fprintf(stderr, "Enter ``none'' if there are no more tapes\n");