-$Id: CHANGES,v 1.45 2000/03/01 10:16:05 stelian Exp $
+$Id: CHANGES,v 1.46 2000/03/02 11:34:51 stelian Exp $
Changes between versions 0.4b14 and 0.4b15 (released ?????????????????)
=======================================================================
reporting this on Bugtraq (and to several dump users
who forwarded me his mail).
+3. Added the '-F script' option to dump in order to
+ launch a script at the end of each tape (to be used
+ with a tape changer, or to notify the sysadmin by
+ pager etc.).
+
+4. Fixed a bug in restore compare code caused by the changes
+ I made in 0.4b14.
+
+5. Fixed the treatment of options using the old BSD syntax
+ in both dump and restore.
+
Changes between versions 0.4b13 and 0.4b14 (released February 10, 2000)
=======================================================================
-$Id: TODO,v 1.11 2000/02/10 10:22:04 stelian Exp $
+$Id: TODO,v 1.12 2000/03/02 11:34:51 stelian Exp $
Need to verify:
---------------
the specified archive_file to be used by
ufsrestore(1M) to determine whether a file is in
the dump file that is being restored.
-
-9. Add a '--new-volume-script' option to dump (and restore),
- such as found in tar.
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: dump.8.in,v 1.11 2000/02/04 20:22:21 stelian Exp $
+.\" $Id: dump.8.in,v 1.12 2000/03/02 11:34:51 stelian Exp $
.\"
.Dd __DATE__
.Dt DUMP 8
.Op Fl B Ar records
.Op Fl b Ar blocksize
.Op Fl d Ar density
+.Op Fl e Ar inode number
.Op Fl f Ar file
+.Op Fl F Ar script
.Op Fl h Ar level
.Op Fl L Ar label
.Op Fl s Ar feet
.Op Fl B Ar records
.Op Fl b Ar blocksize
.Op Fl d Ar density
+.Op Fl e Ar inode number
.Op Fl f Ar file
+.Op Fl F Ar script
.Op Fl h Ar level
.Op Fl L Ar label
.Op Fl s Ar feet
.Pa /etc/rmt ;
this can be overridden by the environment variable
.Ev RMT .
+.It Fl F Ar script
+Run script at the end of each tape. The script must return 0
+if the dump should continue without asking the user to change
+the tape, 1 if the dump should continue but ask the user
+to change the tape. Any other exit code will cause dump to
+abort.
.It Fl k
Use Kerberos authentication to talk to remote tape servers. (Only
available if this option was enabled when
* Remy Card <card@Linux.EU.Org>, 1994-1997
* Stelian Pop <pop@cybercable.fr>, 1999-2000
*
- * $Id: dump.h,v 1.12 2000/03/01 10:16:05 stelian Exp $
+ * $Id: dump.h,v 1.13 2000/03/02 11:34:51 stelian Exp $
*/
/*-
char level; /* dump level of this dump */
int uflag; /* update flag */
int Mflag; /* multi-volume flag */
+char *eot_script; /* end of volume script fiag */
int diskfd; /* disk file descriptor */
int tapefd; /* tape file descriptor */
int pipeout; /* true => output to standard output */
void close_rewind __P((void));
void dumpblock __P((daddr_t blkno, int size));
void startnewtape __P((int top));
-void trewind __P((void));
+time_t trewind __P((void));
void writerec __P((const void *dp, int isspcl));
void Exit __P((int status));
#ifndef lint
static const char rcsid[] =
- "$Id: main.c,v 1.17 2000/03/01 10:16:05 stelian Exp $";
+ "$Id: main.c,v 1.18 2000/03/02 11:34:51 stelian Exp $";
#endif /* not lint */
#include <sys/param.h>
#endif
tsize = 0; /* Default later, based on 'c' option for cart tapes */
+ eot_script = NULL;
if ((tapeprefix = getenv("TAPE")) == NULL)
tapeprefix = _PATH_DEFTAPE;
dumpdates = _PATH_DUMPDATES;
obsolete(&argc, &argv);
#ifdef KERBEROS
-#define optstring "0123456789aB:b:cd:e:f:h:kL:Mns:ST:uWw"
+#define optstring "0123456789aB:b:cd:e:f:F:h:kL:Mns:ST:uWw"
#else
-#define optstring "0123456789aB:b:cd:e:f:h:L:Mns:ST:uWw"
+#define optstring "0123456789aB:b:cd:e:f:F:h:L:Mns:ST:uWw"
#endif
while ((ch = getopt(argc, argv, optstring)) != -1)
#undef optstring
tapeprefix = optarg;
break;
+ case 'F': /* end of tape script */
+ eot_script = optarg;
+ break;
+
case 'h':
honorlevel = numarg("honor level", 0L, 10L);
break;
spcl.c_type = TS_END;
for (i = 0; i < ntrec; i++)
writeheader(maxino - 1);
+
+ tnow = trewind();
+
if (pipeout)
msg("DUMP: %ld tape blocks\n", spcl.c_tapea);
else
tend_writing - tstart_writing,
spcl.c_tapea / (tend_writing - tstart_writing));
- tnow = do_stats();
putdumptime();
#ifdef __linux__
msg("DUMP: Date of this level %c dump: %s", level,
msg("DUMP: Average transfer rate: %ld KB/s\n", xferrate / tapeno);
- trewind();
broadcast("DUMP IS DONE!\7\7\n");
msg("DUMP IS DONE\n");
Exit(X_FINOK);
case 'B':
case 'b':
case 'd':
+ case 'e':
case 'f':
+ case 'F':
case 'h':
+ case 'L':
case 's':
case 'T':
if (*argv == NULL) {
#ifndef lint
static const char rcsid[] =
- "$Id: tape.c,v 1.14 2000/03/01 10:16:05 stelian Exp $";
+ "$Id: tape.c,v 1.15 2000/03/02 11:34:51 stelian Exp $";
#endif /* not lint */
#ifdef __linux__
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
+#include <compaterr.h>
#ifdef __STDC__
#include <stdlib.h>
#include <string.h>
extern char *host;
char *nexttape;
extern pid_t rshpid;
+int eot_code = 1;
static ssize_t atomic_read __P((int, void *, size_t));
static ssize_t atomic_write __P((int, const void *, size_t));
timeest();
}
-void
+/*
+ * 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) {
+ int pid, status;
+
+ pid = fork();
+ if (pid == -1) {
+ perror(" DUMP: unable to fork");
+ return -1;
+ }
+ if (pid == 0) {
+ setuid(getuid());
+ setgid(getgid());
+ execl("/bin/sh", "sh", "-c", command, 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)
{
int f;
while (wait((int *)NULL) >= 0) /* wait for any signals from slaves */
/* void */;
- if (pipeout)
- return;
+ if (!pipeout) {
- msg("Closing %s\n", tape);
+ msg("Closing %s\n", tape);
#ifdef RDUMP
- if (host) {
- rmtclose();
- while (rmtopen(tape, 0) < 0)
- sleep(10);
- rmtclose();
- return;
- }
+ if (host) {
+ rmtclose();
+ while (rmtopen(tape, 0) < 0)
+ sleep(10);
+ rmtclose();
+ }
+ else
+#else
+ {
+ (void) close(tapefd);
+ while ((f = open(tape, 0)) < 0)
+ sleep (10);
+ (void) close(f);
+ }
#endif
- (void) close(tapefd);
- while ((f = open(tape, 0)) < 0)
- sleep (10);
- (void) close(f);
+ eot_code = 1;
+ if (eot_script) {
+ msg("Launching %s\n", eot_script);
+ eot_code = system_command(eot_script);
+ }
+ if (eot_code != 0 && eot_code != 1) {
+ msg("Dump aborted by the end of tape script\n");
+ dumpabort(0);
+ }
+ }
+ return do_stats();
}
+
void
close_rewind(void)
{
- trewind();
- (void)do_stats();
- if (nexttape || Mflag)
+ (void)trewind();
+ if (nexttape || Mflag || (eot_code == 0) )
return;
if (!nogripe) {
msg("Change Volumes: Mount volume #%d\n", tapeno+1);
#ifndef lint
static const char rcsid[] =
- "$Id: main.c,v 1.8 2000/01/21 10:17:41 stelian Exp $";
+ "$Id: main.c,v 1.9 2000/03/02 11:34:51 stelian Exp $";
#endif /* not lint */
#include <sys/param.h>
FILE *terminal;
char *tmpdir;
int compare_ignore_not_found;
-char *filesys = NULL;
+char filesys[NAMELEN];
#ifdef __linux__
char *__progname;
/* Temp files should *not* be readable. We set permissions later. */
(void) umask(077);
-
+ filesys[0] = '\0';
#ifdef __linux__
__progname = argv[0];
#endif
cvtflag = 1;
break;
case 'D':
- filesys = optarg;
+ strncpy(filesys, optarg, NAMELEN);
+ filesys[NAMELEN - 1] = '\0';
break;
case 'T':
tmpdir = optarg;
for (flags = 0; *ap; ++ap) {
switch (*ap) {
case 'b':
+ case 'D':
case 'f':
case 's':
+ case 'T':
if (*argv == NULL) {
warnx("option requires an argument -- %c", *ap);
usage();
* Remy Card <card@Linux.EU.Org>, 1994-1997
* Stelian Pop <pop@cybercable.fr>, 1999-2000
*
- * $Id: restore.h,v 1.7 2000/01/21 10:17:41 stelian Exp $
+ * $Id: restore.h,v 1.8 2000/03/02 11:34:51 stelian Exp $
*/
/*
* SUCH DAMAGE.
*/
+#include <protocols/dumprestore.h>
/*
* Flags
*/
/* used to compare incremental dumps, */
/* so messages about "not found" files */
/* isn't seen. */
-extern char *filesys; /* name of dumped filesystem */
+extern char filesys[NAMELEN];/* name of dumped filesystem */
/*
* Each file in the file system is described by one of these entries
#ifndef lint
static const char rcsid[] =
- "$Id: tape.c,v 1.12 2000/03/01 10:16:05 stelian Exp $";
+ "$Id: tape.c,v 1.13 2000/03/02 11:34:51 stelian Exp $";
#endif /* not lint */
#include <sys/param.h>
}
if (vflag || command == 't' || command == 'C')
printdumpinfo();
- if (filesys == NULL) {
- filesys = spcl.c_filesys;
+ if (filesys[0] == '\0') {
+ char *dirptr;
+printf("spcl.c_filesys = %s\n", spcl.c_filesys);
+ strncpy(filesys, spcl.c_filesys, NAMELEN);
+ filesys[NAMELEN - 1] = '\0';
+ dirptr = strstr(filesys, " (dir");
+printf("dirptr = %s\n", dirptr);
+ if (dirptr != NULL)
+ *dirptr = '\0';
+printf("dirptr = %s\n", dirptr);
+printf("filesys = %s\n", filesys);
}
dumptime = spcl.c_ddate;
dumpdate = spcl.c_date;