X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=restore%2Ftape.c;h=3db8f07fe5618d63bf7d6f354157b342697c5f0d;hp=2bb447239bed286d20afbe0de2cb57f2afdf7215;hb=900bffdb4fb7cf14ada66e3a0c81b1275cc7571f;hpb=5bf65105dbaf0bb3d6fb4ccb3d8790bda496d861 diff --git a/restore/tape.c b/restore/tape.c index 2bb4472..3db8f07 100644 --- a/restore/tape.c +++ b/restore/tape.c @@ -46,7 +46,7 @@ #ifndef lint static const char rcsid[] = - "$Id: tape.c,v 1.67 2003/01/10 14:42:51 stelian Exp $"; + "$Id: tape.c,v 1.70 2003/02/12 11:02:30 stelian Exp $"; #endif /* not lint */ #include @@ -286,7 +286,7 @@ setup(void) temptape = magtape; #ifdef RRESTORE - if (host) + if (!Afile && host) mt = rmtopen(temptape, O_RDONLY); else #endif @@ -295,7 +295,7 @@ setup(void) else mt = OPEN(temptape, O_RDONLY, 0); if (mt < 0) - err(1, "%s", magtape); + err(1, "%s", temptape); if (!Afile) { volno = 1; setmagtapein(); @@ -502,6 +502,13 @@ again: return; } closemt(); + + /* + * if using an archive file, reset its name so readtape() + * could properly use remote access. + */ + Afile = NULL; + if (Mflag) { snprintf(magtape, MAXPATHLEN, "%s%03ld", magtapeprefix, newvol); magtape[MAXPATHLEN - 1] = '\0'; @@ -1266,6 +1273,16 @@ comparefile(char *name) struct STAT stemp; #endif + curfile.name = name; + curfile.action = USING; + mode = curfile.dip->di_mode; + + if ((mode & IFMT) == IFSOCK) { + Vprintf(stdout, "skipped socket %s\n", name); + skipfile(); + return; + } + if ((r = LSTAT(name, &sb)) != 0) { warn("%s: does not exist (%d)", name, r); do_compare_error; @@ -1273,10 +1290,6 @@ comparefile(char *name) return; } - curfile.name = name; - curfile.action = USING; - mode = curfile.dip->di_mode; - Vprintf(stdout, "comparing %s (size: %ld, mode: 0%o)\n", name, (long)sb.st_size, mode); @@ -1481,7 +1494,7 @@ readtape(char *buf) #endif getmore: #ifdef RRESTORE - if (host) + if (!Afile && host) i = rmtread(&tapebuf[rd], cnt); else #endif @@ -1543,7 +1556,7 @@ getmore: i = ntrec * TP_BSIZE; memset(tapebuf, 0, (size_t)i); #ifdef RRESTORE - if (host) + if (!Afile && host) seek_failed = (rmtseek(i, 1) < 0); else #endif @@ -2024,7 +2037,7 @@ static int read_a_block(int fd, char *buf, size_t len, long *lengthread) size = len; while (size > 0) { #ifdef RRESTORE - if (host) + if (!Afile && host) i = rmtread(buf, size); else #endif @@ -2048,7 +2061,7 @@ closemt(void) if (mt < 0) return; #ifdef RRESTORE - if (host) + if (!Afile && host) rmtclose(); else #endif @@ -2072,7 +2085,8 @@ setmagtapein(void) { magtapein = ioctl(mt, MTIOCGET, (char *)&mt_stat) == 0; } - Vprintf(stdout,"Input is from %s\n", + Vprintf(stdout,"Input is from a %s %s\n", + host ? "remote" : "local", magtapein ? "tape" : Vflag ? "multi-volume (no tape)" : "file/pipe"); }