summaryrefslogtreecommitdiffstats
path: root/sbin/restore/tape.c
diff options
context:
space:
mode:
authoriedowse <iedowse@FreeBSD.org>2000-12-12 12:04:02 +0000
committeriedowse <iedowse@FreeBSD.org>2000-12-12 12:04:02 +0000
commita507515e083a208609badf2032b1cf4a61571fc5 (patch)
tree94a9260b8ef2a70ef3a47ebefed8a70ab8b5ea54 /sbin/restore/tape.c
parent513cdb008249fa2a1faeb31a407c87138df1cd2b (diff)
downloadFreeBSD-src-a507515e083a208609badf2032b1cf4a61571fc5.zip
FreeBSD-src-a507515e083a208609badf2032b1cf4a61571fc5.tar.gz
Stop restore from looping under certain error conditions. This
corrects cases where restore would spew an infinite stream of "Changing volumes on pipe input?" messages, or would loop waiting for a response to the "set owner/mode for '.'" question. PR: bin/14250 Reviewed by: dwmalone
Diffstat (limited to 'sbin/restore/tape.c')
-rw-r--r--sbin/restore/tape.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/sbin/restore/tape.c b/sbin/restore/tape.c
index 89b8b29..fdae506 100644
--- a/sbin/restore/tape.c
+++ b/sbin/restore/tape.c
@@ -307,8 +307,12 @@ getvol(nextvol)
gettingfile = 0;
}
if (pipein) {
- if (nextvol != 1)
+ if (nextvol != 1) {
panic("Changing volumes on pipe input?\n");
+ /* Avoid looping if we couldn't ask the user. */
+ if (yflag || ferror(terminal) || feof(terminal))
+ done(1);
+ }
if (volno == 1)
return;
goto gethdr;
@@ -345,10 +349,9 @@ again:
do {
fprintf(stderr, "Specify next volume #: ");
(void) fflush(stderr);
- (void) fgets(buf, BUFSIZ, terminal);
- } while (!feof(terminal) && buf[0] == '\n');
- if (feof(terminal))
- done(1);
+ if (fgets(buf, BUFSIZ, terminal) == NULL)
+ done(1);
+ } while (buf[0] == '\n');
newvol = atoi(buf);
if (newvol <= 0) {
fprintf(stderr,
@@ -364,8 +367,7 @@ again:
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))
+ if (fgets(buf, BUFSIZ, terminal) == NULL)
done(1);
if (!strcmp(buf, "none\n")) {
terminateinput();
OpenPOWER on IntegriCloud