[PATCH] D96308: [llvm-objcopy] Avoid rename if input filename = output filename
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 9 11:20:19 PST 2021
MaskRay added a comment.
In D96308#2551924 <https://reviews.llvm.org/D96308#2551924>, @kees wrote:
> Is it possible to plumb fd instead of pathname? Then fchown(), fsetxattr(), etc, can all be used?
(Before this patch both input and output filenames can already be opened more than once. TOC-TOU already applies, which is bad.)
I wanted to avoid adding a new open but it is difficult. `Expected<OwningBinary<llvm::object::Binary>> BinaryOrErr = createBinary(Config.InputFilename);` does not expose the file handle.
Fixing it is possible but that will be a very intrusive change.
Preserving extended attributes is possible but different OSes have different APIs, e.g. fgetxattr on Linux and extattr_get_file on FreeBSD. In the end binutils just accepts the non-atomic operation. So we just follow suit.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96308/new/
https://reviews.llvm.org/D96308
More information about the llvm-commits
mailing list