Index: sbin/restore/symtab.c =================================================================== --- sbin/restore/symtab.c (Revision 202551) +++ sbin/restore/symtab.c (Arbeitskopie) @@ -446,7 +446,10 @@ vprintf(stdout, "Check pointing the restore\n"); if (Nflag) return; - if ((fd = fopen(filename, "w")) == NULL) { + do { + fd = fopen(filename, "w"); + } while ((fd == NULL) && (errno == EINTR)); + if (fd == NULL) { fprintf(stderr, "fopen: %s\n", strerror(errno)); panic("cannot create save file %s for symbol table\n", filename); @@ -529,7 +532,7 @@ struct symtableheader hdr; struct stat stbuf; long i; - int fd; + int fd, ret_val; vprintf(stdout, "Initialize symbol table.\n"); if (filename == NULL) { @@ -542,7 +545,10 @@ ep->e_flags |= NEW; return; } - if ((fd = open(filename, O_RDONLY, 0)) < 0) { + do { + fd = open(filename, O_RDONLY, 0); + } while ((fd == -1) && (errno == EINTR)); + if (fd < 0) { fprintf(stderr, "open: %s\n", strerror(errno)); panic("cannot open symbol table file %s\n", filename); } @@ -554,11 +560,20 @@ base = calloc(sizeof(char), (unsigned)tblsize); if (base == NULL) panic("cannot allocate space for symbol table\n"); - if (read(fd, base, (int)tblsize) < 0 || - read(fd, (char *)&hdr, sizeof(struct symtableheader)) < 0) { + do { + ret_val = read(fd, base, (int)tblsize); + } while ((ret_val == -1) && (errno == EINTR)); + if (ret_val == -1) { fprintf(stderr, "read: %s\n", strerror(errno)); panic("cannot read symbol table file %s\n", filename); } + do { + ret_val = read(fd, (char *)&hdr, sizeof(struct symtableheader)); + } while ((ret_val == -1) && (errno == EINTR)); + if (ret_val == -1) { + fprintf(stderr, "read: %s\n", strerror(errno)); + panic("cannot read symbol table file %s\n", filename); + } switch (command) { case 'r': /* Index: sbin/restore/dirs.c =================================================================== --- sbin/restore/dirs.c (Revision 202551) +++ sbin/restore/dirs.c (Arbeitskopie) @@ -143,11 +143,19 @@ if (command != 'r' && command != 'R') { (void *) strcat(dirfile, "-XXXXXX"); fd = mkstemp(dirfile); - } else - fd = open(dirfile, O_RDWR|O_CREAT|O_EXCL, 0666); - if (fd == -1 || (df = fdopen(fd, "w")) == NULL) { + } else { + do { + fd = open(dirfile, O_RDWR|O_CREAT|O_EXCL, 0666); + } while ((fd == -1) && (errno == EINTR)); + } + if (fd != -1) { + do { + df = fdopen(fd, "w"); + } while ((df == NULL) && (errno == EINTR)); + } + if (fd == -1 || df == NULL) { if (fd != -1) - close(fd); + while ((close(fd) == -1) && (errno == EINTR)) /* nop */; warn("%s: cannot create directory database", dirfile); done(1); } @@ -156,11 +164,20 @@ if (command != 'r' && command != 'R') { (void *) strcat(modefile, "-XXXXXX"); fd = mkstemp(modefile); - } else - fd = open(modefile, O_RDWR|O_CREAT|O_EXCL, 0666); - if (fd == -1 || (mf = fdopen(fd, "w")) == NULL) { + } else { + do { + fd = open(modefile, O_RDWR|O_CREAT|O_EXCL, 0666); + } while ((fd == -1) && (errno == EINTR)); + } + if (fd != -1) { + do { + mf = fdopen(fd, "w"); + } while ((mf == NULL) && (errno == EINTR)); + } + if (fd == -1 || mf == NULL) { if (fd != -1) - close(fd); + while ((close(fd) == -1) && (errno == EINTR)) + /* nop */; warn("%s: cannot create modefile", modefile); done(1); } @@ -442,7 +459,10 @@ (void) lseek(dirp->dd_fd, base + (loc & ~(DIRBLKSIZ - 1)), SEEK_SET); dirp->dd_loc = loc & (DIRBLKSIZ - 1); if (dirp->dd_loc != 0) - dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ); + do { + dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf, + DIRBLKSIZ); + } while ((dirp->dd_size == -1) && (errno == EINTR)); } /* @@ -455,8 +475,10 @@ for (;;) { if (dirp->dd_loc == 0) { - dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf, - DIRBLKSIZ); + do { + dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf, + DIRBLKSIZ); + } while ((dirp->dd_size == -1) && (errno == EINTR)); if (dirp->dd_size <= 0) { dprintf(stderr, "error reading directory\n"); return (NULL); @@ -513,7 +535,7 @@ RST_DIR *dirp; dirp = arg; - (void)close(dirp->dd_fd); + while ((close(dirp->dd_fd) == -1) && (errno == EINTR)) /* nop */; free(dirp); return; } @@ -537,10 +559,13 @@ RST_DIR *dirp; int fd; - if ((fd = open(name, O_RDONLY)) == -1) + do { + fd = open(name, O_RDONLY); + } while ((fd == -1) && (errno == EINTR)); + if (fd == -1) return (NULL); if ((dirp = malloc(sizeof(RST_DIR))) == NULL) { - (void)close(fd); + while ((close(fd) == -1) && (errno == EINTR)) /* nop */; return (NULL); } dirp->dd_fd = fd; @@ -572,7 +597,9 @@ fprintf(stderr, "directory mode, owner, and times not set\n"); return; } - mf = fopen(modefile, "r"); + do { + mf = fopen(modefile, "r"); + } while ((mf == NULL) && (errno == EINTR)); if (mf == NULL) { fprintf(stderr, "fopen: %s\n", strerror(errno)); fprintf(stderr, "cannot open mode file %s\n", modefile); @@ -676,7 +703,10 @@ itp = inotablookup(ino); if (itp == NULL) panic("Cannot find directory inode %d named %s\n", ino, name); - if ((ofile = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) { + do { + ofile = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0666); + } while ((ofile == -1) && (errno == EINTR)); + if (ofile < 0) { fprintf(stderr, "%s: ", name); (void) fflush(stderr); fprintf(stderr, "cannot create file: %s\n", strerror(errno)); @@ -685,8 +715,12 @@ rst_seekdir(dirp, itp->t_seekpt, itp->t_seekpt); dp = dup(dirp->dd_fd); for (i = itp->t_size; i > 0; i -= BUFSIZ) { + int ret_val = 0; size = i < BUFSIZ ? i : BUFSIZ; - if (read(dp, buf, (int) size) == -1) { + do { + ret_val = read(dp, buf, (int) size); + } while ((ret_val == -1) && (errno == EINTR)); + if (ret_val == -1) { fprintf(stderr, "write error extracting inode %d, name %s\n", curfile.ino, curfile.name); @@ -701,8 +735,8 @@ done(1); } } - (void) close(dp); - (void) close(ofile); + while((close(dp) == -1) && (errno == EINTR)) /* nop */; + while((close(ofile) == -1) && (errno == EINTR)) /* nop */; return (GOOD); } Index: sbin/restore/tape.c =================================================================== --- sbin/restore/tape.c (Revision 202551) +++ sbin/restore/tape.c (Arbeitskopie) @@ -151,11 +151,15 @@ * Since input is coming from a pipe we must establish * our own connection to the terminal. */ - terminal = fopen(_PATH_TTY, "r"); + do { + terminal = fopen(_PATH_TTY, "r"); + } while ((terminal == NULL) && (errno == EINTR)); if (terminal == NULL) { (void)fprintf(stderr, "cannot open %s: %s\n", _PATH_TTY, strerror(errno)); - terminal = fopen(_PATH_DEVNULL, "r"); + do { + terminal = fopen(_PATH_DEVNULL, "r"); + } while ((terminal == NULL) && (errno == EINTR)); if (terminal == NULL) { (void)fprintf(stderr, "cannot open %s: %s\n", _PATH_DEVNULL, strerror(errno)); @@ -218,8 +222,11 @@ #endif if (pipein) mt = 0; - else - mt = open(magtape, O_RDONLY, 0); + else { + do { + mt = open(magtape, O_RDONLY, 0); + } while ((mt == -1) && (errno == EINTR)); + } if (mt < 0) { fprintf(stderr, "%s: %s\n", magtape, strerror(errno)); done(1); @@ -415,7 +422,9 @@ mt = rmtopen(magtape, 0); else #endif - mt = open(magtape, O_RDONLY, 0); + do { + mt = open(magtape, O_RDONLY, 0); + } while ((mt == -1) && (errno == EINTR)); if (mt == -1) { fprintf(stderr, "Cannot open %s\n", magtape); @@ -698,9 +707,11 @@ return (GOOD); } if (uflag) - (void) unlink(name); - if ((ofile = open(name, O_WRONLY | O_CREAT | O_TRUNC, - 0600)) < 0) { + (void)unlink(name); + do { + ofile = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0600); + } while ((ofile <0) && (errno == EINTR)); + if (ofile < 0) { fprintf(stderr, "%s: cannot create file: %s\n", name, strerror(errno)); skipfile(); @@ -715,7 +726,7 @@ (void) futimes(ofile, ctimep); (void) futimes(ofile, mtimep); (void) fchflags(ofile, flags); - (void) close(ofile); + while((close(ofile) == -1) && (errno == EINTR)) /* nop */; return (GOOD); } /* NOTREACHED */ @@ -1199,7 +1210,9 @@ i = rmtread(&tapebuf[rd], cnt); else #endif - i = read(mt, &tapebuf[rd], cnt); + do { + i = read(mt, &tapebuf[rd], cnt); + } while ((i == -1) && (errno == EINTR)); /* * Check for mid-tape short read error. * If found, skip rest of buffer and start with the next. @@ -1310,7 +1323,9 @@ i = rmtread(tapebuf, ntrec * TP_BSIZE); else #endif - i = read(mt, tapebuf, ntrec * TP_BSIZE); + do { + i = read(mt, tapebuf, ntrec * TP_BSIZE); + } while ((i == -1) && (errno == EINTR)); if (i <= 0) { fprintf(stderr, "tape read error: %s\n", strerror(errno)); @@ -1341,7 +1356,7 @@ rmtclose(); else #endif - (void) close(mt); + while((close(mt) == -1) && (errno == EINTR)) /* nop */; } /*