# HG changeset patch # User Eric Blake # Date 1253707836 21600 # Node ID 00e8f52bdef47293ff989ace9711fe08d2938f7b # Parent c47da311af776576e35f5dac49190c5b03970396 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 diff --git a/ChangeLog b/ChangeLog --- 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 --- a/lib/link.c +++ b/lib/link.c @@ -162,11 +162,13 @@ || (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;