coreutils: fix ln exit code on error

This commit is contained in:
Jerome Duval
2021-11-01 21:24:14 +01:00
parent 2e7801a039
commit 7d8d90c814
2 changed files with 75 additions and 10 deletions

View File

@@ -1,4 +1,4 @@
From 0aeb9a970dab1106af2af343a4f045a6b6053e25 Mon Sep 17 00:00:00 2001
From a034fbd419e2b13b1bb3b6d0086fbf2a353c9caf Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Tue, 13 May 2014 17:18:52 +0000
Subject: define __USE_GNU for wempcpy
@@ -22,7 +22,7 @@ index b8a71f1..0dc18c7 100644
2.30.2
From b99853f9633ddd2f6c319a1c4a6d4f0fabaaa33d Mon Sep 17 00:00:00 2001
From 003eab13f32f56346925551fa1d1b7c4a4eefaec Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Tue, 13 May 2014 17:22:10 +0000
Subject: force declaration of rpl_inet_ntop
@@ -45,7 +45,7 @@ index 9968067..ad11a60 100644
2.30.2
From fa94fafda6bbbbebf8bdfdebb012f1e0a580ad1f Mon Sep 17 00:00:00 2001
From 55d22feaa454df25c6c504a891576d378a6f9699 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Tue, 13 May 2014 17:32:36 +0000
Subject: Haiku defines mknod in unistd.h
@@ -67,7 +67,7 @@ index c54e60c..018ed23 100644
2.30.2
From d00b1d9937aac8f49411c8e5e97945a77a6a9ce8 Mon Sep 17 00:00:00 2001
From 09f7fd664fee674e09ac887c94f33fec62150d9a Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Tue, 13 May 2014 17:35:25 +0000
Subject: protect the label, not used on Haiku
@@ -99,7 +99,7 @@ index 352b35f..7514f57 100644
2.30.2
From 4f1aca5f273e45958c72d238d5e2d8a6c98469d8 Mon Sep 17 00:00:00 2001
From 92289b441276ade205dc8f2945bff662ac78fde6 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Thu, 15 May 2014 15:40:32 +0000
Subject: strchrnul needs __USE_GNU on Haiku
@@ -138,7 +138,7 @@ index 8d77ae3..892640b 100644
2.30.2
From 467aa80f3ee94d1a4e35f449542eb4f4d4a75286 Mon Sep 17 00:00:00 2001
From fd8eaf6e9308d0b0cec212313d6971ae67c18c40 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Thu, 15 May 2014 20:13:58 +0000
Subject: don't build hostid, nice, users, who
@@ -172,7 +172,7 @@ index b42c218..34c917e 100644
2.30.2
From 12cc1134dad01775fb7c810383a9cc5d1145f549 Mon Sep 17 00:00:00 2001
From 2a0307c0358423e5bf41ed01739d6cf63a11dd7c Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Fri, 6 Feb 2015 20:24:12 +0000
Subject: import Haiku changes, fix warnings.
@@ -571,7 +571,7 @@ index ae9b8e2..2c551af 100644
2.30.2
From a8d6d0bacb954aee1e398bb5dcd2511f76662955 Mon Sep 17 00:00:00 2001
From 727b1b3f07f8eade8861623b38f6e77de1e8a6ac Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Thu, 21 Oct 2021 20:28:22 +0200
Subject: config.h is required for stdint.h
@@ -588,3 +588,64 @@ index 20a1e41..fdf2fdf 100644
uint_fast32_t const crctab[8][256] = {
--
2.30.2
From fa26aa214dfe0d231c3b105ba90f7e118d9918c3 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Mon, 1 Nov 2021 21:08:55 +0100
Subject: ln: handle negative errno
explicit check for -1 which is a special value in this code.
diff --git a/src/ln.c b/src/ln.c
index c7eb740..dde3e4b 100644
--- a/src/ln.c
+++ b/src/ln.c
@@ -160,7 +160,7 @@ convert_abs_rel (char const *from, char const *target)
/* Link SOURCE to DESTDIR_FD + DEST_BASE atomically. DESTDIR_FD is
the directory containing DEST_BASE. Return 0 if successful, a
- positive errno value on failure, and -1 if an atomic link cannot be
+ errno value on failure, and -1 if an atomic link cannot be
done. This handles the common case where the destination does not
already exist and -r is not specified. */
@@ -191,7 +191,7 @@ do_link (char const *source, int destdir_fd, char const *dest_base,
char *backup_base = NULL;
char *rel_source = NULL;
int nofollow_flag = logical ? 0 : AT_SYMLINK_NOFOLLOW;
- if (link_errno < 0)
+ if (link_errno == -1)
link_errno = atomic_link (source, destdir_fd, dest_base);
/* Get SOURCE_STATS if later code will need it, if only for sharper
@@ -278,7 +278,7 @@ do_link (char const *source, int destdir_fd, char const *dest_base,
}
}
- if (link_errno < 0 || link_errno == EEXIST)
+ if (link_errno == -1 || link_errno == EEXIST)
{
if (interactive)
{
@@ -344,7 +344,7 @@ do_link (char const *source, int destdir_fd, char const *dest_base,
required removing the destination first. */
}
- if (link_errno <= 0)
+ if (link_errno == 0 || link_errno == -1)
{
/* Right after creating a hard link, do this: (note dest name and
source_stats, which are also the just-linked-destinations stats) */
@@ -399,7 +399,7 @@ do_link (char const *source, int destdir_fd, char const *dest_base,
free (backup_base);
free (rel_source);
- return link_errno <= 0;
+ return link_errno == 0 || link_errno == -1;
fail:
free (rel_source);
--
2.30.2