--- src/bin/ln/ln.c 2004/11/07 20:54:51 1.5 +++ src/bin/ln/ln.c 2005/02/28 19:26:20 1.6 @@ -130,16 +130,17 @@ main(int argc, char *argv[]) } /* ln target1 target2 directory */ sourcedir = argv[argc - 1]; - if (hflag && lstat(sourcedir, &sb) == 0 && S_ISLNK(sb.st_mode)) { + + if (lstat(sourcedir, &sb)) + err(1, "%s", sourcedir); + + if (hflag && S_ISLNK(sb.st_mode)) { /* * We were asked not to follow symlinks, but found one at * the target--simulate "not a directory" error */ - errno = ENOTDIR; - err(1, "%s", sourcedir); + errc(1, ENOTDIR, "%s", sourcedir); } - if (stat(sourcedir, &sb)) - err(1, "%s", sourcedir); if (!S_ISDIR(sb.st_mode)) usage(); for (exitval = 0; *argv != sourcedir; ++argv)