* 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@cybercable.fr>, 1999
+ * Stelian Pop <pop@cybercable.fr>, 1999-2000
*/
/*
#ifndef lint
static const char rcsid[] =
- "$Id: tape.c,v 1.8 1999/11/11 16:14:01 tiniou Exp $";
+ "$Id: tape.c,v 1.12 2000/03/01 10:16:05 stelian Exp $";
#endif /* not lint */
#include <sys/param.h>
static long fssize = MAXBSIZE;
static int mt = -1;
static int pipein = 0;
-static char *magtape;
+static char magtape[MAXPATHLEN];
+static char magtapeprefix[MAXPATHLEN];
static int blkcnt;
static int numtrec;
static char *tapebuf;
pipein++;
}
setuid(getuid()); /* no longer need or want root privileges */
- magtape = strdup(source);
- if (magtape == NULL)
- errx(1, "Cannot allocate space for magtape buffer");
+ if (Mflag) {
+ strncpy(magtapeprefix, source, MAXPATHLEN);
+ magtapeprefix[MAXPATHLEN-1] = '\0';
+ snprintf(magtape, MAXPATHLEN, "%s%03d", source, 1);
+ }
+ else
+ strncpy(magtape, source, MAXPATHLEN);
+ magtape[MAXPATHLEN - 1] = '\0';
}
void
if (spcl.c_type != TS_CLRI)
errx(1, "Cannot find file removal list");
maxino = (spcl.c_count * TP_BSIZE * NBBY) + 1;
- Dprintf(stdout, "maxino = %ld\n", maxino);
+ Dprintf(stdout, "maxino = %ld\n", (long)maxino);
map = calloc((unsigned)1, (unsigned)howmany(maxino, NBBY));
if (map == NULL)
panic("no memory for active inode map\n");
union u_spcl tmpspcl;
# define tmpbuf tmpspcl.s_spcl
char buf[TP_BSIZE];
+ int haderror = 0;
if (nextvol == 1) {
tapesread = 0;
return;
}
closemt();
- fprintf(stderr, "Mount tape volume %ld\n", (long)newvol);
- fprintf(stderr, "Enter ``none'' if there are no more tapes\n");
- fprintf(stderr, "otherwise enter tape name (default: %s) ", magtape);
- (void) fflush(stderr);
- (void) fgets(buf, BUFSIZ, terminal);
- if (feof(terminal))
- exit(1);
- if (!strcmp(buf, "none\n")) {
- terminateinput();
- return;
+ if (Mflag) {
+ snprintf(magtape, MAXPATHLEN, "%s%03ld", magtapeprefix, newvol);
+ magtape[MAXPATHLEN - 1] = '\0';
}
- if (buf[0] != '\n') {
- (void) strcpy(magtape, buf);
- magtape[strlen(magtape) - 1] = '\0';
+ if (!Mflag || haderror) {
+ haderror = 0;
+ fprintf(stderr, "Mount tape volume %ld\n", (long)newvol);
+ fprintf(stderr, "Enter ``none'' if there are no more tapes\n");
+ fprintf(stderr, "otherwise enter tape name (default: %s) ", magtape);
+ (void) fflush(stderr);
+ (void) fgets(buf, BUFSIZ, terminal);
+ if (feof(terminal))
+ exit(1);
+ if (!strcmp(buf, "none\n")) {
+ terminateinput();
+ return;
+ }
+ if (buf[0] != '\n') {
+ (void) strcpy(magtape, buf);
+ magtape[strlen(magtape) - 1] = '\0';
+ }
}
#ifdef RRESTORE
if (host)
if (mt == -1) {
fprintf(stderr, "Cannot open %s\n", magtape);
volno = -1;
+ haderror = 1;
goto again;
}
gethdr:
Dprintf(stdout, "header read failed at %ld blocks\n", (long)blksread);
fprintf(stderr, "tape is not dump tape\n");
volno = 0;
+ haderror = 1;
goto again;
}
if (tmpbuf.c_volume != volno) {
fprintf(stderr, "Wrong volume (%d)\n", tmpbuf.c_volume);
volno = 0;
+ haderror = 1;
goto again;
}
if (tmpbuf.c_date != dumpdate || tmpbuf.c_ddate != dumptime) {
fprintf(stderr, "\twanted: %s", ctime(&dumpdate));
#endif
volno = 0;
+ haderror = 1;
goto again;
}
tapesread |= 1 << volno;
fprintf(stderr, "File header, ino %lu", (unsigned long)previno);
break;
case TS_ADDR:
- fprintf(stderr, "File continuation header, ino %ld", previno);
+ fprintf(stderr, "File continuation header, ino %ld", (long)previno);
break;
case TS_END:
fprintf(stderr, "End of tape header");