os: handle SYNC packet in lx_fs

Call 'fsync(2)' on files and directories.

Fixes #3711.
This commit is contained in:
Josef Söntgen 2020-03-23 17:13:39 +01:00 committed by Christian Helmuth
parent df553e9360
commit 336228f357
4 changed files with 18 additions and 7 deletions

View File

@ -237,6 +237,12 @@ class Lx_fs::Directory : public Node
return 0; return 0;
} }
bool sync() override
{
int ret = fsync(dirfd(_fd));
return ret ? false : true;
}
Status status() override Status status() override
{ {
struct stat st { }; struct stat st { };

View File

@ -141,6 +141,12 @@ class Lx_fs::File : public Node
return ret == -1 ? 0 : ret; return ret == -1 ? 0 : ret;
} }
bool sync() override
{
int ret = fsync(_fd);
return ret ? false : true;
}
Status status() override Status status() override
{ {
struct stat st { }; struct stat st { };

View File

@ -121,13 +121,10 @@ class Lx_fs::Session_component : public Session_rpc_object
case Packet_descriptor::SYNC: case Packet_descriptor::SYNC:
/** if (tx_sink()->packet_valid(packet)) {
* We could call sync(2) here but for now we forward just the succeeded = open_node.node().sync();
* reminder because besides testing, there is currently no }
* use-case.
*/
Genode::warning("SYNC not implemented!");
succeeded = true;
break; break;
} }

View File

@ -53,6 +53,8 @@ class Lx_fs::Node : public File_system::Node_base
virtual size_t read(char *dst, size_t len, seek_off_t) = 0; virtual size_t read(char *dst, size_t len, seek_off_t) = 0;
virtual size_t write(char const *src, size_t len, seek_off_t) = 0; virtual size_t write(char const *src, size_t len, seek_off_t) = 0;
virtual bool sync() { return true; }
virtual Status status() = 0; virtual Status status() = 0;
/* /*