summaryrefslogtreecommitdiff
path: root/src/force-link.c
Commit message (Collapse)AuthorAgeFilesLines
* maint: update all copyright year number rangesPádraig Brady2023-01-011-1/+1
| | | | | | | | | | Update to latest gnulib with new copyright year. Run "make update-copyright" and then... * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Manually update copyright year, until we fully sync with gnulib at a later stage. * tests/sample-test: Adjust to use the single most recent year.
* maint: update all copyright year number rangesPádraig Brady2022-01-021-1/+1
| | | | | | | | | Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
* maint: update all copyright year number rangesPádraig Brady2021-01-011-1/+1
| | | | | | | | | Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
* maint: update all copyright year number rangesPádraig Brady2020-01-011-1/+1
| | | | | | | | | Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
* maint: update all copyright year number rangesAssaf Gordon2019-01-011-1/+1
| | | | | | | | | Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
* ln: avoid directory hard-link racesPaul Eggert2018-10-191-26/+28
| | | | | | | | | | | | | | | | | | | | | | | | Previously, 'ln A B' did 'stat("B"), lstat("A"), link("A","B")' where the stat and lstat were necessary to avoid hard-linking directories on systems that can hard-link directories. Now, in situations that prohibit hard links to directories, 'ln A B' merely does 'link("A","B")'. The new behavior avoids some races and should be more efficient. This patch was inspired by Bug#10020, which was about 'ln'. * bootstrap.conf (gnulib_modules): Add unlinkdir. * src/force-link.c (force_linkat, force_symlinkat): New arg for error number of previous try. Return error number, 0, or -1 if error, success, or success after removal. All callers changed. * src/ln.c: Include priv-set.h, unlinkdir.h. (beware_hard_dir_link): New static var. (errnoize, atomic_link): New functions. (target_directory_operand): Use errnoize for simplicity. (do_link): New arg for error number of previous try. All callers changed. Do each link atomically if possible. (main): Do -r check earlier. Remove linkdir privileges so we can use a single linkat/symlinkat instead of a racy substitute for the common case of 'ln A B' and 'ln -s A B'. Set beware_hard_dir_link to disable this optimization.
* maint: update all copyright year number rangesPádraig Brady2018-01-011-1/+1
| | | | | | | | | Run "make update-copyright" and then... * gnulib: Update to latest with copyright year adjusted. * tests/init.sh: Sync with gnulib to pick up copyright year. * bootstrap: Likewise. * tests/sample-test: Adjust to use the single most recent year.
* all: prefer HTTPS in URLsPaul Eggert2017-09-191-1/+1
|
* maint: tweaks so syntax tests pass for previous commitPádraig Brady2017-02-121-8/+3
| | | | | | * src/force-link.h: Don't include headers already included by system.h * src/force-link.c: Likewise. Also include system.h and explicitly mark extern functions as such.
* ln: replace destination links more atomicallyPaul Eggert2017-02-111-0/+187
If the file B already exists, commands like 'ln -f A B' and 'cp -fl A B' no longer remove B before creating the new link. Instead, they arrange for the new link to replace B atomically. This should fix a race condition reported by Mike Crowe (Bug#25680). * NEWS, doc/coreutils.texi (cp invocation, ln invocation): Document this. * bootstrap.conf (gnulib_modules): Add symlinkat. * src/copy.c, src/ln.c: Include force-link.h. * src/copy.c (same_file_ok): It's also OK to remove a destination symlink when creating symbolic links, or when the source and destination are on the same file system and when creating hard links. * src/copy.c (create_hard_link, copy_internal): * src/ln.c (do_link): Rewrite using force_linkat and force_symlinkat, to close a window where the destination temporarily does not exist. * src/cp.c (main): Do not set x.unlink_dest_before_opening merely because we are in link-creation mode. * src/force-link.c, src/force-link.h: New files. * src/local.mk (copy_sources, src_ln_SOURCES): Add them. * tests/cp/same-file.sh: Adjust test case to match fixed behavior.