]> git.wh0rd.org - dump.git/blobdiff - restore/dirs.c
Added -o flag to restore.
[dump.git] / restore / dirs.c
index 60f5b23673b15eebe42576aa3887ded3b2e8c894..4a0a2bcfdbb4618bd495189717666f3ce6ad74c0 100644 (file)
@@ -46,7 +46,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: dirs.c,v 1.17 2002/01/25 15:08:59 stelian Exp $";
+       "$Id: dirs.c,v 1.19 2002/06/08 07:10:37 stelian Exp $";
 #endif /* not lint */
 
 #include <config.h>
@@ -140,7 +140,7 @@ struct odirect {
        char    d_name[ODIRSIZ];
 };
 
-#ifdef __linux__
+#if defined(__linux__) || defined(sunos)
 static struct inotab   *allocinotab __P((dump_ino_t, struct new_bsd_inode *, long));
 #else
 static struct inotab   *allocinotab __P((dump_ino_t, struct dinode *, long));
@@ -165,7 +165,7 @@ void
 extractdirs(int genmode)
 {
        int i;
-#ifdef __linux__
+#if defined(__linux__) || defined(sunos)
        struct new_bsd_inode *ip;
 #else
        struct dinode *ip;
@@ -325,7 +325,11 @@ pathsearch(const char *pathname)
        while (*path == '/')
                path++;
        dp = NULL;
+#ifdef __linux__
        while ((name = strsep(&path, "/")) != NULL && *name /* != NULL */) {
+#else
+       while ((name = strtok_r(NULL, "/", &path)) != NULL && *name /* != NULL */) {
+#endif
                if ((dp = searchdir(ino, name)) == NULL)
                        return (NULL);
                ino = dp->d_ino;
@@ -431,9 +435,9 @@ putdir(char *buf, size_t size)
 /*
  * These variables are "local" to the following two functions.
  */
-char dirbuf[DIRBLKSIZ];
-long dirloc = 0;
-long prev = 0;
+static char dirbuf[DIRBLKSIZ];
+static long dirloc = 0;
+static long prev = 0;
 
 /*
  * add a new directory entry to a file.
@@ -643,7 +647,8 @@ setdirmodes(int flags)
                                ep->e_flags &= ~NEW;
                                continue;
                        }
-                       if (node.ino == ROOTINO &&
+                       if ((flags & FORCE) == 0 &&
+                           node.ino == ROOTINO &&
                            reply("set owner/mode for '.'") == FAIL)
                                continue;
                }