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
<rom> co-mounted with a <ram> file-system does not stand in the way of
unlinking files from the <ram>. The concrete symptom occurred the
following scenario:

  <vfs>
    <dir name="home">
      <ram/>
      <rom name="..."/>
    </dir>
  </vfs>

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
This commit is contained in:
Norman Feske 2020-03-09 16:21:00 +01:00
parent ba55409c86
commit 2912096f6e

View File

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