commit: d1b4aa19de333e65b44da471cac89d9f98457233
parent 5efc5d6eb2d59e6f6e2f9076f33e6aa9e531fb8c
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 25 Jul 2025 07:59:53 +0200
cmd/ln: fix error handling of opening as directory on NetBSD
Diffstat:
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/cmd/ln.c b/cmd/ln.c
@@ -60,11 +60,20 @@ do_link(char *src, char *dest)
int dirfd = open(dest, open_dir_flags);
if(dirfd < 0)
{
+ switch(errno)
+ {
+ case ENOENT:
+ break;
// ENOTDIR: Found but not a directory
+ case ENOTDIR:
// ELOOP: POSIX return code when O_NOFOLLOW encounters a symbolic link
+ case ELOOP:
// EMLINK: Same as ELOOP but FreeBSD *sigh*
- if(errno == ENOTDIR || errno == ELOOP || errno == EMLINK)
- {
+ case EMLINK:
+#ifdef EFTYPE
+ // EFTYPE: Same as ELOOP but NetBSD *grunt*
+ case EFTYPE:
+#endif
if(!force)
{
fprintf(stderr, "ln: error: Destination '%s' already exists\n", dest);
@@ -83,9 +92,8 @@ do_link(char *src, char *dest)
strerror(errno));
return -1;
}
- }
- else
- {
+ break;
+ default:
fprintf(stderr,
"ln: error: Failed opening destination as directory '%s': %s\n",
dest,