[PATCH] D93881: [llvm-objcopy] preserve file ownership when overwritten

Manoj Gupta via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 4 19:37:44 PST 2021


manojgupta added inline comments.


================
Comment at: llvm/lib/Support/FileOutputBuffer.cpp:142
+    if (!EC)
+      fs::changeFileOwnership(File.TmpName, Stat.getUser(), Stat.getGroup());
+  }
----------------
jcai19 wrote:
> manojgupta wrote:
> > manojgupta wrote:
> > > Can we pass the file descriptor (File.FD) directly?
> > The check for root user looks incorrect to me. The stat check for root should be done on the temp file, not the existing file. 
> Yes, I realized it the moment I sent the update. Will fix it.
I also think that calling fstat (fd) is better than stat. So I think using the existing status function which uses file descriptor is better here: std::error_code status(int FD, file_status &Result) 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93881/new/

https://reviews.llvm.org/D93881



More information about the llvm-commits mailing list