]> git.wh0rd.org - dump.git/commitdiff
chdir() back to the initial directory when abort()ing.
authorStelian Pop <stelian@popies.net>
Thu, 13 Jan 2005 15:41:05 +0000 (15:41 +0000)
committerStelian Pop <stelian@popies.net>
Thu, 13 Jan 2005 15:41:05 +0000 (15:41 +0000)
CHANGES
restore/main.c
restore/restore.h
restore/utilities.c

diff --git a/CHANGES b/CHANGES
index 391d7594e503f1d38cc63f2de55d6bbb38c9ec4a..7494087cb824ee6cb4ea611718037d817a0a8dc5 100644 (file)
--- 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
        <bob@cemetery.homeunix.org>.
 
+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 <shiva@sewingwitch.com> for the bug report.
+
 Changes between versions 0.4b37 and 0.4b38 (released January 7, 2005)
 =====================================================================
 
index 361c4ecd4b4e190e01e03a251011e783a2e2ed3a..0f43cb7e1de0f64d4f7637d1dce2032708aa8054 100644 (file)
@@ -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 <config.h>
@@ -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 = ".";
index 36cb88ae486b67c2649c8eddf2c99613334e248b..7deb3f24f10537e7efd8a8ee75adbf750f68f2fd 100644 (file)
@@ -5,7 +5,7 @@
  *     Stelian Pop <stelian@popies.net>, 1999-2000
  *     Stelian Pop <stelian@popies.net> - AlcĂ´ve <www.alcove.com>, 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
 
index 2e73aa87cac93cb2bfb3accdfa899b578335feb5..c16590c680d7655c35c00cf009feb2f91c55317e 100644 (file)
@@ -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 <config.h>
@@ -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);
        }
 }