1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 13:44:58 +00:00

Kernel: Have the open() syscall take an explicit path length parameter.

Instead of computing the path length inside the syscall handler, let the
caller do that work. This allows us to implement to new variants of open()
and creat(), called open_with_path_length() and creat_with_path_length().
These are suitable for use with e.g StringView.
This commit is contained in:
Andreas Kling 2019-07-08 20:01:49 +02:00
parent fc4022d173
commit c110cf193d
9 changed files with 40 additions and 9 deletions

View file

@ -844,7 +844,7 @@ void GTextEditor::Line::truncate(int length)
bool GTextEditor::write_to_file(const StringView& path)
{
int fd = open(String(path).characters(), O_WRONLY | O_CREAT | O_TRUNC, 0666);
int fd = open_with_path_length(path.characters_without_null_termination(), path.length(), O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd < 0) {
perror("open");
return false;