I am trying to extend dump to allow a script to be run in order to use an
autoloader. The hack^H^H^H^Hdiff is in it's early stages but I feel like
I have done enough to make the basic functionality work ;)
Diff against RELENG_4 and the script is attached.
Basically the idea was to replace the query() calls with calls to a script
if a flag (-l) is passed to dump. When I try this without the (-a) append
option all works as expected. When dump feels it has got to the end of
the tape it calls my script and this successfully changes the tape
(verified by looking at the LCD display and using chio stat).
However when the (-a) append option is passed the first tape is loaded
(assuming no tape in the drive) and written to till the end, the script is
then called and successfully changes the tape, however when dump tries to
write to the new tape I get the error:
DUMP: End of tape detected
When I do an mt stat I noticed that the fsf goes up by one for each tape
(seems sensible) but other than that I see no other problems.
I have added an mt rew and mt stat to the script but see no difference and
no new clues. Am I being terminally dull? ;)
Can someone with more of a clue about tapes/dump/scsi help?
Can I provide more info?
Henry
PS: Yes I know that the script keeping state is stupid I will fix this
once I have fixed the current more blatant issue!
PPS: Is anyone else interested in adding per file software compression
capability to dump? I would like to do it, but would like someone to
bounce ideas off.
Index: main.c
===================================================================
RCS file: /fs/Source/FBSD-repos/src/sbin/dump/main.c,v
retrieving revision 1.20.2.6
diff -u -r1.20.2.6 main.c
--- main.c 24 Nov 2001 19:19:41 -0000 1.20.2.6
+++ main.c 4 Jan 2002 15:16:57 -0000
@@ -87,6 +87,7 @@
long dev_bsize = 1; /* recalculated below */
long blocksperfile; /* output blocks per file */
char *host = NULL; /* remote host (if any) */
+int loader = 0; /* Use a loader script */
static long numarg __P((char *, long, long));
static void obsolete __P((int *, char **[]));
@@ -124,9 +125,9 @@
obsolete(&argc, &argv);
#ifdef KERBEROS
-#define optstring "0123456789aB:b:cd:f:h:kns:T:uWwD:"
+#define optstring "0123456789aB:b:cd:f:h:klns:T:uWwD:"
#else
-#define optstring "0123456789aB:b:cd:f:h:ns:T:uWwD:"
+#define optstring "0123456789aB:b:cd:f:h:lns:T:uWwD:"
#endif
while ((ch = getopt(argc, argv, optstring)) != -1)
#undef optstring
@@ -178,6 +179,10 @@
dokerberos = 1;
break;
#endif
+
+ case 'l': /* Use loader script */
+ loader = 1;
+ break;
case 'n': /* notify operators */
notify = 1;
Index: tape.c
===================================================================
RCS file: /fs/Source/FBSD-repos/src/sbin/dump/tape.c,v
retrieving revision 1.12.2.1
diff -u -r1.12.2.1 tape.c
--- tape.c 1 Aug 2001 06:29:35 -0000 1.12.2.1
+++ tape.c 10 Jan 2002 15:30:53 -0000
@@ -78,6 +78,7 @@
extern int ntrec; /* blocking factor on tape */
extern int cartridge;
extern char *host;
+extern int loader;
char *nexttape;
static int atomic __P((ssize_t (*)(), int, char *, int));
@@ -374,20 +375,32 @@
close_rewind()
{
time_t tstart_changevol, tend_changevol;
+ int retval;
trewind();
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?")) {
+ if (loader){
+#define LOADERSCRIPT "/tmp/loaderscript.sh"
+ msg("Calling %s for volume #%d (%d)\n", LOADERSCRIPT, tapeno+1,
+nexttape);
+ retval = system(LOADERSCRIPT);
+ if (retval != 0){
+ msg("ERROR: Loader script failed (returned %d) -- ABORTING\n",
+retval);
dumpabort(0);
/*NOTREACHED*/
}
+ } else if (!nogripe) {
+ msg("Change Volumes: Mount volume #%d\n", tapeno+1);
+ broadcast("CHANGE DUMP VOLUMES!\a\a\n");
+ }
+ if(!loader){
+ 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);
@@ -516,6 +529,7 @@
int childpid;
int status;
int waitpid;
+ int retval;
char *p;
#ifdef sunos
void (*interrupt_save)();
@@ -615,9 +629,18 @@
open(tape, O_WRONLY|O_CREAT, 0666))) < 0)
#endif
{
- msg("Cannot open output \"%s\".\n", tape);
- if (!query("Do you want to retry the open?"))
- dumpabort(0);
+ if (!loader){
+ msg("Cannot open output \"%s\".\n", tape);
+ if (!query("Do you want to retry the open?"))
+ dumpabort(0);
+ } else { /* Use Autoloader script */
+ msg("Calling %s for volume #%d (%d)\n", LOADERSCRIPT,
+tapeno+1, nexttape);
+ retval = system(LOADERSCRIPT);
+ if (retval != 0){
+ msg("ERROR: Loader script failed (returned %d)
+-- ABORTING\n", retval);
+ dumpabort(0);
+ }
+ }
}
enslave(); /* Share open tape file descriptor with slaves */
#!/usr/local/bin/zsh
TAPEFILE=/tmp/dumptape
CHIOCMD="rsh dev chio move"
MTREWCMD="rsh dev mt rew"
if [ ! -e $TAPEFILE ]; then
TAPENO=0
else
TAPENO=`cat $TAPEFILE`
echo Moving tape $TAPENO from drive into slot
eval $CHIOCMD drive 0 slot $TAPENO
TAPENO=$[ $TAPENO + 1]
fi
if [ $TAPENO -gt 7 ]; then
echo No more tapes in device
exit 1
fi
echo -n $TAPENO > $TAPEFILE
echo Moving tape $TAPENO from slot to drive
eval $CHIOCMD slot $TAPENO drive 0
echo Rewinding tape $TAPENO
eval $MTREW
echo Stating tape device
eval rsh dev mt stat