]> sourceware.org Git - binutils-gdb.git/commit
Use make_tempname file descriptor in smart_rename
authorAlan Modra <amodra@gmail.com>
Tue, 23 Feb 2021 01:40:58 +0000 (12:10 +1030)
committerAlan Modra <amodra@gmail.com>
Fri, 26 Feb 2021 07:28:30 +0000 (17:58 +1030)
commit08bdb5f4f98b6a5e1a9bdc89e7d1889933859caf
tree1b1c034a9b69077d343e6c797ae2d8b14e7a81b9
parent8b69e61d4be276bb862698aaafddc3e779d23c8f
Use make_tempname file descriptor in smart_rename

This patch makes use of the temp file descriptor in smart_rename
rather than reopening the file.  I don't believe there is a security
issue in reopening the file, but this way is one less directory
operation.  The patch also attempts to preserve S_ISUID and S_ISGID.

PR 27456
* bucomm.h (smart_rename): Update prototype.
* rename.c (smart_rename): Add fromfd and preserve_dates params.
Pass fromfd and target_stat to simple_copy.  Call set_times
when preserve_dates.
(simple_copy): Accept fromfd rather than from filename.  Add
target_stat param.  Rewind fromfd rather than opening.  Open
"to" file without O_CREAT.  Try to preserve S_ISUID and S_ISGID.
* ar.c (write_archive): Rename ofd to tmpfd.  Dup tmpfd before
closing output temp file, and pass tmpfd to smart_rename.
* arsup.c (temp_fd): Rename from real_fd.
(ar_save): Dup temp_fd and pass to smart_rename.
* objcopy.c (strip_main, copy_main): Likewise, and pass
preserve_dates.

(cherry picked from commit c42c71a1527dd70417d3966dce7ba9edbcf4bdb4)
binutils/ChangeLog
binutils/ar.c
binutils/arsup.c
binutils/bucomm.h
binutils/objcopy.c
binutils/rename.c
This page took 0.037434 seconds and 5 git commands to generate.