mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-08 11:55:24 +00:00
parent
3b9f022f1c
commit
d354f7a8b9
@ -18,12 +18,6 @@
|
||||
#include <vfs/directory_service.h>
|
||||
#include <file_system_session/file_system_session.h>
|
||||
|
||||
static bool const verbose = false;
|
||||
#define PDBGV(...) if (verbose) PDBG(__VA_ARGS__)
|
||||
#define PERRV(...) if (verbose) PERR(__VA_ARGS__)
|
||||
|
||||
#define PERR_THROW(e) PERRV("%s - %s", __func__, #e); throw e();
|
||||
|
||||
namespace File_system {
|
||||
|
||||
using namespace Vfs;
|
||||
@ -33,11 +27,11 @@ namespace File_system {
|
||||
typedef Directory_service::Mkdir_result Result;
|
||||
|
||||
switch (r) {
|
||||
case Result::MKDIR_ERR_NAME_TOO_LONG: PERR_THROW(Name_too_long);
|
||||
case Result::MKDIR_ERR_NO_ENTRY: PERR_THROW(Lookup_failed);
|
||||
case Result::MKDIR_ERR_NO_SPACE: PERR_THROW(No_space);
|
||||
case Result::MKDIR_ERR_NO_PERM: PERR_THROW(Permission_denied);
|
||||
case Result::MKDIR_ERR_EXISTS: PERR_THROW(Node_already_exists);
|
||||
case Result::MKDIR_ERR_NAME_TOO_LONG: throw Name_too_long();
|
||||
case Result::MKDIR_ERR_NO_ENTRY: throw Lookup_failed();
|
||||
case Result::MKDIR_ERR_NO_SPACE: throw No_space();
|
||||
case Result::MKDIR_ERR_NO_PERM: throw Permission_denied();
|
||||
case Result::MKDIR_ERR_EXISTS: throw Node_already_exists();
|
||||
case Result::MKDIR_OK: break;
|
||||
}
|
||||
}
|
||||
@ -47,11 +41,11 @@ namespace File_system {
|
||||
typedef Directory_service::Open_result Result;
|
||||
|
||||
switch (r) {
|
||||
case Result::OPEN_ERR_NAME_TOO_LONG: PERR_THROW(Invalid_name);
|
||||
case Result::OPEN_ERR_UNACCESSIBLE: PERR_THROW(Lookup_failed);
|
||||
case Result::OPEN_ERR_NO_SPACE: PERR_THROW(No_space);
|
||||
case Result::OPEN_ERR_NO_PERM: PERR_THROW(Permission_denied);
|
||||
case Result::OPEN_ERR_EXISTS: PERR_THROW(Node_already_exists);
|
||||
case Result::OPEN_ERR_NAME_TOO_LONG: throw Invalid_name();
|
||||
case Result::OPEN_ERR_UNACCESSIBLE: throw Lookup_failed();
|
||||
case Result::OPEN_ERR_NO_SPACE: throw No_space();
|
||||
case Result::OPEN_ERR_NO_PERM: throw Permission_denied();
|
||||
case Result::OPEN_ERR_EXISTS: throw Node_already_exists();
|
||||
case Result::OPEN_OK: break;
|
||||
}
|
||||
}
|
||||
@ -61,11 +55,11 @@ namespace File_system {
|
||||
typedef Directory_service::Symlink_result Result;
|
||||
|
||||
switch (r) {
|
||||
case Result::SYMLINK_ERR_NAME_TOO_LONG: PERR_THROW(Invalid_name);
|
||||
case Result::SYMLINK_ERR_NO_ENTRY: PERR_THROW(Lookup_failed);
|
||||
case Result::SYMLINK_ERR_NO_SPACE: PERR_THROW(No_space);
|
||||
case Result::SYMLINK_ERR_NO_PERM: PERR_THROW(Permission_denied);
|
||||
case Result::SYMLINK_ERR_EXISTS: PERR_THROW(Node_already_exists);
|
||||
case Result::SYMLINK_ERR_NAME_TOO_LONG: throw Invalid_name();
|
||||
case Result::SYMLINK_ERR_NO_ENTRY: throw Lookup_failed();
|
||||
case Result::SYMLINK_ERR_NO_SPACE: throw No_space();
|
||||
case Result::SYMLINK_ERR_NO_PERM: throw Permission_denied();
|
||||
case Result::SYMLINK_ERR_EXISTS: throw Node_already_exists();
|
||||
case Result::SYMLINK_OK: break;
|
||||
}
|
||||
}
|
||||
@ -75,8 +69,8 @@ namespace File_system {
|
||||
typedef Directory_service::Readlink_result Result;
|
||||
|
||||
switch (r) {
|
||||
case Result::READLINK_ERR_NO_ENTRY: PERR_THROW(Lookup_failed);
|
||||
case Result::READLINK_ERR_NO_PERM: PERR_THROW(Permission_denied);
|
||||
case Result::READLINK_ERR_NO_ENTRY: throw Lookup_failed();
|
||||
case Result::READLINK_ERR_NO_PERM: throw Permission_denied();
|
||||
case Result::READLINK_OK: break;
|
||||
}
|
||||
}
|
||||
@ -86,9 +80,9 @@ namespace File_system {
|
||||
typedef File_io_service::Ftruncate_result Result;
|
||||
|
||||
switch (r) {
|
||||
case Result::FTRUNCATE_ERR_INTERRUPT: PERR_THROW(Invalid_handle);
|
||||
case Result::FTRUNCATE_ERR_NO_SPACE: PERR_THROW(No_space);
|
||||
case Result::FTRUNCATE_ERR_NO_PERM: PERR_THROW(Permission_denied);
|
||||
case Result::FTRUNCATE_ERR_INTERRUPT: throw Invalid_handle();
|
||||
case Result::FTRUNCATE_ERR_NO_SPACE: throw No_space();
|
||||
case Result::FTRUNCATE_ERR_NO_PERM: throw Permission_denied();
|
||||
case Result::FTRUNCATE_OK: break;
|
||||
}
|
||||
}
|
||||
@ -97,9 +91,9 @@ namespace File_system {
|
||||
{
|
||||
typedef Directory_service::Unlink_result Result;
|
||||
switch (r) {
|
||||
case Result::UNLINK_ERR_NO_ENTRY: PERR_THROW(Lookup_failed);
|
||||
case Result::UNLINK_ERR_NO_PERM: PERR_THROW(Permission_denied);
|
||||
case Result::UNLINK_ERR_NOT_EMPTY: PERR_THROW(Not_empty);
|
||||
case Result::UNLINK_ERR_NO_ENTRY: throw Lookup_failed();
|
||||
case Result::UNLINK_ERR_NO_PERM: throw Permission_denied();
|
||||
case Result::UNLINK_ERR_NOT_EMPTY: throw Not_empty();
|
||||
case Result::UNLINK_OK: break;
|
||||
}
|
||||
}
|
||||
@ -108,8 +102,8 @@ namespace File_system {
|
||||
{
|
||||
typedef Directory_service::Stat_result Result;
|
||||
switch (r) {
|
||||
case Result::STAT_ERR_NO_ENTRY: PERR_THROW(Lookup_failed);
|
||||
case Result::STAT_ERR_NO_PERM: PERR_THROW(Permission_denied);
|
||||
case Result::STAT_ERR_NO_ENTRY: throw Lookup_failed();
|
||||
case Result::STAT_ERR_NO_PERM: throw Permission_denied();
|
||||
case Result::STAT_OK: break;
|
||||
}
|
||||
}
|
||||
@ -118,9 +112,9 @@ namespace File_system {
|
||||
{
|
||||
typedef Directory_service::Rename_result Result;
|
||||
switch (r) {
|
||||
case Result::RENAME_ERR_NO_ENTRY: PERR_THROW(Lookup_failed);
|
||||
case Result::RENAME_ERR_CROSS_FS: PERR_THROW(Permission_denied);
|
||||
case Result::RENAME_ERR_NO_PERM: PERR_THROW(Permission_denied);
|
||||
case Result::RENAME_ERR_NO_ENTRY: throw Lookup_failed();
|
||||
case Result::RENAME_ERR_CROSS_FS: throw Permission_denied();
|
||||
case Result::RENAME_ERR_NO_PERM: throw Permission_denied();
|
||||
case Result::RENAME_OK: break;
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ namespace Vfs_server {
|
||||
{
|
||||
try { return Genode::config()->xml_node().sub_node("vfs"); }
|
||||
catch (...) {
|
||||
PERR("vfs not configured");
|
||||
Genode::error("vfs not configured");
|
||||
Genode::env()->parent()->exit(~0);
|
||||
Genode::sleep_forever();
|
||||
}
|
||||
@ -141,7 +141,6 @@ class Vfs_server::Session_component :
|
||||
seek_off_t const seek = packet.position();
|
||||
|
||||
if ((!(content && length)) || (packet.length() > packet.size())) {
|
||||
PDBGV("bad packet %d: %llu:%zu", packet.handle().value, packet.position(), packet.length());
|
||||
packet.succeeded(false);
|
||||
return;
|
||||
}
|
||||
@ -276,7 +275,6 @@ class Vfs_server::Session_component :
|
||||
|
||||
_ram.ref_account(Genode::env()->ram_session_cap());
|
||||
Genode::env()->ram_session()->transfer_quota(_ram.cap(), ram_quota);
|
||||
PWRN("ram quota starts at %zd for %s", _ram.quota(), _label.string());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -293,7 +291,6 @@ class Vfs_server::Session_component :
|
||||
size_t new_quota =
|
||||
Genode::Arg_string::find_arg(args, "ram_quota").ulong_value(0);
|
||||
Genode::env()->ram_session()->transfer_quota(_ram.cap(), new_quota);
|
||||
PWRN("ram quota upgraded to %zd for %s", _ram.quota(), _label.string());
|
||||
}
|
||||
|
||||
|
||||
@ -303,8 +300,6 @@ class Vfs_server::Session_component :
|
||||
|
||||
Dir_handle dir(File_system::Path const &path, bool create) override
|
||||
{
|
||||
PDBGV("%s create=%d", path.string(), create);
|
||||
|
||||
if (create && (!_writable))
|
||||
throw Permission_denied();
|
||||
|
||||
@ -337,8 +332,6 @@ class Vfs_server::Session_component :
|
||||
File_handle file(Dir_handle dir_handle, Name const &name,
|
||||
Mode fs_mode, bool create) override
|
||||
{
|
||||
PDBGV("%d:%s create=%d", dir_handle.value, name.string(), create);
|
||||
|
||||
if ((create || (fs_mode & WRITE_ONLY)) && (!_writable))
|
||||
throw Permission_denied();
|
||||
|
||||
@ -358,8 +351,6 @@ class Vfs_server::Session_component :
|
||||
|
||||
Symlink_handle symlink(Dir_handle dir_handle, Name const &name, bool create) override
|
||||
{
|
||||
PDBGV("%d:%s create=%d", dir_handle.value, name.string(), create);
|
||||
|
||||
if (create && !_writable) throw Permission_denied();
|
||||
|
||||
Directory &dir = _lookup(dir_handle);
|
||||
@ -379,8 +370,6 @@ class Vfs_server::Session_component :
|
||||
|
||||
Node_handle node(File_system::Path const &path) override
|
||||
{
|
||||
PDBGV("%s", path.string());
|
||||
|
||||
char const *path_str = path.string();
|
||||
/* '/' is bound to '0' */
|
||||
if (!strcmp(path_str, "/"))
|
||||
@ -406,8 +395,6 @@ class Vfs_server::Session_component :
|
||||
|
||||
void close(Node_handle handle) override
|
||||
{
|
||||
PDBGV("%d", handle.value);
|
||||
|
||||
/* handle '0' cannot be freed */
|
||||
if (!handle.value) {
|
||||
_root.notify_listeners();
|
||||
@ -443,10 +430,8 @@ class Vfs_server::Session_component :
|
||||
listener = Listener();
|
||||
}
|
||||
|
||||
Status status(Node_handle node_handle)
|
||||
Status status(Node_handle node_handle) override
|
||||
{
|
||||
PDBGV("%d", node_handle.value);
|
||||
|
||||
Directory_service::Stat vfs_stat;
|
||||
File_system::Status fs_stat;
|
||||
|
||||
@ -480,10 +465,8 @@ class Vfs_server::Session_component :
|
||||
return fs_stat;
|
||||
}
|
||||
|
||||
void unlink(Dir_handle dir_handle, Name const &name)
|
||||
void unlink(Dir_handle dir_handle, Name const &name) override
|
||||
{
|
||||
PDBGV("%d:%s", dir_handle.value, name.string());
|
||||
|
||||
if (!_writable) throw Permission_denied();
|
||||
|
||||
Directory &dir = _lookup(dir_handle);
|
||||
@ -497,19 +480,12 @@ class Vfs_server::Session_component :
|
||||
dir.mark_as_updated();
|
||||
}
|
||||
|
||||
void truncate(File_handle file_handle, file_size_t size)
|
||||
{
|
||||
PDBGV("%d", file_handle.value);
|
||||
_lookup(file_handle).truncate(size);
|
||||
}
|
||||
void truncate(File_handle file_handle, file_size_t size) override {
|
||||
_lookup(file_handle).truncate(size); }
|
||||
|
||||
void move(Dir_handle from_dir_handle, Name const &from_name,
|
||||
Dir_handle to_dir_handle, Name const &to_name)
|
||||
Dir_handle to_dir_handle, Name const &to_name) override
|
||||
{
|
||||
PDBGV("%d:%s - %d:%s",
|
||||
from_dir_handle.value, from_name.string(),
|
||||
to_dir_handle.value, to_name.string());
|
||||
|
||||
if (!_writable)
|
||||
throw Permission_denied();
|
||||
|
||||
@ -533,7 +509,6 @@ class Vfs_server::Session_component :
|
||||
|
||||
void sigh(Node_handle handle, Signal_context_capability sigh) override
|
||||
{
|
||||
PDBGV("%d", handle.value);
|
||||
if (!_in_range(handle.value))
|
||||
throw Invalid_handle();
|
||||
|
||||
@ -560,9 +535,8 @@ class Vfs_server::Session_component :
|
||||
/**
|
||||
* Sync the VFS and send any pending signals on the node.
|
||||
*/
|
||||
void sync(Node_handle handle)
|
||||
void sync(Node_handle handle) override
|
||||
{
|
||||
PDBGV("%d", handle.value);
|
||||
try {
|
||||
Node &node = _lookup(handle);
|
||||
_vfs.sync(node.path());
|
||||
@ -570,7 +544,7 @@ class Vfs_server::Session_component :
|
||||
} catch (Invalid_handle) { }
|
||||
}
|
||||
|
||||
void control(Node_handle, Control) { }
|
||||
void control(Node_handle, Control) override { }
|
||||
};
|
||||
|
||||
|
||||
@ -644,15 +618,15 @@ class Vfs_server::Root :
|
||||
tx_buf_size;
|
||||
|
||||
if (session_size > ram_quota) {
|
||||
PERR("insufficient 'ram_quota' from %s, got %zd, need %zd",
|
||||
label.string(), ram_quota, session_size);
|
||||
error("insufficient 'ram_quota' from '", label, "' "
|
||||
"got ", ram_quota, ", need ", session_size);
|
||||
throw Root::Quota_exceeded();
|
||||
}
|
||||
ram_quota -= session_size;
|
||||
|
||||
/* check if the session root exists */
|
||||
if (!((session_root == "/") || _vfs.directory(session_root.base()))) {
|
||||
PERR("session root '%s' not found for '%s'", session_root.base(), label.string());
|
||||
error("session root '", session_root, "' not found for '", label, "'");
|
||||
throw Root::Unavailable();
|
||||
}
|
||||
|
||||
@ -665,7 +639,7 @@ class Vfs_server::Root :
|
||||
session_root.base(),
|
||||
writeable);
|
||||
|
||||
PLOG("session opened for '%s' at '%s'", label.string(), session_root.base());
|
||||
Genode::log("session opened for '", label, "' at '", session_root, "'");
|
||||
return session;
|
||||
}
|
||||
|
||||
@ -706,7 +680,6 @@ struct Vfs_server::Main
|
||||
Main(Server::Entrypoint &ep) : ep(ep)
|
||||
{
|
||||
env()->parent()->announce(ep.manage(fs_root));
|
||||
PLOG("virtual file system server started");
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user