mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +00:00
Kernel: Avoid OpenFileDescription::absolute_path
This commit is contained in:
parent
d020d46846
commit
735da58d44
2 changed files with 8 additions and 6 deletions
|
@ -565,9 +565,11 @@ bool Process::dump_perfcore()
|
||||||
|
|
||||||
// Try to generate a filename which isn't already used.
|
// Try to generate a filename which isn't already used.
|
||||||
auto base_filename = String::formatted("{}_{}", name(), pid().value());
|
auto base_filename = String::formatted("{}_{}", name(), pid().value());
|
||||||
auto description_or_error = VirtualFileSystem::the().open(String::formatted("{}.profile", base_filename), O_CREAT | O_EXCL, 0400, current_directory(), UidAndGid { uid(), gid() });
|
auto perfcore_filename = String::formatted("{}.profile", base_filename);
|
||||||
|
auto description_or_error = VirtualFileSystem::the().open(perfcore_filename, O_CREAT | O_EXCL, 0400, current_directory(), UidAndGid { uid(), gid() });
|
||||||
for (size_t attempt = 1; attempt < 10 && description_or_error.is_error(); ++attempt)
|
for (size_t attempt = 1; attempt < 10 && description_or_error.is_error(); ++attempt)
|
||||||
description_or_error = VirtualFileSystem::the().open(String::formatted("{}.{}.profile", base_filename, attempt), O_CREAT | O_EXCL, 0400, current_directory(), UidAndGid { uid(), gid() });
|
perfcore_filename = String::formatted("{}.{}.profile", base_filename, attempt);
|
||||||
|
description_or_error = VirtualFileSystem::the().open(perfcore_filename, O_CREAT | O_EXCL, 0400, current_directory(), UidAndGid { uid(), gid() });
|
||||||
if (description_or_error.is_error()) {
|
if (description_or_error.is_error()) {
|
||||||
dbgln("Failed to generate perfcore for pid {}: Could not generate filename for the perfcore file.", pid().value());
|
dbgln("Failed to generate perfcore for pid {}: Could not generate filename for the perfcore file.", pid().value());
|
||||||
return false;
|
return false;
|
||||||
|
@ -596,7 +598,7 @@ bool Process::dump_perfcore()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbgln("Wrote perfcore for pid {} to {}", pid().value(), description.absolute_path());
|
dbgln("Wrote perfcore for pid {} to {}", pid().value(), perfcore_filename);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -739,19 +739,19 @@ KResultOr<RefPtr<OpenFileDescription>> Process::find_elf_interpreter_for_executa
|
||||||
|
|
||||||
auto elf_header = (ElfW(Ehdr)*)first_page;
|
auto elf_header = (ElfW(Ehdr)*)first_page;
|
||||||
if (!ELF::validate_elf_header(*elf_header, interp_metadata.size)) {
|
if (!ELF::validate_elf_header(*elf_header, interp_metadata.size)) {
|
||||||
dbgln("exec({}): Interpreter ({}) has invalid ELF header", path, interpreter_description->absolute_path());
|
dbgln("exec({}): Interpreter ({}) has invalid ELF header", path, interpreter_path);
|
||||||
return ENOEXEC;
|
return ENOEXEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not using KResultOr here because we'll want to do the same thing in userspace in the RTLD
|
// Not using KResultOr here because we'll want to do the same thing in userspace in the RTLD
|
||||||
String interpreter_interpreter_path;
|
String interpreter_interpreter_path;
|
||||||
if (!ELF::validate_program_headers(*elf_header, interp_metadata.size, (u8*)first_page, nread, &interpreter_interpreter_path)) {
|
if (!ELF::validate_program_headers(*elf_header, interp_metadata.size, (u8*)first_page, nread, &interpreter_interpreter_path)) {
|
||||||
dbgln("exec({}): Interpreter ({}) has invalid ELF Program headers", path, interpreter_description->absolute_path());
|
dbgln("exec({}): Interpreter ({}) has invalid ELF Program headers", path, interpreter_path);
|
||||||
return ENOEXEC;
|
return ENOEXEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!interpreter_interpreter_path.is_empty()) {
|
if (!interpreter_interpreter_path.is_empty()) {
|
||||||
dbgln("exec({}): Interpreter ({}) has its own interpreter ({})! No thank you!", path, interpreter_description->absolute_path(), interpreter_interpreter_path);
|
dbgln("exec({}): Interpreter ({}) has its own interpreter ({})! No thank you!", path, interpreter_path, interpreter_interpreter_path);
|
||||||
return ELOOP;
|
return ELOOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue