]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(dolink): Use symlink if hard link failed with EXDEV.
authorUlrich Drepper <drepper@redhat.com>
Fri, 30 Jan 1998 18:05:01 +0000 (18:05 +0000)
committerUlrich Drepper <drepper@redhat.com>
Fri, 30 Jan 1998 18:05:01 +0000 (18:05 +0000)
time/zic.c

index c95887c9b4b945beee37829b929730b83e12aea0..c94c32206bc5fb283f4c844341f445e8321279b9 100644 (file)
@@ -601,10 +601,23 @@ const char * const        tofile;
        if (!itsdir(toname))
                (void) remove(toname);
        if (link(fromname, toname) != 0) {
-               if (mkdirs(toname) != 0)
-                       (void) exit(EXIT_FAILURE);
-               if (link(fromname, toname) != 0) {
-                       const char *e = strerror(errno);
+               int failure = errno;
+               if (failure == ENOENT)
+                       if (mkdirs(toname) != 0)
+                               failure = errno;
+                       else if (link(fromname, toname) == 0)
+                               failure = 0;
+                       else
+                               failure = errno;
+#ifndef MISSING_SYMLINK
+               if (failure == EXDEV)
+                       if (symlink(fromname, toname) != 0)
+                               failure = errno;
+                       else
+                               failure = 0;
+#endif
+               if (failure) {
+                       const char *e = strerror(failure);
 
                        (void) fprintf(stderr,
                                _("%s: Can't link from %s to %s: %s\n"),