diff -ru /usr/src/sbin/dump/main.c dump/main.c --- /usr/src/sbin/dump/main.c Sun Nov 16 09:01:58 2003 +++ dump/main.c Wed Feb 4 09:20:48 2004 @@ -85,6 +85,7 @@ long dev_bsize = 1; /* recalculated below */ long blocksperfile; /* output blocks per file */ char *host = NULL; /* remote host (if any) */ +char *script = NULL; /* name of the script for changing tapes */ /* * Possible superblock locations ordered from most to least likely. @@ -127,7 +128,7 @@ obsolete(&argc, &argv); while ((ch = getopt(argc, argv, - "0123456789aB:b:C:cD:d:f:h:LnSs:T:uWw")) != -1) + "0123456789aB:b:C:cD:d:f:F:h:LnSs:T:uWw")) != -1) switch (ch) { /* dump level */ case '0': case '1': case '2': case '3': case '4': @@ -171,6 +172,10 @@ tape = optarg; break; + case 'F': /* changer script */ + script = optarg; + break; + case 'h': honorlevel = numarg("honor level", 0L, 10L); break; @@ -559,8 +564,8 @@ { fprintf(stderr, "usage: dump [-0123456789acLnSu] [-B records] [-b blocksize] [-C cachesize]\n" - " [-D dumpdates] [-d density] [-f file] [-h level] [-s feet]\n" - " [-T date] filesystem\n" + " [-D dumpdates] [-d density] [-f file] [-F script] [-h level]\n" + " [-s feet] [-T date] filesystem\n" " dump -W | -w\n"); exit(X_STARTUP); } diff -ru /usr/src/sbin/dump/tape.c dump/tape.c --- /usr/src/sbin/dump/tape.c Wed Sep 25 06:06:35 2002 +++ dump/tape.c Wed Feb 4 09:16:54 2004 @@ -70,6 +70,7 @@ extern int ntrec; /* blocking factor on tape */ extern int cartridge; extern char *host; +extern char *script; char *nexttape; static int atomic(ssize_t (*)(), int, char *, int); @@ -118,6 +119,41 @@ static jmp_buf jmpbuf; /* where to jump to if we are ready when the */ /* SIGUSR2 arrives from the previous slave */ + +int +runscript(void) +{ + char *cmd; + size_t cmd_len; + int rc; + + if (script != NULL) { + cmd_len = strlen(script) + strlen(disk) + 10; + if ((cmd = (char*) malloc(sizeof(char)*cmd_len)) == NULL) { + perror(" DUMP: could not allocate memory for command buffer."); + return(1); + } + + snprintf(cmd, cmd_len, "%s %s %d", script, disk, tapeno); + rc = system(cmd); + + if (rc == -1) { + perror(" DUMP: execution of script failed"); + return(1); + } else if (rc == (127 << 8)) { + msg("Change Volumes: execution of shell failed while running changer script"); + return(1); + } else { + msg("Change Volumes: changer script failed with return code %d\n", (rc >> 8)); + return(1); + } + + return(0); + } + + return(1); +} + int alloctape(void) { @@ -368,15 +404,17 @@ if (nexttape) return; (void)time((time_t *)&(tstart_changevol)); - if (!nogripe) { - msg("Change Volumes: Mount volume #%d\n", tapeno+1); - broadcast("CHANGE DUMP VOLUMES!\a\a\n"); - } - while (!query("Is the new volume mounted and ready to go?")) - if (query("Do you want to abort?")) { - dumpabort(0); - /*NOTREACHED*/ + if (runscript()) { + if (!nogripe) { + msg("Change Volumes: Mount volume #%d\n", tapeno+1); + broadcast("CHANGE DUMP VOLUMES!\a\a\n"); } + while (!query("Is the new volume mounted and ready to go?")) + if (query("Do you want to abort?")) { + dumpabort(0); + /*NOTREACHED*/ + } + } (void)time((time_t *)&(tend_changevol)); if ((tstart_changevol != (time_t)-1) && (tend_changevol != (time_t)-1)) tstart_writing += (tend_changevol - tstart_changevol);