]> git.wh0rd.org - dump.git/blobdiff - restore/utilities.c
Do not add links several times in restore
[dump.git] / restore / utilities.c
index 1498599166bbe4b48e904839c7af3c14e7997a37..f052071484824a7fc41db11ad265f0e90507c728 100644 (file)
@@ -2,8 +2,7 @@
  *     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@cybercable.fr>, 1999-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.4 1999/10/11 13:08:10 stelian Exp $";
+       "$Id: utilities.c,v 1.8 2000/02/08 12:22:43 stelian Exp $";
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -248,6 +244,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",