From 2912096f6ed19001c106e9bf8b9a5180c4e82209 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Mon, 9 Mar 2020 16:21:00 +0100 Subject: [PATCH] vfs: distinguish NO_PERM from NO_ENTRY in unlink This patch changes the 'Single_file_system' to return NO_PERM only if the to-be-unlinked file corresponds to the single file. This way, a co-mounted with a file-system does not stand in the way of unlinking files from the . The concrete symptom occurred the following scenario: The following sequence of commands wrongly resulted in "Operation not permitted": $ mkdir -p /home/a/b/c $ rm -f /home/a/b/c/d In this case, rm should not fail (unlink should return ENOENT) Fixes #3690 --- repos/os/include/vfs/single_file_system.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/repos/os/include/vfs/single_file_system.h b/repos/os/include/vfs/single_file_system.h index ba5db3b3ff..5b3b55244a 100644 --- a/repos/os/include/vfs/single_file_system.h +++ b/repos/os/include/vfs/single_file_system.h @@ -230,9 +230,12 @@ class Vfs::Single_file_system : public File_system destroy(handle->alloc(), handle); } - Unlink_result unlink(char const *) override + Unlink_result unlink(char const *path) override { - return UNLINK_ERR_NO_PERM; + if (_single_file(path)) + return UNLINK_ERR_NO_PERM; + + return UNLINK_ERR_NO_ENTRY; } Rename_result rename(char const *from, char const *to) override