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
This commit is contained in:
parent
040639a0aa
commit
5a59cccc61
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=69906
@ -325,12 +325,11 @@ getcmd(curdir, cmd, name, size, ap)
|
|||||||
do {
|
do {
|
||||||
fprintf(stderr, "restore > ");
|
fprintf(stderr, "restore > ");
|
||||||
(void) fflush(stderr);
|
(void) fflush(stderr);
|
||||||
(void) fgets(input, BUFSIZ, terminal);
|
if (fgets(input, BUFSIZ, terminal) == NULL) {
|
||||||
} while (!feof(terminal) && input[0] == '\n');
|
strcpy(cmd, "quit");
|
||||||
if (feof(terminal)) {
|
return;
|
||||||
(void) strcpy(cmd, "quit");
|
}
|
||||||
return;
|
} while (input[0] == '\n');
|
||||||
}
|
|
||||||
for (cp = &input[strlen(input) - 2]; *cp == ' ' || *cp == '\t'; cp--)
|
for (cp = &input[strlen(input) - 2]; *cp == ' ' || *cp == '\t'; cp--)
|
||||||
/* trim off trailing white space and newline */;
|
/* trim off trailing white space and newline */;
|
||||||
*++cp = '\0';
|
*++cp = '\0';
|
||||||
|
@ -307,8 +307,12 @@ getvol(nextvol)
|
|||||||
gettingfile = 0;
|
gettingfile = 0;
|
||||||
}
|
}
|
||||||
if (pipein) {
|
if (pipein) {
|
||||||
if (nextvol != 1)
|
if (nextvol != 1) {
|
||||||
panic("Changing volumes on pipe input?\n");
|
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)
|
if (volno == 1)
|
||||||
return;
|
return;
|
||||||
goto gethdr;
|
goto gethdr;
|
||||||
@ -345,10 +349,9 @@ getvol(nextvol)
|
|||||||
do {
|
do {
|
||||||
fprintf(stderr, "Specify next volume #: ");
|
fprintf(stderr, "Specify next volume #: ");
|
||||||
(void) fflush(stderr);
|
(void) fflush(stderr);
|
||||||
(void) fgets(buf, BUFSIZ, terminal);
|
if (fgets(buf, BUFSIZ, terminal) == NULL)
|
||||||
} while (!feof(terminal) && buf[0] == '\n');
|
done(1);
|
||||||
if (feof(terminal))
|
} while (buf[0] == '\n');
|
||||||
done(1);
|
|
||||||
newvol = atoi(buf);
|
newvol = atoi(buf);
|
||||||
if (newvol <= 0) {
|
if (newvol <= 0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@ -364,8 +367,7 @@ getvol(nextvol)
|
|||||||
fprintf(stderr, "Enter ``none'' if there are no more tapes\n");
|
fprintf(stderr, "Enter ``none'' if there are no more tapes\n");
|
||||||
fprintf(stderr, "otherwise enter tape name (default: %s) ", magtape);
|
fprintf(stderr, "otherwise enter tape name (default: %s) ", magtape);
|
||||||
(void) fflush(stderr);
|
(void) fflush(stderr);
|
||||||
(void) fgets(buf, BUFSIZ, terminal);
|
if (fgets(buf, BUFSIZ, terminal) == NULL)
|
||||||
if (feof(terminal))
|
|
||||||
done(1);
|
done(1);
|
||||||
if (!strcmp(buf, "none\n")) {
|
if (!strcmp(buf, "none\n")) {
|
||||||
terminateinput();
|
terminateinput();
|
||||||
|
@ -405,14 +405,14 @@ int
|
|||||||
reply(question)
|
reply(question)
|
||||||
char *question;
|
char *question;
|
||||||
{
|
{
|
||||||
char c;
|
int c;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
fprintf(stderr, "%s? [yn] ", question);
|
fprintf(stderr, "%s? [yn] ", question);
|
||||||
(void) fflush(stderr);
|
(void) fflush(stderr);
|
||||||
c = getc(terminal);
|
c = getc(terminal);
|
||||||
while (c != '\n' && getc(terminal) != '\n')
|
while (c != '\n' && getc(terminal) != '\n')
|
||||||
if (feof(terminal))
|
if (c == EOF)
|
||||||
return (FAIL);
|
return (FAIL);
|
||||||
} while (c != 'y' && c != 'n');
|
} while (c != 'y' && c != 'n');
|
||||||
if (c == 'y')
|
if (c == 'y')
|
||||||
|
Loading…
Reference in New Issue
Block a user