mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-23 09:15:36 +00:00
committed by
Christian Helmuth
parent
65a662f5b3
commit
d9043057a2
@ -24,6 +24,7 @@
|
|||||||
#include <file.h>
|
#include <file.h>
|
||||||
|
|
||||||
#include <lx_util.h>
|
#include <lx_util.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Lx_fs {
|
namespace Lx_fs {
|
||||||
@ -113,6 +114,14 @@ class Lx_fs::Directory : public Node
|
|||||||
closedir(_fd);
|
closedir(_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rename(Directory &dir_to, char const *name_from, char const *name_to)
|
||||||
|
{
|
||||||
|
int ret = renameat(dirfd(_fd), name_from,
|
||||||
|
dirfd(dir_to._fd), name_to);
|
||||||
|
if (ret != 0)
|
||||||
|
throw Unavailable();
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME returned file node must be locked */
|
/* FIXME returned file node must be locked */
|
||||||
File * file(char const *name, Mode mode, bool create) override
|
File * file(char const *name, Mode mode, bool create) override
|
||||||
{
|
{
|
||||||
|
@ -351,9 +351,32 @@ class Lx_fs::Session_component : public Session_rpc_object
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void move(Dir_handle, Name const &, Dir_handle, Name const &) override
|
void move(Dir_handle dir_from, Name const & name_from,
|
||||||
|
Dir_handle dir_to, Name const & name_to) override
|
||||||
{
|
{
|
||||||
Genode::error(__func__, " not implemented");
|
typedef File_system::Open_node<Directory> Dir_node;
|
||||||
|
|
||||||
|
Directory *to = 0;
|
||||||
|
|
||||||
|
auto to_fn = [&] (Dir_node &dir_node) {
|
||||||
|
to = &dir_node.node();
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
_open_node_registry.apply<Dir_node>(dir_to, to_fn);
|
||||||
|
} catch (Id_space<File_system::Node>::Unknown_id const &) {
|
||||||
|
throw Invalid_handle();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto move_fn = [&] (Dir_node &dir_node) {
|
||||||
|
dir_node.node().rename(*to, name_from.string(), name_to.string());
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
_open_node_registry.apply<Dir_node>(dir_from, move_fn);
|
||||||
|
} catch (Id_space<File_system::Node>::Unknown_id const &) {
|
||||||
|
throw Invalid_handle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user