mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-15 21:58:24 +00:00
VFS: catch Out_of_ram and Out_of_cap exceptions
Catch out of RAM and capability exceptions and return error values. Abort opening a composite directory at Dir_file_system where an opendir call on any child file-system returns an OUT_OF_RAM or OUT_OF_CAPS error. Ref #2642
This commit is contained in:
committed by
Norman Feske
parent
c34a4bfdb4
commit
c7d0accac0
@ -540,8 +540,12 @@ class Vfs::Dir_file_system : public File_system
|
||||
* are subjected to the stacked file-system layout.
|
||||
*/
|
||||
if (directory(path)) {
|
||||
*out_handle = new (alloc) Vfs_handle(*this, *this, alloc, 0);
|
||||
return OPEN_OK;
|
||||
try {
|
||||
*out_handle = new (alloc) Vfs_handle(*this, *this, alloc, 0);
|
||||
return OPEN_OK;
|
||||
}
|
||||
catch (Genode::Out_of_ram) { return OPEN_ERR_OUT_OF_RAM; }
|
||||
catch (Genode::Out_of_caps) { return OPEN_ERR_OUT_OF_CAPS; }
|
||||
}
|
||||
|
||||
/*
|
||||
@ -558,8 +562,12 @@ class Vfs::Dir_file_system : public File_system
|
||||
|
||||
/* path equals directory name */
|
||||
if (strlen(path) == 0) {
|
||||
*out_handle = new (alloc) Vfs_handle(*this, *this, alloc, 0);
|
||||
return OPEN_OK;
|
||||
try {
|
||||
*out_handle = new (alloc) Vfs_handle(*this, *this, alloc, 0);
|
||||
return OPEN_OK;
|
||||
}
|
||||
catch (Genode::Out_of_ram) { return OPEN_ERR_OUT_OF_RAM; }
|
||||
catch (Genode::Out_of_caps) { return OPEN_ERR_OUT_OF_CAPS; }
|
||||
}
|
||||
|
||||
/* path refers to any of our sub file systems */
|
||||
@ -595,6 +603,9 @@ class Vfs::Dir_file_system : public File_system
|
||||
switch (r) {
|
||||
case OPENDIR_OK:
|
||||
break;
|
||||
case OPEN_ERR_OUT_OF_RAM:
|
||||
case OPEN_ERR_OUT_OF_CAPS:
|
||||
return r;
|
||||
case OPENDIR_ERR_LOOKUP_FAILED:
|
||||
default:
|
||||
continue;
|
||||
@ -625,8 +636,13 @@ class Vfs::Dir_file_system : public File_system
|
||||
* only, VFS root additionally calls 'open_composite_dirs' in order to
|
||||
* open its file systems
|
||||
*/
|
||||
Dir_vfs_handle *root_handle = new (alloc)
|
||||
Dir_vfs_handle(*this, *this, alloc, path);
|
||||
Dir_vfs_handle *root_handle;
|
||||
try {
|
||||
root_handle = new (alloc)
|
||||
Dir_vfs_handle(*this, *this, alloc, path);
|
||||
}
|
||||
catch (Genode::Out_of_ram) { return OPENDIR_ERR_OUT_OF_RAM; }
|
||||
catch (Genode::Out_of_caps) { return OPENDIR_ERR_OUT_OF_CAPS; }
|
||||
|
||||
/* the VFS root may contain more file systems */
|
||||
if (_vfs_root)
|
||||
@ -667,8 +683,13 @@ class Vfs::Dir_file_system : public File_system
|
||||
return opendir_result;
|
||||
}
|
||||
|
||||
Dir_vfs_handle *dir_vfs_handle = new (alloc)
|
||||
Dir_vfs_handle(*this, *this, alloc, path);
|
||||
Dir_vfs_handle *dir_vfs_handle;
|
||||
try {
|
||||
dir_vfs_handle = new (alloc)
|
||||
Dir_vfs_handle(*this, *this, alloc, path);
|
||||
}
|
||||
catch (Genode::Out_of_ram) { return OPENDIR_ERR_OUT_OF_RAM; }
|
||||
catch (Genode::Out_of_caps) { return OPENDIR_ERR_OUT_OF_CAPS; }
|
||||
|
||||
/* path equals "/" (for reading the name of this directory) */
|
||||
if (strlen(sub_path) == 0)
|
||||
|
Reference in New Issue
Block a user