File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -259,6 +259,12 @@ static Error restoreStatOnFile(StringRef Filename,
259
259
if (std::error_code EC = sys::fs::status (FD, OStat))
260
260
return createFileError (Filename, EC);
261
261
if (OStat.type () == sys::fs::file_type::regular_file) {
262
+ #ifndef _WIN32
263
+ // Keep ownership if llvm-objcopy is called under root.
264
+ if (Config.InputFilename == Config.OutputFilename && OStat.getUser () == 0 )
265
+ sys::fs::changeFileOwnership (FD, Stat.getUser (), Stat.getGroup ());
266
+ #endif
267
+
262
268
sys::fs::perms Perm = Stat.permissions ();
263
269
if (Config.InputFilename != Config.OutputFilename )
264
270
Perm = static_cast <sys::fs::perms>(Perm & ~sys::fs::getUmask () & ~06000 );
@@ -268,12 +274,6 @@ static Error restoreStatOnFile(StringRef Filename,
268
274
if (auto EC = sys::fs::setPermissions (FD, Perm))
269
275
#endif
270
276
return createFileError (Filename, EC);
271
-
272
- #ifndef _WIN32
273
- // Keep ownership if llvm-objcopy is called under root.
274
- if (Config.InputFilename == Config.OutputFilename && OStat.getUser () == 0 )
275
- sys::fs::changeFileOwnership (FD, Stat.getUser (), Stat.getGroup ());
276
- #endif
277
277
}
278
278
279
279
if (auto EC = sys::Process::SafelyCloseFileDescriptor (FD))
You can’t perform that action at this time.
0 commit comments