lx_fs: fix errno EEXIST not propagated

This commit introduces a fix for lx_fs to propagate errno EEXIST error.
This prevents vfs <import overwrite="false"> to overwrite an imported
file, if it already exists, without the overwrite flag set to true.

Issue genodelabs#4104
This commit is contained in:
Jean-Adrien DOMAGE 2021-04-28 19:37:15 +02:00 committed by Christian Helmuth
parent 0f0edc0134
commit e65b7f3b82

View File

@ -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;