diff --git a/src/server/lwext4_fs/main.cc b/src/server/lwext4_fs/main.cc index 826c1f0..bfa318a 100644 --- a/src/server/lwext4_fs/main.cc +++ b/src/server/lwext4_fs/main.cc @@ -102,6 +102,16 @@ class Lwext4_fs::Session_component : public File_system::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*/ diff --git a/src/server/lwext4_fs/node.h b/src/server/lwext4_fs/node.h index 3d13861..a0ac74f 100644 --- a/src/server/lwext4_fs/node.h +++ b/src/server/lwext4_fs/node.h @@ -57,6 +57,15 @@ class Lwext4_fs::Node : public Node_base } } + void update_modification_time(Timestamp const time) + { + /* lwext4 only supports 32bit time values */ + uint32_t const mtime = time.value > 0 ? (uint32_t)time.value : 0; + + /* silently ignore errors */ + (void)ext4_mtime_set(name(), mtime); + } + virtual Status status() { int err = ext4_raw_inode_fill(_name.base(), &_ino, &_inode); @@ -76,15 +85,24 @@ class Lwext4_fs::Node : public Node_base status.size = ext4_inode_get_size(sb, &_inode); status.inode = _ino; - unsigned int const v = ext4_inode_get_mode(sb, &_inode) & 0xf000; + unsigned int mtime = 0; + (void) ext4_mtime_get(_name.base(), &mtime); + status.modification_time = { mtime }; - switch (v) { + unsigned int const mode = ext4_inode_get_mode(sb, &_inode); + unsigned int const type = mode & 0xf000; + switch (type) { case EXT4_INODE_MODE_DIRECTORY: status.type = Node_type::DIRECTORY; break; case EXT4_INODE_MODE_SOFTLINK: status.type = Node_type::SYMLINK; break; case EXT4_INODE_MODE_FILE: default: status.type = Node_type::CONTINUOUS_FILE; break; } + status.rwx = { .readable = mode & 0x100, + .writeable = mode & 0x080, + .executable = mode & 0x040, + }; + return status; }