Skip to content

Conversation

@LucasChollet
Copy link
Member

The Kernel will now write to a .partial file until it is done writing, and then rename the file by removing the extension.

This makes the final coredump appear atomically on the file system. So no need for special handling of partial files in CrashDaemon.

The Kernel will now write to a .partial file until it is done writing,
and then rename the file by removing the extension.

This makes the final coredump appear atomically on the file system. So
no need for special handling of partial files in CrashDaemon.
@github-actions github-actions bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label Nov 11, 2025
Comment on lines +839 to +846
auto output_directory = KLexicalPath::dirname(coredump_path->view());
auto vfs_root_context_root_custody = vfs_root_context()->root_custody().with([](auto& custody) -> NonnullRefPtr<Custody> {
return custody;
});
auto dump_directory = TRY(VirtualFileSystem::open_directory(vfs_root_context(), credentials(), output_directory, *vfs_root_context_root_custody));

auto new_path = TRY(KString::try_create(coredump_path->view().trim(".partial"sv)));
TRY(VirtualFileSystem::rename(vfs_root_context(), credentials(), dump_directory, coredump_path->view(), dump_directory, new_path->view()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two CustodyBases rename expects are mapped to renameat(), so if the given paths are absolute, the dirfd/CustodyBase is ignored (see also https://github.com/LucasChollet/serenity/blob/824d5bf04ce331681895caf4eedbf520a21757e2/Kernel/FileSystem/VirtualFileSystem.cpp#L1086).
CustodyBase::resolve() returns the root custody if the given path is absolute, so I think you should be able to do that here as well. The coredump path should always be absolute, though we currently don't seem to check that when userspace writes the SysFS variable.

(side note: While looking at the CustodyBase class, I noticed that it's maybe a bit counterintuitive for it to store the path in the class itself rather than taking it as an argument for resolve())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

👀 pr-needs-review PR needs review from a maintainer or community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants