[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: confusing error message from ln
From: |
Paul Eggert |
Subject: |
Re: confusing error message from ln |
Date: |
Fri, 28 Oct 2005 15:41:04 -0700 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
How about this patch? I think it addresses all issues raised so far
on this thread.
2005-10-28 Paul Eggert <address@hidden>
* src/ln.c (do_link): In diagnostics, don't mention operands when
we know they did not contribute to the error.
--- src/ln.c.~1.153.~ 2005-10-28 15:14:13.000000000 -0700
+++ src/ln.c 2005-10-28 15:36:32.000000000 -0700
@@ -165,6 +165,7 @@ do_link (const char *source, const char
struct stat dest_stats;
char *dest_backup = NULL;
bool lstat_ok = false;
+ bool source_is_dir = false;
/* Use stat here instead of lstat.
On SVR4, link does not follow symlinks, so this check disallows
@@ -186,11 +187,15 @@ do_link (const char *source, const char
quote (source));
}
- if (!hard_dir_link && S_ISDIR (source_stats.st_mode))
+ if (S_ISDIR (source_stats.st_mode))
{
- error (0, 0, _("%s: hard link not allowed for directory"),
- quote (source));
- return false;
+ source_is_dir = true;
+ if (! hard_dir_link)
+ {
+ error (0, 0, _("%s: hard link not allowed for directory"),
+ quote (source));
+ return false;
+ }
}
}
@@ -319,8 +324,15 @@ do_link (const char *source, const char
error (0, errno,
(symbolic_link
- ? _("creating symbolic link %s to %s")
- : _("creating hard link %s to %s")),
+ ? (errno != ENAMETOOLONG && *source
+ ? _("creating symbolic link %s")
+ : _("creating symbolic link %s to %s"))
+ : (errno == EMLINK && !source_is_dir
+ ? _("creating hard link to %.0s%s")
+ : (errno == EDQUOT || errno == EEXIST || errno == ENOSPC
+ || errno == EROFS)
+ ? _("creating hard link %s")
+ : _("creating hard link %s to %s"))),
quote_n (0, dest), quote_n (1, source));
if (dest_backup)
- confusing error message from ln, Elan Ruusamäe, 2005/10/27
- Re: confusing error message from ln, Bob Proulx, 2005/10/28
- Re: confusing error message from ln, Andreas Schwab, 2005/10/28
- Re: confusing error message from ln, Bob Proulx, 2005/10/28
- Re: confusing error message from ln,
Paul Eggert <=
- Re: confusing error message from ln, Bob Proulx, 2005/10/30
- Re: confusing error message from ln, Paul Eggert, 2005/10/30
- Re: confusing error message from ln, Bob Proulx, 2005/10/30
- Re: confusing error message from ln, Paul Eggert, 2005/10/31