Handle ln -sf a foo/ correctly
Previously it would not delete foo/a if it already existed. Use unlinkat() instead to do that.
This commit is contained in:
parent
3946d1fcc9
commit
d475a6bdf2
2
ln.c
2
ln.c
|
@ -67,7 +67,7 @@ main(int argc, char *argv[])
|
||||||
if (!hasto)
|
if (!hasto)
|
||||||
to = basename(argv[0]);
|
to = basename(argv[0]);
|
||||||
if (fflag)
|
if (fflag)
|
||||||
remove(to);
|
unlinkat(dirfd, to, 0);
|
||||||
if ((!sflag ? linkat(AT_FDCWD, argv[0], dirfd, to, flags)
|
if ((!sflag ? linkat(AT_FDCWD, argv[0], dirfd, to, flags)
|
||||||
: symlinkat(argv[0], dirfd, to)) < 0) {
|
: symlinkat(argv[0], dirfd, to)) < 0) {
|
||||||
eprintf("%s %s <- %s:", fname, argv[0], to);
|
eprintf("%s %s <- %s:", fname, argv[0], to);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user