]> git.wh0rd.org - dump.git/blobdiff - restore/utilities.c
Andreas Dilger fixes (CPP, ext2 features, const char etc).
[dump.git] / restore / utilities.c
index 7c3bcd8b1dcbeb183fee5af349557a719ebd4aa6..a7164fb134697d34bd13231d9d7a6f8ae57e01ca 100644 (file)
@@ -2,8 +2,8 @@
  *     Ported to Linux's Second Extended File System as part of the
  *     dump and restore backup suit
  *     Remy Card <card@Linux.EU.Org>, 1994-1997
- *      Stelian Pop <pop@cybercable.fr>, 1999 
- *
+ *     Stelian Pop <pop@noos.fr>, 1999-2000
+ *     Stelian Pop <pop@noos.fr> - AlcĂ´ve <www.alcove.fr>, 2000
  */
 
 /*
  */
 
 #ifndef lint
-#if 0
-static char sccsid[] = "@(#)utilities.c        8.5 (Berkeley) 4/28/95";
-#endif
 static const char rcsid[] =
-       "$Id: utilities.c,v 1.3 1999/10/11 12:59:21 stelian Exp $";
+       "$Id: utilities.c,v 1.12 2001/03/19 13:22:49 stelian Exp $";
 #endif /* not lint */
 
+#include <config.h>
+#include <errno.h>
+#include <compaterr.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
 #include <sys/param.h>
 #include <sys/stat.h>
 
 #ifdef __linux__
 #include <sys/time.h>
 #include <linux/ext2_fs.h>
+#include <ext2fs/ext2fs.h>
 #include <bsdcompat.h>
 #else  /* __linux__ */
 #include <ufs/ufs/dinode.h>
 #include <ufs/ufs/dir.h>
 #endif /* __linux__ */
 
-#include <errno.h>
-#include <compaterr.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#ifdef __linux__
-#include <ext2fs/ext2fs.h>
-#endif
-
 #include "restore.h"
 #include "extern.h"
 
@@ -157,7 +152,6 @@ void
 newnode(struct entry *np)
 {
        char *cp;
-
        if (np->e_type != NODE)
                badentry(np, "newnode: not a node");
        cp = myname(np);
@@ -249,6 +243,18 @@ linkit(char *existing, char *new, int type)
                                ret = link(existing, new);
                                chflags(existing, s.st_flags);
                        }
+#else
+                       unsigned long s;
+
+                       /*
+                        * Most likely, the immutable or append-only attribute
+                        * is set. Clear the attributes and try again.
+                        */
+                       if (fgetflags (existing, &s) != -1 &&
+                           fsetflags (existing, 0) != -1) {
+                               ret = link(existing, new);
+                               fsetflags(existing, s);
+                       }
 #endif
                        if (ret < 0) {
                                warn("warning: cannot create hard link %s->%s",