]> git.wh0rd.org - dump.git/blob - restore/interactive.c
Added CVS Id.
[dump.git] / restore / interactive.c
1 /*
2 * Ported to Linux's Second Extended File System as part of the
3 * dump and restore backup suit
4 * Remy Card <card@Linux.EU.Org>, 1994-1997
5 * Stelian Pop <pop@cybercable.fr>, 1999
6 *
7 */
8
9 /*
10 * Copyright (c) 1985, 1993
11 * The Regents of the University of California. All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgement:
23 * This product includes software developed by the University of
24 * California, Berkeley and its contributors.
25 * 4. Neither the name of the University nor the names of its contributors
26 * may be used to endorse or promote products derived from this software
27 * without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * SUCH DAMAGE.
40 *
41 * $Id: interactive.c,v 1.5 1999/10/11 13:31:12 stelian Exp $
42 */
43
44 #include <sys/param.h>
45 #include <sys/stat.h>
46
47 #ifdef __linux__
48 #include <linux/ext2_fs.h>
49 #include <bsdcompat.h>
50 #else /* __linux__ */
51 #include <ufs/ufs/dinode.h>
52 #include <ufs/ufs/dir.h>
53 #endif /* __linux__ */
54 #include <protocols/dumprestore.h>
55
56 #include <setjmp.h>
57 #include <compaterr.h>
58 #include <errno.h>
59 #include <compatglob.h>
60 #include <stdio.h>
61 #include <stdlib.h>
62 #include <string.h>
63
64 #ifdef __linux__
65 #include <ext2fs/ext2fs.h>
66 extern char * __progname;
67 #endif
68
69 #include "restore.h"
70 #include "extern.h"
71
72 #define round(a, b) (((a) + (b) - 1) / (b) * (b))
73
74 /*
75 * Things to handle interruptions.
76 */
77 static int runshell;
78 static jmp_buf reset;
79 static char *nextarg = NULL;
80
81 /*
82 * Structure and routines associated with listing directories.
83 */
84 struct afile {
85 ino_t fnum; /* inode number of file */
86 char *fname; /* file name */
87 short len; /* name length */
88 char prefix; /* prefix character */
89 char postfix; /* postfix character */
90 };
91 struct arglist {
92 int freeglob; /* glob structure needs to be freed */
93 int argcnt; /* next globbed argument to return */
94 glob_t glob; /* globbing information */
95 char *cmd; /* the current command */
96 };
97
98 static char *copynext __P((char *, char *));
99 static int fcmp __P((const void *, const void *));
100 static void formatf __P((struct afile *, int));
101 static void getcmd __P((char *, char *, char *, int, struct arglist *));
102 struct dirent *glob_readdir __P((RST_DIR *dirp));
103 static int glob_stat __P((const char *, struct stat *));
104 static void mkentry __P((char *, struct direct *, struct afile *));
105 static void printlist __P((char *, char *));
106
107 /*
108 * Read and execute commands from the terminal.
109 */
110 void
111 runcmdshell(void)
112 {
113 register struct entry *np;
114 ino_t ino;
115 struct arglist arglist;
116 char curdir[MAXPATHLEN];
117 char name[MAXPATHLEN];
118 char cmd[BUFSIZ];
119
120 arglist.freeglob = 0;
121 arglist.argcnt = 0;
122 arglist.glob.gl_flags = GLOB_ALTDIRFUNC;
123 arglist.glob.gl_opendir = (void *)rst_opendir;
124 arglist.glob.gl_readdir = (void *)glob_readdir;
125 arglist.glob.gl_closedir = (void *)rst_closedir;
126 arglist.glob.gl_lstat = glob_stat;
127 arglist.glob.gl_stat = glob_stat;
128 canon("/", curdir, sizeof(curdir));
129 loop:
130 if (setjmp(reset) != 0) {
131 if (arglist.freeglob != 0) {
132 arglist.freeglob = 0;
133 arglist.argcnt = 0;
134 globfree(&arglist.glob);
135 }
136 nextarg = NULL;
137 volno = 0;
138 }
139 runshell = 1;
140 getcmd(curdir, cmd, name, sizeof(name), &arglist);
141 switch (cmd[0]) {
142 /*
143 * Add elements to the extraction list.
144 */
145 case 'a':
146 if (strncmp(cmd, "add", strlen(cmd)) != 0)
147 goto bad;
148 ino = dirlookup(name);
149 if (ino == 0)
150 break;
151 if (mflag)
152 pathcheck(name);
153 treescan(name, ino, addfile);
154 break;
155 /*
156 * Change working directory.
157 */
158 case 'c':
159 if (strncmp(cmd, "cd", strlen(cmd)) != 0)
160 goto bad;
161 ino = dirlookup(name);
162 if (ino == 0)
163 break;
164 if (inodetype(ino) == LEAF) {
165 fprintf(stderr, "%s: not a directory\n", name);
166 break;
167 }
168 (void) strncpy(curdir, name, sizeof(curdir));
169 curdir[sizeof(curdir) - 1] = '\0';
170 break;
171 /*
172 * Delete elements from the extraction list.
173 */
174 case 'd':
175 if (strncmp(cmd, "delete", strlen(cmd)) != 0)
176 goto bad;
177 np = lookupname(name);
178 if (np == NULL || (np->e_flags & NEW) == 0) {
179 fprintf(stderr, "%s: not on extraction list\n", name);
180 break;
181 }
182 treescan(name, np->e_ino, deletefile);
183 break;
184 /*
185 * Extract the requested list.
186 */
187 case 'e':
188 if (strncmp(cmd, "extract", strlen(cmd)) != 0)
189 goto bad;
190 createfiles();
191 createlinks();
192 setdirmodes(0);
193 if (dflag)
194 checkrestore();
195 volno = 0;
196 break;
197 /*
198 * List available commands.
199 */
200 case 'h':
201 if (strncmp(cmd, "help", strlen(cmd)) != 0)
202 goto bad;
203 case '?':
204 fprintf(stderr, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
205 "Available commands are:\n",
206 "\tls [arg] - list directory\n",
207 "\tcd arg - change directory\n",
208 "\tpwd - print current directory\n",
209 "\tadd [arg] - add `arg' to list of",
210 " files to be extracted\n",
211 "\tdelete [arg] - delete `arg' from",
212 " list of files to be extracted\n",
213 "\textract - extract requested files\n",
214 "\tsetmodes - set modes of requested directories\n",
215 "\tquit - immediately exit program\n",
216 "\twhat - list dump header information\n",
217 "\tverbose - toggle verbose flag",
218 " (useful with ``ls'')\n",
219 "\thelp or `?' - print this list\n",
220 "If no `arg' is supplied, the current",
221 " directory is used\n");
222 break;
223 /*
224 * List a directory.
225 */
226 case 'l':
227 if (strncmp(cmd, "ls", strlen(cmd)) != 0)
228 goto bad;
229 printlist(name, curdir);
230 break;
231 /*
232 * Print current directory.
233 */
234 case 'p':
235 if (strncmp(cmd, "pwd", strlen(cmd)) != 0)
236 goto bad;
237 if (curdir[1] == '\0')
238 fprintf(stderr, "/\n");
239 else
240 fprintf(stderr, "%s\n", &curdir[1]);
241 break;
242 /*
243 * Quit.
244 */
245 case 'q':
246 if (strncmp(cmd, "quit", strlen(cmd)) != 0)
247 goto bad;
248 return;
249 case 'x':
250 if (strncmp(cmd, "xit", strlen(cmd)) != 0)
251 goto bad;
252 return;
253 /*
254 * Toggle verbose mode.
255 */
256 case 'v':
257 if (strncmp(cmd, "verbose", strlen(cmd)) != 0)
258 goto bad;
259 if (vflag) {
260 fprintf(stderr, "verbose mode off\n");
261 vflag = 0;
262 break;
263 }
264 fprintf(stderr, "verbose mode on\n");
265 vflag++;
266 break;
267 /*
268 * Just restore requested directory modes.
269 */
270 case 's':
271 if (strncmp(cmd, "setmodes", strlen(cmd)) != 0)
272 goto bad;
273 setdirmodes(FORCE);
274 break;
275 /*
276 * Print out dump header information.
277 */
278 case 'w':
279 if (strncmp(cmd, "what", strlen(cmd)) != 0)
280 goto bad;
281 printdumpinfo();
282 break;
283 /*
284 * Turn on debugging.
285 */
286 case 'D':
287 if (strncmp(cmd, "Debug", strlen(cmd)) != 0)
288 goto bad;
289 if (dflag) {
290 fprintf(stderr, "debugging mode off\n");
291 dflag = 0;
292 break;
293 }
294 fprintf(stderr, "debugging mode on\n");
295 dflag++;
296 break;
297 /*
298 * Unknown command.
299 */
300 default:
301 bad:
302 fprintf(stderr, "%s: unknown command; type ? for help\n", cmd);
303 break;
304 }
305 goto loop;
306 }
307
308 /*
309 * Read and parse an interactive command.
310 * The first word on the line is assigned to "cmd". If
311 * there are no arguments on the command line, then "curdir"
312 * is returned as the argument. If there are arguments
313 * on the line they are returned one at a time on each
314 * successive call to getcmd. Each argument is first assigned
315 * to "name". If it does not start with "/" the pathname in
316 * "curdir" is prepended to it. Finally "canon" is called to
317 * eliminate any embedded ".." components.
318 */
319 static void
320 getcmd(char *curdir, char *cmd, char *name, int size, struct arglist *ap)
321 {
322 register char *cp;
323 static char input[BUFSIZ];
324 char output[BUFSIZ];
325 # define rawname input /* save space by reusing input buffer */
326
327 /*
328 * Check to see if still processing arguments.
329 */
330 if (ap->argcnt > 0)
331 goto retnext;
332 if (nextarg != NULL)
333 goto getnext;
334 /*
335 * Read a command line and trim off trailing white space.
336 */
337 do {
338 fprintf(stderr, "%s > ", __progname);
339 (void) fflush(stderr);
340 (void) fgets(input, BUFSIZ, terminal);
341 } while (!feof(terminal) && input[0] == '\n');
342 if (feof(terminal)) {
343 (void) strcpy(cmd, "quit");
344 return;
345 }
346 for (cp = &input[strlen(input) - 2]; *cp == ' ' || *cp == '\t'; cp--)
347 /* trim off trailing white space and newline */;
348 *++cp = '\0';
349 /*
350 * Copy the command into "cmd".
351 */
352 cp = copynext(input, cmd);
353 ap->cmd = cmd;
354 /*
355 * If no argument, use curdir as the default.
356 */
357 if (*cp == '\0') {
358 (void) strncpy(name, curdir, size);
359 name[size - 1] = '\0';
360 return;
361 }
362 nextarg = cp;
363 /*
364 * Find the next argument.
365 */
366 getnext:
367 cp = copynext(nextarg, rawname);
368 if (*cp == '\0')
369 nextarg = NULL;
370 else
371 nextarg = cp;
372 /*
373 * If it is an absolute pathname, canonicalize it and return it.
374 */
375 if (rawname[0] == '/') {
376 canon(rawname, name, size);
377 } else {
378 /*
379 * For relative pathnames, prepend the current directory to
380 * it then canonicalize and return it.
381 */
382 snprintf(output, sizeof(output), "%s/%s", curdir, rawname);
383 canon(output, name, size);
384 }
385 if (glob(name, GLOB_ALTDIRFUNC, NULL, &ap->glob) < 0)
386 fprintf(stderr, "%s: out of memory\n", ap->cmd);
387 if (ap->glob.gl_pathc == 0)
388 return;
389 ap->freeglob = 1;
390 ap->argcnt = ap->glob.gl_pathc;
391
392 retnext:
393 strncpy(name, ap->glob.gl_pathv[ap->glob.gl_pathc - ap->argcnt], size);
394 name[size - 1] = '\0';
395 if (--ap->argcnt == 0) {
396 ap->freeglob = 0;
397 globfree(&ap->glob);
398 }
399 # undef rawname
400 }
401
402 /*
403 * Strip off the next token of the input.
404 */
405 static char *
406 copynext(char *input, char *output)
407 {
408 register char *cp, *bp;
409 char quote;
410
411 for (cp = input; *cp == ' ' || *cp == '\t'; cp++)
412 /* skip to argument */;
413 bp = output;
414 while (*cp != ' ' && *cp != '\t' && *cp != '\0') {
415 /*
416 * Handle back slashes.
417 */
418 if (*cp == '\\') {
419 if (*++cp == '\0') {
420 fprintf(stderr,
421 "command lines cannot be continued\n");
422 continue;
423 }
424 *bp++ = *cp++;
425 continue;
426 }
427 /*
428 * The usual unquoted case.
429 */
430 if (*cp != '\'' && *cp != '"') {
431 *bp++ = *cp++;
432 continue;
433 }
434 /*
435 * Handle single and double quotes.
436 */
437 quote = *cp++;
438 while (*cp != quote && *cp != '\0')
439 *bp++ = *cp++ | 0200;
440 if (*cp++ == '\0') {
441 fprintf(stderr, "missing %c\n", quote);
442 cp--;
443 continue;
444 }
445 }
446 *bp = '\0';
447 return (cp);
448 }
449
450 /*
451 * Canonicalize file names to always start with ``./'' and
452 * remove any embedded "." and ".." components.
453 */
454 void
455 canon(char *rawname, char *canonname, int len)
456 {
457 register char *cp, *np;
458
459 if (strcmp(rawname, ".") == 0 || strncmp(rawname, "./", 2) == 0)
460 (void) strcpy(canonname, "");
461 else if (rawname[0] == '/')
462 (void) strcpy(canonname, ".");
463 else
464 (void) strcpy(canonname, "./");
465 if (strlen(canonname) + strlen(rawname) >= len)
466 errx(1, "canonname: not enough buffer space");
467
468 (void) strcat(canonname, rawname);
469 /*
470 * Eliminate multiple and trailing '/'s
471 */
472 for (cp = np = canonname; *np != '\0'; cp++) {
473 *cp = *np++;
474 while (*cp == '/' && *np == '/')
475 np++;
476 }
477 *cp = '\0';
478 if (*--cp == '/')
479 *cp = '\0';
480 /*
481 * Eliminate extraneous "." and ".." from pathnames.
482 */
483 for (np = canonname; *np != '\0'; ) {
484 np++;
485 cp = np;
486 while (*np != '/' && *np != '\0')
487 np++;
488 if (np - cp == 1 && *cp == '.') {
489 cp--;
490 (void) strcpy(cp, np);
491 np = cp;
492 }
493 if (np - cp == 2 && strncmp(cp, "..", 2) == 0) {
494 cp--;
495 while (cp > &canonname[1] && *--cp != '/')
496 /* find beginning of name */;
497 (void) strcpy(cp, np);
498 np = cp;
499 }
500 }
501 }
502
503 /*
504 * Do an "ls" style listing of a directory
505 */
506 static void
507 printlist(char *name, char *basename)
508 {
509 register struct afile *fp, *list, *listp = NULL;
510 register struct direct *dp;
511 struct afile single;
512 RST_DIR *dirp;
513 int entries, len, namelen;
514 char locname[MAXPATHLEN + 1];
515
516 dp = pathsearch(name);
517 if (dp == NULL || (!dflag && TSTINO(dp->d_ino, dumpmap) == 0) ||
518 (!vflag && dp->d_ino == WINO))
519 return;
520 if ((dirp = rst_opendir(name)) == NULL) {
521 entries = 1;
522 list = &single;
523 mkentry(name, dp, list);
524 len = strlen(basename) + 1;
525 if (strlen(name) - len > single.len) {
526 freename(single.fname);
527 single.fname = savename(&name[len]);
528 single.len = strlen(single.fname);
529 }
530 } else {
531 entries = 0;
532 while ((dp = rst_readdir(dirp)))
533 entries++;
534 rst_closedir(dirp);
535 list = (struct afile *)malloc(entries * sizeof(struct afile));
536 if (list == NULL) {
537 fprintf(stderr, "ls: out of memory\n");
538 return;
539 }
540 if ((dirp = rst_opendir(name)) == NULL)
541 panic("directory reopen failed\n");
542 fprintf(stderr, "%s:\n", name);
543 entries = 0;
544 listp = list;
545 namelen = snprintf(locname, sizeof(locname), "%s/", name);
546 if (namelen >= sizeof(locname))
547 namelen = sizeof(locname) - 1;
548 while ((dp = rst_readdir(dirp))) {
549 if (dp == NULL)
550 break;
551 if (!dflag && TSTINO(dp->d_ino, dumpmap) == 0)
552 continue;
553 if (!vflag && (dp->d_ino == WINO ||
554 strcmp(dp->d_name, ".") == 0 ||
555 strcmp(dp->d_name, "..") == 0))
556 continue;
557 locname[namelen] = '\0';
558 if (namelen + strlen(dp->d_name) >= MAXPATHLEN) {
559 fprintf(stderr, "%s%s: name exceeds %d char\n",
560 locname, dp->d_name, MAXPATHLEN);
561 } else {
562 (void) strncat(locname, dp->d_name,
563 (int)strlen(dp->d_name));
564 mkentry(locname, dp, listp++);
565 entries++;
566 }
567 }
568 rst_closedir(dirp);
569 if (entries == 0) {
570 fprintf(stderr, "\n");
571 free(list);
572 return;
573 }
574 qsort((char *)list, entries, sizeof(struct afile), fcmp);
575 }
576 formatf(list, entries);
577 if (dirp != NULL) {
578 for (fp = listp - 1; fp >= list; fp--)
579 freename(fp->fname);
580 fprintf(stderr, "\n");
581 free(list);
582 }
583 }
584
585 /*
586 * Read the contents of a directory.
587 */
588 static void
589 mkentry(char *name, struct direct *dp, struct afile *fp)
590 {
591 char *cp;
592 struct entry *np;
593
594 fp->fnum = dp->d_ino;
595 fp->fname = savename(dp->d_name);
596 for (cp = fp->fname; *cp; cp++)
597 if (!vflag && (*cp < ' ' || *cp >= 0177))
598 *cp = '?';
599 fp->len = cp - fp->fname;
600 if (dflag && TSTINO(fp->fnum, dumpmap) == 0)
601 fp->prefix = '^';
602 else if ((np = lookupname(name)) != NULL && (np->e_flags & NEW))
603 fp->prefix = '*';
604 else
605 fp->prefix = ' ';
606 switch(dp->d_type) {
607
608 default:
609 fprintf(stderr, "Warning: undefined file type %d\n",
610 dp->d_type);
611 /* fall through */
612 case DT_REG:
613 fp->postfix = ' ';
614 break;
615
616 case DT_LNK:
617 fp->postfix = '@';
618 break;
619
620 case DT_FIFO:
621 case DT_SOCK:
622 fp->postfix = '=';
623 break;
624
625 case DT_CHR:
626 case DT_BLK:
627 fp->postfix = '#';
628 break;
629
630 #ifndef __linux__
631 /* no need for this */
632 case DT_WHT:
633 fp->postfix = '%';
634 break;
635 #endif
636
637 case DT_UNKNOWN:
638 case DT_DIR:
639 if (inodetype(dp->d_ino) == NODE)
640 fp->postfix = '/';
641 else
642 fp->postfix = ' ';
643 break;
644 }
645 return;
646 }
647
648 /*
649 * Print out a pretty listing of a directory
650 */
651 static void
652 formatf(struct afile *list, int nentry)
653 {
654 register struct afile *fp, *endlist;
655 int width, bigino, haveprefix, havepostfix;
656 int i, j, w, precision = 0, columns, lines;
657
658 width = 0;
659 haveprefix = 0;
660 havepostfix = 0;
661 bigino = ROOTINO;
662 endlist = &list[nentry];
663 for (fp = &list[0]; fp < endlist; fp++) {
664 if (bigino < fp->fnum)
665 bigino = fp->fnum;
666 if (width < fp->len)
667 width = fp->len;
668 if (fp->prefix != ' ')
669 haveprefix = 1;
670 if (fp->postfix != ' ')
671 havepostfix = 1;
672 }
673 if (haveprefix)
674 width++;
675 if (havepostfix)
676 width++;
677 if (vflag) {
678 for (precision = 0, i = bigino; i > 0; i /= 10)
679 precision++;
680 width += precision + 1;
681 }
682 width++;
683 columns = 81 / width;
684 if (columns == 0)
685 columns = 1;
686 lines = (nentry + columns - 1) / columns;
687 for (i = 0; i < lines; i++) {
688 for (j = 0; j < columns; j++) {
689 fp = &list[j * lines + i];
690 if (vflag) {
691 fprintf(stderr, "%*ld ", precision, fp->fnum);
692 fp->len += precision + 1;
693 }
694 if (haveprefix) {
695 putc(fp->prefix, stderr);
696 fp->len++;
697 }
698 fprintf(stderr, "%s", fp->fname);
699 if (havepostfix) {
700 putc(fp->postfix, stderr);
701 fp->len++;
702 }
703 if (fp + lines >= endlist) {
704 fprintf(stderr, "\n");
705 break;
706 }
707 for (w = fp->len; w < width; w++)
708 putc(' ', stderr);
709 }
710 }
711 }
712
713 /*
714 * Skip over directory entries that are not on the tape
715 *
716 * First have to get definition of a dirent.
717 *
718 * For Linux the dirent struct is now included from bsdcompat.h
719 */
720 #ifndef __linux__
721 #undef DIRBLKSIZ
722 #include <dirent.h>
723 #undef d_ino
724 #endif /* ! __linux__ */
725
726 struct dirent *
727 glob_readdir(RST_DIR *dirp)
728 {
729 struct direct *dp;
730 static struct dirent adirent;
731
732 while ((dp = rst_readdir(dirp)) != NULL) {
733 if (!vflag && dp->d_ino == WINO)
734 continue;
735 if (dflag || TSTINO(dp->d_ino, dumpmap))
736 break;
737 }
738 if (dp == NULL)
739 return (NULL);
740 adirent.d_fileno = dp->d_ino;
741 memmove(adirent.d_name, dp->d_name, dp->d_namlen + 1);
742 return (&adirent);
743 }
744
745 /*
746 * Return st_mode information in response to stat or lstat calls
747 */
748 static int
749 glob_stat(const char *name, struct stat *stp)
750 {
751 register struct direct *dp;
752 dp = pathsearch(name);
753 if (dp == NULL || (!dflag && TSTINO(dp->d_ino, dumpmap) == 0) ||
754 (!vflag && dp->d_ino == WINO))
755 return (-1);
756 if (inodetype(dp->d_ino) == NODE)
757 stp->st_mode = IFDIR;
758 else
759 stp->st_mode = IFREG;
760 return (0);
761 }
762
763 /*
764 * Comparison routine for qsort.
765 */
766 static int
767 fcmp(const void *f1, const void *f2)
768 {
769 return (strcmp(((struct afile *)f1)->fname,
770 ((struct afile *)f2)->fname));
771 }
772
773 /*
774 * respond to interrupts
775 */
776 void
777 onintr(int signo)
778 {
779 int save_errno = errno;
780
781 if (command == 'i' && runshell)
782 longjmp(reset, 1);
783 if (reply("restore interrupted, continue") == FAIL)
784 exit(1);
785 errno = save_errno;
786 }