diff options
author | ngie <ngie@FreeBSD.org> | 2017-07-17 21:11:21 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2017-07-17 21:11:21 +0000 |
commit | a13c5bbff8635140cf402c421973ab342c220b43 (patch) | |
tree | e0c10e96b19e26e26bdf2a319c6caac8fdf53b48 | |
parent | 1242dab22d8e11a6ac24d4fce79391d488a2ebdc (diff) | |
download | FreeBSD-src-a13c5bbff8635140cf402c421973ab342c220b43.zip FreeBSD-src-a13c5bbff8635140cf402c421973ab342c220b43.tar.gz |
MFC r320172,r320173:
r320172:
ln(1): fix -F behavior
When '-F' option is used, the target directory needs to be unlinked.
Currently, the modified target ("target/source") is being unlinked, and
since it doesn't yet exist, the original target isn't removed.
This is fixed by skipping the block where target is modified to
"target/source" when '-F' option is set.
Hence, a symbolic link (with the same name as of the original target) to
the source_file is produced.
Update the test for ln(1) to reflect fix for option '-F'
PR: 219943
r320173:
Don't expect :sF_flag to fail anymore
While here, also add a check to verify that the link target
is updated in the testcase
MFC with: r320172
PR: 219943
-rw-r--r-- | bin/ln/ln.c | 6 | ||||
-rw-r--r-- | bin/ln/tests/ln_test.sh | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/bin/ln/ln.c b/bin/ln/ln.c index f50802a..ef8d532 100644 --- a/bin/ln/ln.c +++ b/bin/ln/ln.c @@ -245,11 +245,11 @@ linkit(const char *source, const char *target, int isdir) /* * If the target is a directory (and not a symlink if hflag), - * append the source's name. + * append the source's name, unless Fflag is set. */ - if (isdir || + if (!Fflag && (isdir || (lstat(target, &sb) == 0 && S_ISDIR(sb.st_mode)) || - (!hflag && stat(target, &sb) == 0 && S_ISDIR(sb.st_mode))) { + (!hflag && stat(target, &sb) == 0 && S_ISDIR(sb.st_mode)))) { if (strlcpy(bbuf, source, sizeof(bbuf)) >= sizeof(bbuf) || (p = basename(bbuf)) == NULL || snprintf(path, sizeof(path), "%s/%s", target, p) >= diff --git a/bin/ln/tests/ln_test.sh b/bin/ln/tests/ln_test.sh index e7aac2d..e1f5b47 100644 --- a/bin/ln/tests/ln_test.sh +++ b/bin/ln/tests/ln_test.sh @@ -160,10 +160,10 @@ sF_flag_head() sF_flag_body() { - atf_expect_fail "B isn't being unlinked (bug 219943)" atf_check mkdir A B atf_check ln -sF A B atf_check -o inline:'Symbolic Link\n' stat -f %SHT B + atf_check -o inline:'A\n' readlink B } atf_test_case sf_flag |