From 30e8407d4ff60da69e6f6202267eb8c705743b5d Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Thu, 13 Jan 2005 15:41:05 +0000 Subject: [PATCH] chdir() back to the initial directory when abort()ing. --- CHANGES | 9 ++++++++- restore/main.c | 7 ++++++- restore/restore.h | 3 ++- restore/utilities.c | 6 ++++-- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 391d759..7494087 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.264 2005/01/13 12:13:46 stelian Exp $ +$Id: CHANGES,v 1.265 2005/01/13 15:41:05 stelian Exp $ Changes between versions 0.4b38 and 0.4b39 (released ???????????????) ===================================================================== @@ -7,6 +7,13 @@ Changes between versions 0.4b38 and 0.4b39 (released ???????????????) with an updated version from Andrew Basterfield . +2. Made restore to chdir() back into the initial directory when + dumping core while aborting a comparision operation. The + previous behaviour was to write the corefile at the root of + the directory being compared, which could very well be + read only and preventing the corefile generation. Thanks + to Kenneth Porter for the bug report. + Changes between versions 0.4b37 and 0.4b38 (released January 7, 2005) ===================================================================== diff --git a/restore/main.c b/restore/main.c index 361c4ec..0f43cb7 100644 --- a/restore/main.c +++ b/restore/main.c @@ -37,7 +37,7 @@ #ifndef lint static const char rcsid[] = - "$Id: main.c,v 1.47 2004/12/15 11:00:01 stelian Exp $"; + "$Id: main.c,v 1.48 2005/01/13 15:41:06 stelian Exp $"; #endif /* not lint */ #include @@ -112,6 +112,7 @@ char filesys[NAMELEN]; static const char *stdin_opt = NULL; char *bot_script = NULL; dump_ino_t volinfo[TP_NINOS]; +int wdfd; #ifdef USE_QFA FILE *gTapeposfp; @@ -356,6 +357,10 @@ main(int argc, char *argv[]) else setinput(inputdev); + wdfd = open(".", O_RDONLY); + if (wdfd < 0) + err(1, "can't get current directory"); + if (argc == 0 && !filelist) { argc = 1; *--argv = "."; diff --git a/restore/restore.h b/restore/restore.h index 36cb88a..7deb3f2 100644 --- a/restore/restore.h +++ b/restore/restore.h @@ -5,7 +5,7 @@ * Stelian Pop , 1999-2000 * Stelian Pop - AlcĂ´ve , 2000-2002 * - * $Id: restore.h,v 1.30 2004/12/14 14:07:58 stelian Exp $ + * $Id: restore.h,v 1.31 2005/01/13 15:41:07 stelian Exp $ */ /* @@ -91,6 +91,7 @@ extern int compare_ignore_not_found; extern int compare_errors; /* did we encounter any compare errors? */ extern char filesys[NAMELEN];/* name of dumped filesystem */ extern dump_ino_t volinfo[]; /* which inode on which volume archive info */ +extern int wdfd; /* original working directory */ #define DIRHASH_SIZE 1024 diff --git a/restore/utilities.c b/restore/utilities.c index 2e73aa8..c16590c 100644 --- a/restore/utilities.c +++ b/restore/utilities.c @@ -37,7 +37,7 @@ #ifndef lint static const char rcsid[] = - "$Id: utilities.c,v 1.26 2004/12/15 11:00:01 stelian Exp $"; + "$Id: utilities.c,v 1.27 2005/01/13 15:41:07 stelian Exp $"; #endif /* not lint */ #include @@ -487,8 +487,10 @@ panic(fmt, va_alist) if (yflag) return; if (reply("abort") == GOOD) { - if (reply("dump core") == GOOD) + if (reply("dump core") == GOOD) { + fchdir(wdfd); abort(); + } exit(1); } } -- 2.39.5