diff options
author | Siddhesh Poyarekar <siddhesh@gotplt.org> | 2021-02-19 08:05:33 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@gotplt.org> | 2021-02-19 08:05:33 +0530 |
commit | 3685de750e6a091663a0abe42528cad29e960e35 (patch) | |
tree | 2c71a3c3f24af21550fde8cef7431a3f9d248659 /binutils/bucomm.h | |
parent | 668c18f17fc4ea91675a2b638c31bfbefa29665f (diff) | |
download | binutils-3685de750e6a091663a0abe42528cad29e960e35.zip binutils-3685de750e6a091663a0abe42528cad29e960e35.tar.gz binutils-3685de750e6a091663a0abe42528cad29e960e35.tar.bz2 |
binutils: Avoid renaming over existing files
Renaming over existing files needs additional care to restore
permissions and ownership, which may not always succeed.
Additionally, other properties of the file such as extended attributes
may be lost, making the operation flaky.
For predictable results, resort to rename() only if the file does not
exist, otherwise copy the file contents into the existing file. This
ensures that no additional tricks are needed to retain file
properties.
This also allows dropping of the redundant set_times on the tmpfile in
objcopy/strip since now we no longer rename over existing files.
binutils/
* ar.c (write_archive): Remove TARGET_STAT. Adjust call to
SMART_RENAME.
* arsup.c (ar_save): Likewise.
* objcopy (strip_main): Don't copy TMPFD. Don't set times on
temporary file and adjust call to SMART_RENAME.
(copy_main): Likewise.
* rename.c [!S_ISLNK]: Remove definitions.
(try_preserve_permissions): Remove function.
(smart_rename): Remove FD, PRESERVE_DATES arguments. Use
rename system call only if TO does not exist.
* bucomm.h (smart_rename): Adjust declaration.
Diffstat (limited to 'binutils/bucomm.h')
-rw-r--r-- | binutils/bucomm.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/binutils/bucomm.h b/binutils/bucomm.h index 7a0adfa..aa7e33d 100644 --- a/binutils/bucomm.h +++ b/binutils/bucomm.h @@ -71,7 +71,7 @@ extern void print_version (const char *); /* In rename.c. */ extern void set_times (const char *, const struct stat *); -extern int smart_rename (const char *, const char *, int, struct stat *, int); +extern int smart_rename (const char *, const char *, struct stat *); /* In libiberty. */ |