diff --git a/repos/dde_linux/src/lib/vfs/lxip/vfs.cc b/repos/dde_linux/src/lib/vfs/lxip/vfs.cc index fa11b12d96..24a66f095e 100644 --- a/repos/dde_linux/src/lib/vfs/lxip/vfs.cc +++ b/repos/dde_linux/src/lib/vfs/lxip/vfs.cc @@ -267,7 +267,7 @@ struct Vfs::Lxip_vfs_handle : Vfs::Vfs_handle /** * Check if the file attached to this handle is ready to read */ - virtual bool read_ready() = 0; + virtual bool read_ready() const = 0; virtual Read_result read(char *dst, file_size count, file_size &out_count) = 0; @@ -312,7 +312,7 @@ struct Vfs::Lxip_vfs_file_handle final : Vfs::Lxip_vfs_handle file->handles.remove(&file_le); } - bool read_ready() override { + bool read_ready() const override { return (file) ? file->poll() : false; } Read_result read(char *dst, file_size count, file_size &out_count) override @@ -364,7 +364,7 @@ struct Vfs::Lxip_vfs_dir_handle final : Vfs::Lxip_vfs_handle : Vfs::Lxip_vfs_handle(fs, alloc, status_flags), dir(dir) { } - bool read_ready() override { return true; } + bool read_ready() const override { return true; } Read_result read(char *dst, file_size count, file_size &out_count) override { @@ -1202,7 +1202,7 @@ struct Vfs::Lxip_socket_handle final : Vfs::Lxip_vfs_handle socket_dir(alloc, parent, sock) { } - bool read_ready() override { return true; } + bool read_ready() const override { return true; } Read_result read(char *dst, file_size count, file_size &out_count) override { @@ -1994,10 +1994,11 @@ class Vfs::Lxip_file_system : public Vfs::File_system, return false; } - bool read_ready(Vfs_handle *vfs_handle) override + bool read_ready(Vfs_handle const &vfs_handle) const override { - Lxip_vfs_handle &handle = - *static_cast(vfs_handle); + Lxip_vfs_handle const &handle = + static_cast(vfs_handle); + return handle.read_ready(); } diff --git a/repos/dde_rump/src/lib/vfs/rump/vfs_rump.cc b/repos/dde_rump/src/lib/vfs/rump/vfs_rump.cc index b168fb2d1c..82b5e0c8df 100644 --- a/repos/dde_rump/src/lib/vfs/rump/vfs_rump.cc +++ b/repos/dde_rump/src/lib/vfs/rump/vfs_rump.cc @@ -807,8 +807,7 @@ class Vfs::Rump_file_system : public File_system return READ_ERR_INVALID; } - bool read_ready(Vfs_handle *) override { return true; } - + bool read_ready (Vfs_handle const &) const override { return true; } bool write_ready(Vfs_handle const &) const override { return true; } Ftruncate_result ftruncate(Vfs_handle *vfs_handle, file_size len) override diff --git a/repos/gems/src/lib/vfs/audit/vfs_audit.cc b/repos/gems/src/lib/vfs/audit/vfs_audit.cc index c58cffd7d3..12c23c6d03 100644 --- a/repos/gems/src/lib/vfs/audit/vfs_audit.cc +++ b/repos/gems/src/lib/vfs/audit/vfs_audit.cc @@ -268,16 +268,21 @@ class Vfs_audit::File_system : public Vfs::File_system return result; } - bool read_ready(Vfs_handle *vfs_handle) override + bool read_ready(Vfs_handle const &vfs_handle) const override { - Handle &h = *static_cast(vfs_handle); - h.sync_state(); - return h.audit->fs().read_ready(h.audit); + Handle const &h = static_cast(vfs_handle); + + const_cast(h).sync_state(); + + return h.audit->fs().read_ready(*h.audit); } bool write_ready(Vfs_handle const &vfs_handle) const override { Handle const &h = static_cast(vfs_handle); + + const_cast(h).sync_state(); + return h.audit->fs().write_ready(*h.audit); } diff --git a/repos/gems/src/lib/vfs/cbe/vfs.cc b/repos/gems/src/lib/vfs/cbe/vfs.cc index f657ea7ca8..2eff57abd0 100644 --- a/repos/gems/src/lib/vfs/cbe/vfs.cc +++ b/repos/gems/src/lib/vfs/cbe/vfs.cc @@ -2020,8 +2020,7 @@ class Vfs_cbe::Data_file_system : public Single_file_system return SYNC_ERR_INVALID; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return true; } }; @@ -2191,8 +2190,7 @@ class Vfs_cbe::Extend_file_system : public Vfs::Single_file_system return WRITE_OK; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return true; } }; @@ -2376,8 +2374,7 @@ class Vfs_cbe::Rekey_file_system : public Vfs::Single_file_system return WRITE_OK; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return true; } }; @@ -2561,8 +2558,7 @@ class Vfs_cbe::Deinitialize_file_system : public Vfs::Single_file_system return WRITE_OK; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return true; } }; @@ -2699,8 +2695,7 @@ class Vfs_cbe::Create_snapshot_file_system : public Vfs::Single_file_system return WRITE_OK; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return true; } }; @@ -2799,8 +2794,7 @@ class Vfs_cbe::Discard_snapshot_file_system : public Vfs::Single_file_system return WRITE_ERR_IO; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return true; } }; @@ -3065,7 +3059,7 @@ class Vfs_cbe::Snapshots_file_system : public Vfs::File_system return SYNC_OK; } - virtual bool read_ready() = 0; + virtual bool read_ready() const = 0; }; @@ -3159,7 +3153,7 @@ class Vfs_cbe::Snapshots_file_system : public Vfs::File_system return WRITE_ERR_INVALID; } - bool read_ready() override { return true; } + bool read_ready() const override { return true; } }; struct Dir_snap_vfs_handle : Vfs::Vfs_handle @@ -3457,7 +3451,7 @@ class Vfs_cbe::Snapshots_file_system : public Vfs::File_system return READ_ERR_IO; } - bool read_ready(Vfs::Vfs_handle *) override + bool read_ready(Vfs::Vfs_handle const &) const override { return true; } diff --git a/repos/gems/src/lib/vfs/cbe_crypto/vfs.cc b/repos/gems/src/lib/vfs/cbe_crypto/vfs.cc index cc309ebca0..832f266233 100644 --- a/repos/gems/src/lib/vfs/cbe_crypto/vfs.cc +++ b/repos/gems/src/lib/vfs/cbe_crypto/vfs.cc @@ -123,8 +123,7 @@ class Vfs_cbe_crypto::Encrypt_file_system : public Vfs::Single_file_system return WRITE_OK; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return true; } }; @@ -257,8 +256,7 @@ class Vfs_cbe_crypto::Decrypt_file_system : public Vfs::Single_file_system return WRITE_OK; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return true; } }; @@ -512,7 +510,7 @@ class Vfs_cbe_crypto::Keys_file_system : public Vfs::File_system return SYNC_OK; } - virtual bool read_ready() = 0; + virtual bool read_ready() const = 0; }; @@ -606,7 +604,7 @@ class Vfs_cbe_crypto::Keys_file_system : public Vfs::File_system return WRITE_ERR_INVALID; } - bool read_ready() override { return true; } + bool read_ready() const override { return true; } }; @@ -892,7 +890,7 @@ class Vfs_cbe_crypto::Keys_file_system : public Vfs::File_system return READ_ERR_IO; } - bool read_ready(Vfs::Vfs_handle *) override + bool read_ready(Vfs::Vfs_handle const &) const override { return true; } @@ -1006,8 +1004,7 @@ class Vfs_cbe_crypto::Management_file_system : public Vfs::Single_file_system return WRITE_ERR_IO; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return true; } }; diff --git a/repos/gems/src/lib/vfs/cbe_trust_anchor/vfs.cc b/repos/gems/src/lib/vfs/cbe_trust_anchor/vfs.cc index ec92a4356c..fb7f163787 100644 --- a/repos/gems/src/lib/vfs/cbe_trust_anchor/vfs.cc +++ b/repos/gems/src/lib/vfs/cbe_trust_anchor/vfs.cc @@ -1369,8 +1369,7 @@ class Vfs_cbe_trust_anchor::Hashsum_file_system : public Vfs::Single_file_system return WRITE_OK; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return true; } }; @@ -1477,8 +1476,7 @@ class Vfs_cbe_trust_anchor::Generate_key_file_system : public Vfs::Single_file_s return WRITE_ERR_IO; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return false; } }; @@ -1607,8 +1605,7 @@ class Vfs_cbe_trust_anchor::Encrypt_file_system : public Vfs::Single_file_system return WRITE_OK; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return true; } }; @@ -1736,8 +1733,7 @@ class Vfs_cbe_trust_anchor::Decrypt_file_system : public Vfs::Single_file_system return WRITE_OK; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return true; } }; @@ -1858,8 +1854,7 @@ class Vfs_cbe_trust_anchor::Initialize_file_system : public Vfs::Single_file_sys return WRITE_OK; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return true; } }; diff --git a/repos/gems/src/lib/vfs/gpu/vfs.cc b/repos/gems/src/lib/vfs/gpu/vfs.cc index 2d89c17c46..73a561bd1d 100644 --- a/repos/gems/src/lib/vfs/gpu/vfs.cc +++ b/repos/gems/src/lib/vfs/gpu/vfs.cc @@ -79,8 +79,7 @@ struct Vfs_gpu::File_system : Single_file_system return WRITE_ERR_IO; } - bool read_ready() override { return _complete; } - + bool read_ready() const override { return _complete; } bool write_ready() const override { return true; } Id_space::Id id() const { return _elem.id(); } diff --git a/repos/gems/src/lib/vfs/import/plugin.cc b/repos/gems/src/lib/vfs/import/plugin.cc index 0bb90e0c18..603d320471 100644 --- a/repos/gems/src/lib/vfs/import/plugin.cc +++ b/repos/gems/src/lib/vfs/import/plugin.cc @@ -284,7 +284,7 @@ class Vfs_import::File_system : public Vfs::File_system file_size&) override { return READ_ERR_INVALID; } - bool read_ready(Vfs_handle*) override { + bool read_ready(Vfs_handle const &) const override { return true; } bool write_ready(Vfs_handle const &) const override { diff --git a/repos/gems/src/lib/vfs/pipe/plugin.cc b/repos/gems/src/lib/vfs/pipe/plugin.cc index 2382e85795..86ce8c2cb0 100644 --- a/repos/gems/src/lib/vfs/pipe/plugin.cc +++ b/repos/gems/src/lib/vfs/pipe/plugin.cc @@ -76,7 +76,7 @@ struct Vfs_pipe::Pipe_handle : Vfs::Vfs_handle, private Pipe_handle_registry_ele file_size count, file_size &out_count); - bool read_ready(); + bool read_ready() const; bool write_ready() const; bool notify_read_ready(); }; @@ -275,14 +275,16 @@ Vfs_pipe::Pipe_handle::write(const char *buf, Vfs_pipe::Read_result -Vfs_pipe::Pipe_handle::read(char *buf, - file_size count, - file_size &out_count) { - return Pipe_handle::pipe.read(*this, buf, count, out_count); } +Vfs_pipe::Pipe_handle::read(char *buf, file_size count, file_size &out_count) +{ + return Pipe_handle::pipe.read(*this, buf, count, out_count); +} -bool Vfs_pipe::Pipe_handle::read_ready() { - return !writer && !pipe.buffer.empty(); } +bool Vfs_pipe::Pipe_handle::read_ready() const +{ + return !writer && !pipe.buffer.empty(); +} bool Vfs_pipe::Pipe_handle::write_ready() const @@ -599,9 +601,9 @@ class Vfs_pipe::File_system : public Vfs::File_system return READ_ERR_INVALID; } - bool read_ready(Vfs_handle *vfs_handle) override + bool read_ready(Vfs_handle const &vfs_handle) const override { - if (Pipe_handle *handle = dynamic_cast(vfs_handle)) + if (Pipe_handle const *handle = dynamic_cast(&vfs_handle)) return handle->read_ready(); return true; } diff --git a/repos/gems/src/lib/vfs/trace/vfs.cc b/repos/gems/src/lib/vfs/trace/vfs.cc index b1c53f2ba4..2fa3f88bbb 100644 --- a/repos/gems/src/lib/vfs/trace/vfs.cc +++ b/repos/gems/src/lib/vfs/trace/vfs.cc @@ -147,8 +147,7 @@ class Vfs_trace::Trace_buffer_file_system : public Single_file_system return WRITE_ERR_INVALID; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return false; } }; diff --git a/repos/gems/src/lib/vfs/ttf/glyphs_file_system.h b/repos/gems/src/lib/vfs/ttf/glyphs_file_system.h index 6dcd327e8a..4ae51b2b32 100644 --- a/repos/gems/src/lib/vfs/ttf/glyphs_file_system.h +++ b/repos/gems/src/lib/vfs/ttf/glyphs_file_system.h @@ -106,8 +106,7 @@ class Vfs::Glyphs_file_system : public Vfs::Single_file_system return WRITE_ERR_IO; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return false; } }; diff --git a/repos/libports/src/lib/libc/vfs_plugin.cc b/repos/libports/src/lib/libc/vfs_plugin.cc index 95d0601ad4..56762754ec 100644 --- a/repos/libports/src/lib/libc/vfs_plugin.cc +++ b/repos/libports/src/lib/libc/vfs_plugin.cc @@ -219,7 +219,7 @@ namespace Libc { handle->fs().notify_read_ready(handle); - return handle->fs().read_ready(handle); + return handle->fs().read_ready(*handle); } bool write_ready_from_kernel(File_descriptor *fd) @@ -2721,7 +2721,7 @@ int Libc::Vfs_plugin::select(int nfds, if (!handle) continue; if (fd_in_readfds) { - if (handle->fs().read_ready(handle)) { + if (handle->fs().read_ready(*handle)) { FD_SET(fd, readfds); ++nready; } else { diff --git a/repos/libports/src/lib/vfs/fatfs/vfs_fatfs.cc b/repos/libports/src/lib/vfs/fatfs/vfs_fatfs.cc index 986cc19e60..a700a529f7 100644 --- a/repos/libports/src/lib/vfs/fatfs/vfs_fatfs.cc +++ b/repos/libports/src/lib/vfs/fatfs/vfs_fatfs.cc @@ -777,7 +777,7 @@ class Fatfs::File_system : public Vfs::File_system FTRUNCATE_OK : FTRUNCATE_ERR_NO_PERM; } - bool read_ready(Vfs_handle *) override { return true; } + bool read_ready(Vfs_handle const &) const override { return true; } bool write_ready(Vfs_handle const &) const override { diff --git a/repos/libports/src/lib/vfs/jitterentropy/vfs_jitterentropy.h b/repos/libports/src/lib/vfs/jitterentropy/vfs_jitterentropy.h index 54d5ffaa21..69159eef32 100644 --- a/repos/libports/src/lib/vfs/jitterentropy/vfs_jitterentropy.h +++ b/repos/libports/src/lib/vfs/jitterentropy/vfs_jitterentropy.h @@ -94,8 +94,7 @@ class Jitterentropy_file_system : public Vfs::Single_file_system return WRITE_ERR_IO; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return false; } }; diff --git a/repos/libports/src/lib/vfs/libusb/vfs_libusb.cc b/repos/libports/src/lib/vfs/libusb/vfs_libusb.cc index a3c5cf4dc8..822390ef19 100644 --- a/repos/libports/src/lib/vfs/libusb/vfs_libusb.cc +++ b/repos/libports/src/lib/vfs/libusb/vfs_libusb.cc @@ -77,9 +77,10 @@ class Libusb_file_system : public Vfs::Single_file_system libusb_genode_usb_connection(&_usb_connection); } - bool read_ready() override + bool read_ready() const override { - return _usb_connection.source()->ack_avail(); + auto &nonconst_this = const_cast(*this); + return nonconst_this._usb_connection.source()->ack_avail(); } Read_result read(char *dst, Vfs::file_size count, diff --git a/repos/libports/src/lib/vfs/lwip/vfs.cc b/repos/libports/src/lib/vfs/lwip/vfs.cc index 55f939c5ff..b8da2e6e27 100644 --- a/repos/libports/src/lib/vfs/lwip/vfs.cc +++ b/repos/libports/src/lib/vfs/lwip/vfs.cc @@ -426,8 +426,7 @@ struct Lwip::Socket_dir : Lwip::Directory char const *src, file_size count, file_size &out_count) = 0; - virtual bool read_ready(Lwip_file_handle&) = 0; - + virtual bool read_ready (Lwip_file_handle const &) const = 0; virtual bool write_ready(Lwip_file_handle const &) const = 0; /** @@ -891,7 +890,7 @@ class Lwip::Udp_socket_dir final : ** Socket_dir interface ** **************************/ - bool read_ready(Lwip_file_handle &handle) override + bool read_ready(Lwip_file_handle const &handle) const override { switch (handle.kind) { case Lwip_file_handle::DATA: @@ -1254,7 +1253,7 @@ class Lwip::Tcp_socket_dir final : ** Socket_dir interface ** **************************/ - bool read_ready(Lwip_file_handle &handle) override + bool read_ready(Lwip_file_handle const &handle) const override { switch (handle.kind) { case Lwip_file_handle::DATA: @@ -2111,12 +2110,13 @@ class Lwip::File_system final : public Vfs::File_system, public Lwip::Directory, return false; } - bool read_ready(Vfs_handle *vfs_handle) override + bool read_ready(Vfs_handle const &vfs_handle) const override { - if (Lwip_file_handle *handle = dynamic_cast(vfs_handle)) { - if (handle->socket) - return handle->socket->read_ready(*handle); - } + Lwip_file_handle const * const handle_ptr = + dynamic_cast(&vfs_handle); + + if (handle_ptr && handle_ptr->socket) + return handle_ptr->socket->read_ready(*handle_ptr); /* * in this case the polled file is a 'new_socket' diff --git a/repos/libports/src/lib/vfs/oss/vfs_oss.cc b/repos/libports/src/lib/vfs/oss/vfs_oss.cc index 00a5edae66..d4059ca371 100644 --- a/repos/libports/src/lib/vfs/oss/vfs_oss.cc +++ b/repos/libports/src/lib/vfs/oss/vfs_oss.cc @@ -285,7 +285,7 @@ struct Vfs::Oss_file_system::Audio _in->overrun_sigh(sigh); } - bool read_ready() + bool read_ready() const { return _info.ifrag_bytes > 0; } @@ -681,7 +681,7 @@ class Vfs::Oss_file_system::Data_file_system : public Single_file_system return result; } - bool read_ready() override + bool read_ready() const override { return _audio.read_ready(); } diff --git a/repos/os/include/vfs/dir_file_system.h b/repos/os/include/vfs/dir_file_system.h index b8bb62a28b..eb203e8686 100644 --- a/repos/os/include/vfs/dir_file_system.h +++ b/repos/os/include/vfs/dir_file_system.h @@ -965,12 +965,12 @@ class Vfs::Dir_file_system : public File_system return FTRUNCATE_ERR_NO_PERM; } - bool read_ready(Vfs_handle *handle) override + bool read_ready(Vfs_handle const &handle) const override { - if (&handle->fs() == this) + if (&handle.fs() == this) return true; - return handle->fs().read_ready(handle); + return handle.fs().read_ready(handle); } bool write_ready(Vfs_handle const &handle) const override diff --git a/repos/os/include/vfs/file_io_service.h b/repos/os/include/vfs/file_io_service.h index 491e00dd7e..eaf8d3e22d 100644 --- a/repos/os/include/vfs/file_io_service.h +++ b/repos/os/include/vfs/file_io_service.h @@ -67,7 +67,7 @@ struct Vfs::File_io_service : Interface /** * Return true if the handle has readable data */ - virtual bool read_ready(Vfs_handle *) = 0; + virtual bool read_ready(Vfs_handle const &) const = 0; /** * Return true if the handle might accept a write operation diff --git a/repos/os/include/vfs/readonly_value_file_system.h b/repos/os/include/vfs/readonly_value_file_system.h index a1ea01c9a8..9aebe0df5f 100644 --- a/repos/os/include/vfs/readonly_value_file_system.h +++ b/repos/os/include/vfs/readonly_value_file_system.h @@ -72,8 +72,7 @@ class Vfs::Readonly_value_file_system : public Vfs::Single_file_system return WRITE_ERR_IO; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return false; } }; diff --git a/repos/os/include/vfs/single_file_system.h b/repos/os/include/vfs/single_file_system.h index f84ead2d9a..868edc5e54 100644 --- a/repos/os/include/vfs/single_file_system.h +++ b/repos/os/include/vfs/single_file_system.h @@ -48,7 +48,7 @@ class Vfs::Single_file_system : public File_system return SYNC_OK; } - virtual bool read_ready() = 0; + virtual bool read_ready() const = 0; virtual bool write_ready() const = 0; @@ -132,8 +132,7 @@ class Vfs::Single_file_system : public File_system return WRITE_ERR_INVALID; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return true; } }; @@ -281,15 +280,12 @@ class Vfs::Single_file_system : public File_system return WRITE_ERR_INVALID; } - bool read_ready(Vfs_handle *vfs_handle) override + bool read_ready(Vfs_handle const &vfs_handle) const override { - Single_vfs_handle *handle = - static_cast(vfs_handle); + Single_vfs_handle const &handle = + static_cast(vfs_handle); - if (handle) - return handle->read_ready(); - - return false; + return handle.read_ready(); } bool write_ready(Vfs_handle const &vfs_handle) const override diff --git a/repos/os/include/vfs/value_file_system.h b/repos/os/include/vfs/value_file_system.h index 24875ea792..9805147c8f 100644 --- a/repos/os/include/vfs/value_file_system.h +++ b/repos/os/include/vfs/value_file_system.h @@ -84,8 +84,7 @@ class Vfs::Value_file_system : public Vfs::Single_file_system return WRITE_OK; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return true; } private: diff --git a/repos/os/src/lib/vfs/block_file_system.h b/repos/os/src/lib/vfs/block_file_system.h index 28ba455ed2..ef4f1df033 100644 --- a/repos/os/src/lib/vfs/block_file_system.h +++ b/repos/os/src/lib/vfs/block_file_system.h @@ -337,8 +337,7 @@ class Vfs::Block_file_system::Data_file_system : public Single_file_system return SYNC_OK; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return true; } }; diff --git a/repos/os/src/lib/vfs/capture/plugin.cc b/repos/os/src/lib/vfs/capture/plugin.cc index 1faa92e4bb..ac802c4e86 100644 --- a/repos/os/src/lib/vfs/capture/plugin.cc +++ b/repos/os/src/lib/vfs/capture/plugin.cc @@ -67,8 +67,7 @@ class Vfs_capture::Data_file_system : public Single_file_system _capture(capture), _capture_ds(capture_ds) { } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return true; } Read_result read(char *dst, file_size count, diff --git a/repos/os/src/lib/vfs/fs_file_system.h b/repos/os/src/lib/vfs/fs_file_system.h index d1cbbd8124..b5715da148 100644 --- a/repos/os/src/lib/vfs/fs_file_system.h +++ b/repos/os/src/lib/vfs/fs_file_system.h @@ -953,11 +953,11 @@ class Vfs::Fs_file_system : public File_system, private Remote_io return result; } - bool read_ready(Vfs_handle *vfs_handle) override + bool read_ready(Vfs_handle const &vfs_handle) const override { - Fs_vfs_handle *handle = static_cast(vfs_handle); + Fs_vfs_handle const &handle = static_cast(vfs_handle); - return handle->read_ready_state == Handle_state::Read_ready_state::READY; + return handle.read_ready_state == Handle_state::Read_ready_state::READY; } bool write_ready(Vfs_handle const &) const override diff --git a/repos/os/src/lib/vfs/inline_file_system.h b/repos/os/src/lib/vfs/inline_file_system.h index d60edd1e35..37a6f96ff8 100644 --- a/repos/os/src/lib/vfs/inline_file_system.h +++ b/repos/os/src/lib/vfs/inline_file_system.h @@ -89,8 +89,7 @@ class Vfs::Inline_file_system : public Single_file_system return WRITE_ERR_INVALID; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return false; } }; diff --git a/repos/os/src/lib/vfs/log_file_system.h b/repos/os/src/lib/vfs/log_file_system.h index ffa0aec7f6..5d494bb497 100644 --- a/repos/os/src/lib/vfs/log_file_system.h +++ b/repos/os/src/lib/vfs/log_file_system.h @@ -126,8 +126,7 @@ class Vfs::Log_file_system : public Single_file_system return WRITE_OK; } - bool read_ready() override { return false; } - + bool read_ready() const override { return false; } bool write_ready() const override { return true; } Sync_result sync() override diff --git a/repos/os/src/lib/vfs/null_file_system.h b/repos/os/src/lib/vfs/null_file_system.h index 89733a6722..655b68148e 100644 --- a/repos/os/src/lib/vfs/null_file_system.h +++ b/repos/os/src/lib/vfs/null_file_system.h @@ -53,8 +53,7 @@ struct Vfs::Null_file_system : Single_file_system return WRITE_OK; } - bool read_ready() override { return false; } - + bool read_ready() const override { return false; } bool write_ready() const override { return true; } }; diff --git a/repos/os/src/lib/vfs/ram_file_system.h b/repos/os/src/lib/vfs/ram_file_system.h index b345977b2a..9354331fd1 100644 --- a/repos/os/src/lib/vfs/ram_file_system.h +++ b/repos/os/src/lib/vfs/ram_file_system.h @@ -966,8 +966,7 @@ class Vfs::Ram_file_system : public Vfs::File_system return handle->node.complete_read(dst, count, handle->seek(), out_count); } - bool read_ready(Vfs_handle *) override { return true; } - + bool read_ready (Vfs_handle const &) const override { return true; } bool write_ready(Vfs_handle const &) const override { return true; } Ftruncate_result ftruncate(Vfs_handle * const vfs_handle, file_size len) override diff --git a/repos/os/src/lib/vfs/rom_file_system.h b/repos/os/src/lib/vfs/rom_file_system.h index 9c5f28f937..b3e720c351 100644 --- a/repos/os/src/lib/vfs/rom_file_system.h +++ b/repos/os/src/lib/vfs/rom_file_system.h @@ -112,8 +112,7 @@ class Vfs::Rom_file_system : public Single_file_system return WRITE_ERR_INVALID; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return false; } }; diff --git a/repos/os/src/lib/vfs/rtc_file_system.h b/repos/os/src/lib/vfs/rtc_file_system.h index 8de6ff66c2..f1aad5e915 100644 --- a/repos/os/src/lib/vfs/rtc_file_system.h +++ b/repos/os/src/lib/vfs/rtc_file_system.h @@ -81,8 +81,7 @@ class Vfs::Rtc_file_system : public Single_file_system return WRITE_ERR_IO; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return false; } }; diff --git a/repos/os/src/lib/vfs/symlink_file_system.h b/repos/os/src/lib/vfs/symlink_file_system.h index c42341344e..d6c0b8244e 100644 --- a/repos/os/src/lib/vfs/symlink_file_system.h +++ b/repos/os/src/lib/vfs/symlink_file_system.h @@ -53,8 +53,7 @@ class Vfs::Symlink_file_system : public Single_file_system file_size&) override { return WRITE_ERR_INVALID; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return false; } }; diff --git a/repos/os/src/lib/vfs/tap/nic_file_system.h b/repos/os/src/lib/vfs/tap/nic_file_system.h index aeea5f262e..3da29955ca 100644 --- a/repos/os/src/lib/vfs/tap/nic_file_system.h +++ b/repos/os/src/lib/vfs/tap/nic_file_system.h @@ -131,8 +131,13 @@ class Vfs::Nic_file_system::Nic_vfs_handle : public Single_vfs_handle * Vfs_handle interface * ************************/ - bool read_ready() override { - return _link_state && _nic.rx()->packet_avail() && _nic.rx()->ready_to_ack(); } + bool read_ready() const override + { + auto &nonconst_this = const_cast(*this); + auto &rx = *nonconst_this._nic.rx(); + + return _link_state && rx.packet_avail() && rx.ready_to_ack(); + } bool write_ready() const override { diff --git a/repos/os/src/lib/vfs/tap/uplink_file_system.h b/repos/os/src/lib/vfs/tap/uplink_file_system.h index 967a3ee01f..e921b8ff8a 100644 --- a/repos/os/src/lib/vfs/tap/uplink_file_system.h +++ b/repos/os/src/lib/vfs/tap/uplink_file_system.h @@ -121,8 +121,13 @@ class Vfs::Uplink_file_system::Uplink_vfs_handle : public Single_vfs_handle, * Vfs_handle interface * ************************/ - bool read_ready() override { - return _drv_link_state && _conn->rx()->packet_avail() && _conn->rx()->ready_to_ack(); } + bool read_ready() const override + { + auto &nonconst_this = const_cast(*this); + auto &rx = *nonconst_this._conn->rx(); + + return _drv_link_state && rx.packet_avail() && rx.ready_to_ack(); + } bool write_ready() const override { diff --git a/repos/os/src/lib/vfs/tar_file_system.h b/repos/os/src/lib/vfs/tar_file_system.h index ea6c64dcd3..054e2c8d55 100644 --- a/repos/os/src/lib/vfs/tar_file_system.h +++ b/repos/os/src/lib/vfs/tar_file_system.h @@ -775,8 +775,7 @@ class Vfs::Tar_file_system : public File_system return FTRUNCATE_ERR_NO_PERM; } - bool read_ready(Vfs_handle *) override { return true; } - + bool read_ready (Vfs_handle const &) const override { return true; } bool write_ready(Vfs_handle const &) const override { return false; } }; diff --git a/repos/os/src/lib/vfs/terminal_file_system.h b/repos/os/src/lib/vfs/terminal_file_system.h index 207c8e3893..bd08b2b72f 100644 --- a/repos/os/src/lib/vfs/terminal_file_system.h +++ b/repos/os/src/lib/vfs/terminal_file_system.h @@ -134,7 +134,7 @@ class Vfs::Terminal_file_system::Data_file_system : public Single_file_system _raw(raw) { } - bool read_ready() override { + bool read_ready() const override { return !_read_buffer.empty(); } bool write_ready() const override { return true; } diff --git a/repos/os/src/lib/vfs/zero_file_system.h b/repos/os/src/lib/vfs/zero_file_system.h index da85585320..78bc9de746 100644 --- a/repos/os/src/lib/vfs/zero_file_system.h +++ b/repos/os/src/lib/vfs/zero_file_system.h @@ -81,8 +81,7 @@ struct Vfs::Zero_file_system : Single_file_system return WRITE_OK; } - bool read_ready() override { return true; } - + bool read_ready() const override { return true; } bool write_ready() const override { return true; } }; diff --git a/repos/os/src/server/vfs/node.h b/repos/os/src/server/vfs/node.h index 62fb2be59f..5ccd38c5f9 100644 --- a/repos/os/src/server/vfs/node.h +++ b/repos/os/src/server/vfs/node.h @@ -351,7 +351,7 @@ class Vfs_server::Io_node : public Vfs_server::Node, { _read_ready_state = Read_ready_state::REQUESTED; - if (_handle.fs().read_ready(&_handle)) { + if (_handle.fs().read_ready(_handle)) { /* if the handle is ready, send a packet back immediately */ read_ready_response(); } else {