mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-18 21:27:56 +00:00
parent
2e5166efd7
commit
400039e1b6
@ -148,6 +148,17 @@ class Rump_fs::Directory : public Node
|
||||
return node;
|
||||
}
|
||||
|
||||
void update_modification_time(Timestamp const time) override
|
||||
{
|
||||
struct timespec ts[2] = {
|
||||
{ .tv_sec = 0, .tv_nsec = 0 },
|
||||
{ .tv_sec = time.value, .tv_nsec = 0 }
|
||||
};
|
||||
|
||||
/* silently igore error */
|
||||
rump_sys_futimens(_fd, (const timespec*)&ts);
|
||||
}
|
||||
|
||||
size_t read(char *dst, size_t len, seek_off_t seek_offset) override
|
||||
{
|
||||
if (len < sizeof(Directory_entry)) {
|
||||
@ -230,10 +241,15 @@ class Rump_fs::Directory : public Node
|
||||
|
||||
Status status() override
|
||||
{
|
||||
struct stat st;
|
||||
if (rump_sys_fstat(_fd, &st) < 0)
|
||||
st.st_mtime = 0;
|
||||
|
||||
Status s;
|
||||
s.inode = inode();
|
||||
s.size = num_entries() * sizeof (Directory_entry);
|
||||
s.mode = File_system::Status::MODE_DIRECTORY;
|
||||
s.modification_time = { (int64_t)st.st_mtime };
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -114,6 +114,17 @@ class Rump_fs::File : public Node
|
||||
|
||||
virtual ~File() { rump_sys_close(_fd); }
|
||||
|
||||
void update_modification_time(Timestamp const time) override
|
||||
{
|
||||
struct timespec ts[2] = {
|
||||
{ .tv_sec = 0, .tv_nsec = 0 },
|
||||
{ .tv_sec = time.value, .tv_nsec = 0 }
|
||||
};
|
||||
|
||||
/* silently igore error */
|
||||
rump_sys_futimens(_fd, (const timespec*)&ts);
|
||||
}
|
||||
|
||||
size_t read(char *dst, size_t len, seek_off_t seek_offset) override
|
||||
{
|
||||
ssize_t ret;
|
||||
@ -142,25 +153,22 @@ class Rump_fs::File : public Node
|
||||
|
||||
virtual Status status() override
|
||||
{
|
||||
struct stat st;
|
||||
if (rump_sys_fstat(_fd, &st) < 0) {
|
||||
st.st_size = 0;
|
||||
st.st_mtime = 0;
|
||||
}
|
||||
|
||||
Status s;
|
||||
|
||||
s.inode = inode();
|
||||
s.size = length();
|
||||
s.size = st.st_size;
|
||||
s.mode = File_system::Status::MODE_FILE;
|
||||
s.modification_time = { (int64_t)st.st_mtime };
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
file_size_t length() const
|
||||
{
|
||||
struct stat s;
|
||||
|
||||
if(rump_sys_fstat(_fd, &s) < 0)
|
||||
return 0;
|
||||
|
||||
return s.st_size;
|
||||
}
|
||||
|
||||
void truncate(file_size_t size) override
|
||||
{
|
||||
rump_sys_ftruncate(_fd, size);
|
||||
|
@ -100,6 +100,15 @@ class Rump_fs::Session_component : public Session_rpc_object
|
||||
}
|
||||
break;
|
||||
|
||||
case Packet_descriptor::WRITE_TIMESTAMP:
|
||||
if (tx_sink()->packet_valid(packet) && packet.length() <= packet.size()) {
|
||||
packet.with_timestamp([&] (File_system::Timestamp const time) {
|
||||
open_node.node().update_modification_time(time);
|
||||
succeeded = true;
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
case Packet_descriptor::CONTENT_CHANGED:
|
||||
open_node.register_notify(*tx_sink());
|
||||
/* notify_listeners may bounce the packet back*/
|
||||
|
@ -54,6 +54,8 @@ class Rump_fs::Node : public Node_base
|
||||
*/
|
||||
void name(char const *name) { strncpy(_name, name, sizeof(_name)); }
|
||||
|
||||
virtual void update_modification_time(Timestamp const) = 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 Status status() = 0;
|
||||
|
@ -47,6 +47,11 @@ class Rump_fs::Symlink : public Node
|
||||
Node::name(basename(path));
|
||||
}
|
||||
|
||||
void update_modification_time(Timestamp const time) override
|
||||
{
|
||||
/* XXX not handled for now: either dirfd or fd to _path is required */
|
||||
}
|
||||
|
||||
size_t write(char const *src, size_t const len, seek_off_t seek_offset) override
|
||||
{
|
||||
/* Ideal symlink operations are atomic. */
|
||||
@ -68,10 +73,16 @@ class Rump_fs::Symlink : public Node
|
||||
|
||||
Status status() override
|
||||
{
|
||||
struct stat st;
|
||||
if (rump_sys_lstat(_path.base(), &st) < 0) {
|
||||
st.st_mtime = 0;
|
||||
}
|
||||
|
||||
Status s;
|
||||
s.inode = inode();
|
||||
s.size = length();
|
||||
s.mode = File_system::Status::MODE_SYMLINK;
|
||||
s.modification_time = { (int64_t)st.st_mtime };
|
||||
|
||||
return s;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user