From 93fb79f357ca9a15ae203b1de56a90315d6d5126 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Tue, 11 Dec 2018 18:40:34 +0100 Subject: [PATCH] Check for existing directories at Vfs::Dir_file_system Return OPENDIR_ERR_NODE_ALREADY_EXISTS for existing directories. Remove deprecated 'is_directory' method. Fix #3083 --- repos/os/include/vfs/dir_file_system.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/repos/os/include/vfs/dir_file_system.h b/repos/os/include/vfs/dir_file_system.h index c23ba6a1d6..9afd9897be 100644 --- a/repos/os/include/vfs/dir_file_system.h +++ b/repos/os/include/vfs/dir_file_system.h @@ -536,7 +536,7 @@ class Vfs::Dir_file_system : public File_system { path = _sub_path(path); if (!path) - return 0; + return nullptr; if (strlen(path) == 0) return path; @@ -547,7 +547,7 @@ class Vfs::Dir_file_system : public File_system return leaf_path; } - return 0; + return nullptr; } Open_result open(char const *path, @@ -686,6 +686,9 @@ class Vfs::Dir_file_system : public File_system return OPENDIR_ERR_LOOKUP_FAILED; if (create) { + if (leaf_path(path) != nullptr) + return OPENDIR_ERR_NODE_ALREADY_EXISTS; + auto opendir_fn = [&] (File_system &fs, char const *path) { Vfs_handle *tmp_handle;