From e65b7f3b82c4ec4cbd78aa45eefba7c555104d77 Mon Sep 17 00:00:00 2001 From: Jean-Adrien DOMAGE Date: Wed, 28 Apr 2021 19:37:15 +0200 Subject: [PATCH] lx_fs: fix errno EEXIST not propagated This commit introduces a fix for lx_fs to propagate errno EEXIST error. This prevents vfs to overwrite an imported file, if it already exists, without the overwrite flag set to true. Issue genodelabs#4104 --- repos/os/src/server/lx_fs/file.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/repos/os/src/server/lx_fs/file.h b/repos/os/src/server/lx_fs/file.h index b5e108c25d..041f875167 100644 --- a/repos/os/src/server/lx_fs/file.h +++ b/repos/os/src/server/lx_fs/file.h @@ -39,8 +39,12 @@ class Lx_fs::File : public Node if (create) { mode_t ugo = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; ret = mknodat(dir, name, S_IFREG | ugo, 0); + if (ret == -1 && errno != EEXIST) throw No_space(); + + if (errno == EEXIST) + throw Node_already_exists(); } struct stat s;