From a115e247aac5bab8a0ca11d544abd149dfeb3f21 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 23 Sep 2009 06:10:36 -0600 Subject: [PATCH] link: fix test failure on Solaris 9 link("file/",name) mistakenly succeeded. * lib/link.c (rpl_link): Don't assume link will catch bogus trailing slash on source. Signed-off-by: Eric Blake --- ChangeLog | 4 ++++ lib/link.c | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 552e8dc7b..8a4aebf6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-09-23 Eric Blake + link: fix test failure on Solaris 9 + * lib/link.c (rpl_link): Don't assume link will catch bogus + trailing slash on source. + test-symlinkat: enhance test * tests/test-readlink.c (main): Move guts... * tests/test-readlink.h (test_readlink): ...into new file. diff --git a/lib/link.c b/lib/link.c index 72b860015..42d086ce8 100644 --- a/lib/link.c +++ b/lib/link.c @@ -162,11 +162,13 @@ rpl_link (char const *file1, char const *file2) || (len2 && file2[len2 - 1] == '/')) { /* Let link() decide whether hard-linking directories is legal. - If stat() fails, link() will probably fail for the same - reason; so we only have to worry about successful stat() and - non-directory. */ + If stat() fails, then link() should fail for the same reason + (although on Solaris 9, link("file/","oops") mistakenly + succeeds); if stat() succeeds, require a directory. */ struct stat st; - if (stat (file1, &st) == 0 && !S_ISDIR (st.st_mode)) + if (stat (file1, &st)) + return -1; + if (!S_ISDIR (st.st_mode)) { errno = ENOTDIR; return -1; -- 2.11.0