mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-20 06:07:59 +00:00
vfs: make 'File_io_service::read_ready' const
... and replace pointer argument to const reference. Issue #4706
This commit is contained in:
parent
1b1a9ca95c
commit
ca0d3757cc
@ -267,7 +267,7 @@ struct Vfs::Lxip_vfs_handle : Vfs::Vfs_handle
|
|||||||
/**
|
/**
|
||||||
* Check if the file attached to this handle is ready to read
|
* 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,
|
virtual Read_result read(char *dst,
|
||||||
file_size count, file_size &out_count) = 0;
|
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);
|
file->handles.remove(&file_le);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override {
|
bool read_ready() const override {
|
||||||
return (file) ? file->poll() : false; }
|
return (file) ? file->poll() : false; }
|
||||||
|
|
||||||
Read_result read(char *dst, file_size count, file_size &out_count) override
|
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),
|
: Vfs::Lxip_vfs_handle(fs, alloc, status_flags),
|
||||||
dir(dir) { }
|
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
|
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)
|
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
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready(Vfs_handle *vfs_handle) override
|
bool read_ready(Vfs_handle const &vfs_handle) const override
|
||||||
{
|
{
|
||||||
Lxip_vfs_handle &handle =
|
Lxip_vfs_handle const &handle =
|
||||||
*static_cast<Lxip_vfs_handle *>(vfs_handle);
|
static_cast<Lxip_vfs_handle const &>(vfs_handle);
|
||||||
|
|
||||||
return handle.read_ready();
|
return handle.read_ready();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,8 +807,7 @@ class Vfs::Rump_file_system : public File_system
|
|||||||
return READ_ERR_INVALID;
|
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; }
|
bool write_ready(Vfs_handle const &) const override { return true; }
|
||||||
|
|
||||||
Ftruncate_result ftruncate(Vfs_handle *vfs_handle, file_size len) override
|
Ftruncate_result ftruncate(Vfs_handle *vfs_handle, file_size len) override
|
||||||
|
@ -268,16 +268,21 @@ class Vfs_audit::File_system : public Vfs::File_system
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready(Vfs_handle *vfs_handle) override
|
bool read_ready(Vfs_handle const &vfs_handle) const override
|
||||||
{
|
{
|
||||||
Handle &h = *static_cast<Handle*>(vfs_handle);
|
Handle const &h = static_cast<Handle const &>(vfs_handle);
|
||||||
h.sync_state();
|
|
||||||
return h.audit->fs().read_ready(h.audit);
|
const_cast<Handle &>(h).sync_state();
|
||||||
|
|
||||||
|
return h.audit->fs().read_ready(*h.audit);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool write_ready(Vfs_handle const &vfs_handle) const override
|
bool write_ready(Vfs_handle const &vfs_handle) const override
|
||||||
{
|
{
|
||||||
Handle const &h = static_cast<Handle const &>(vfs_handle);
|
Handle const &h = static_cast<Handle const &>(vfs_handle);
|
||||||
|
|
||||||
|
const_cast<Handle &>(h).sync_state();
|
||||||
|
|
||||||
return h.audit->fs().write_ready(*h.audit);
|
return h.audit->fs().write_ready(*h.audit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2020,8 +2020,7 @@ class Vfs_cbe::Data_file_system : public Single_file_system
|
|||||||
return SYNC_ERR_INVALID;
|
return SYNC_ERR_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_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;
|
return WRITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_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;
|
return WRITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_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;
|
return WRITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_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;
|
return WRITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_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;
|
return WRITE_ERR_IO;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_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;
|
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;
|
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
|
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;
|
return READ_ERR_IO;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready(Vfs::Vfs_handle *) override
|
bool read_ready(Vfs::Vfs_handle const &) const override
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -123,8 +123,7 @@ class Vfs_cbe_crypto::Encrypt_file_system : public Vfs::Single_file_system
|
|||||||
return WRITE_OK;
|
return WRITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_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;
|
return WRITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_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;
|
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;
|
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;
|
return READ_ERR_IO;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready(Vfs::Vfs_handle *) override
|
bool read_ready(Vfs::Vfs_handle const &) const override
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1006,8 +1004,7 @@ class Vfs_cbe_crypto::Management_file_system : public Vfs::Single_file_system
|
|||||||
return WRITE_ERR_IO;
|
return WRITE_ERR_IO;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_ready() const override { return true; }
|
bool write_ready() const override { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1369,8 +1369,7 @@ class Vfs_cbe_trust_anchor::Hashsum_file_system : public Vfs::Single_file_system
|
|||||||
return WRITE_OK;
|
return WRITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_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;
|
return WRITE_ERR_IO;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_ready() const override { return false; }
|
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;
|
return WRITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_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;
|
return WRITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_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;
|
return WRITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_ready() const override { return true; }
|
bool write_ready() const override { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -79,8 +79,7 @@ struct Vfs_gpu::File_system : Single_file_system
|
|||||||
return WRITE_ERR_IO;
|
return WRITE_ERR_IO;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return _complete; }
|
bool read_ready() const override { return _complete; }
|
||||||
|
|
||||||
bool write_ready() const override { return true; }
|
bool write_ready() const override { return true; }
|
||||||
|
|
||||||
Id_space::Id id() const { return _elem.id(); }
|
Id_space::Id id() const { return _elem.id(); }
|
||||||
|
@ -284,7 +284,7 @@ class Vfs_import::File_system : public Vfs::File_system
|
|||||||
file_size&) override {
|
file_size&) override {
|
||||||
return READ_ERR_INVALID; }
|
return READ_ERR_INVALID; }
|
||||||
|
|
||||||
bool read_ready(Vfs_handle*) override {
|
bool read_ready(Vfs_handle const &) const override {
|
||||||
return true; }
|
return true; }
|
||||||
|
|
||||||
bool write_ready(Vfs_handle const &) const override {
|
bool write_ready(Vfs_handle const &) const override {
|
||||||
|
@ -76,7 +76,7 @@ struct Vfs_pipe::Pipe_handle : Vfs::Vfs_handle, private Pipe_handle_registry_ele
|
|||||||
file_size count,
|
file_size count,
|
||||||
file_size &out_count);
|
file_size &out_count);
|
||||||
|
|
||||||
bool read_ready();
|
bool read_ready() const;
|
||||||
bool write_ready() const;
|
bool write_ready() const;
|
||||||
bool notify_read_ready();
|
bool notify_read_ready();
|
||||||
};
|
};
|
||||||
@ -275,14 +275,16 @@ Vfs_pipe::Pipe_handle::write(const char *buf,
|
|||||||
|
|
||||||
|
|
||||||
Vfs_pipe::Read_result
|
Vfs_pipe::Read_result
|
||||||
Vfs_pipe::Pipe_handle::read(char *buf,
|
Vfs_pipe::Pipe_handle::read(char *buf, file_size count, file_size &out_count)
|
||||||
file_size count,
|
{
|
||||||
file_size &out_count) {
|
return Pipe_handle::pipe.read(*this, buf, count, out_count);
|
||||||
return Pipe_handle::pipe.read(*this, buf, count, out_count); }
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Vfs_pipe::Pipe_handle::read_ready() {
|
bool Vfs_pipe::Pipe_handle::read_ready() const
|
||||||
return !writer && !pipe.buffer.empty(); }
|
{
|
||||||
|
return !writer && !pipe.buffer.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Vfs_pipe::Pipe_handle::write_ready() const
|
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;
|
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<Pipe_handle*>(vfs_handle))
|
if (Pipe_handle const *handle = dynamic_cast<Pipe_handle const *>(&vfs_handle))
|
||||||
return handle->read_ready();
|
return handle->read_ready();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -147,8 +147,7 @@ class Vfs_trace::Trace_buffer_file_system : public Single_file_system
|
|||||||
return WRITE_ERR_INVALID;
|
return WRITE_ERR_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_ready() const override { return false; }
|
bool write_ready() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -106,8 +106,7 @@ class Vfs::Glyphs_file_system : public Vfs::Single_file_system
|
|||||||
return WRITE_ERR_IO;
|
return WRITE_ERR_IO;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_ready() const override { return false; }
|
bool write_ready() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ namespace Libc {
|
|||||||
|
|
||||||
handle->fs().notify_read_ready(handle);
|
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)
|
bool write_ready_from_kernel(File_descriptor *fd)
|
||||||
@ -2721,7 +2721,7 @@ int Libc::Vfs_plugin::select(int nfds,
|
|||||||
if (!handle) continue;
|
if (!handle) continue;
|
||||||
|
|
||||||
if (fd_in_readfds) {
|
if (fd_in_readfds) {
|
||||||
if (handle->fs().read_ready(handle)) {
|
if (handle->fs().read_ready(*handle)) {
|
||||||
FD_SET(fd, readfds);
|
FD_SET(fd, readfds);
|
||||||
++nready;
|
++nready;
|
||||||
} else {
|
} else {
|
||||||
|
@ -777,7 +777,7 @@ class Fatfs::File_system : public Vfs::File_system
|
|||||||
FTRUNCATE_OK : FTRUNCATE_ERR_NO_PERM;
|
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
|
bool write_ready(Vfs_handle const &) const override
|
||||||
{
|
{
|
||||||
|
@ -94,8 +94,7 @@ class Jitterentropy_file_system : public Vfs::Single_file_system
|
|||||||
return WRITE_ERR_IO;
|
return WRITE_ERR_IO;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_ready() const override { return false; }
|
bool write_ready() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -77,9 +77,10 @@ class Libusb_file_system : public Vfs::Single_file_system
|
|||||||
libusb_genode_usb_connection(&_usb_connection);
|
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<Libusb_vfs_handle &>(*this);
|
||||||
|
return nonconst_this._usb_connection.source()->ack_avail();
|
||||||
}
|
}
|
||||||
|
|
||||||
Read_result read(char *dst, Vfs::file_size count,
|
Read_result read(char *dst, Vfs::file_size count,
|
||||||
|
@ -426,8 +426,7 @@ struct Lwip::Socket_dir : Lwip::Directory
|
|||||||
char const *src, file_size count,
|
char const *src, file_size count,
|
||||||
file_size &out_count) = 0;
|
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;
|
virtual bool write_ready(Lwip_file_handle const &) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -891,7 +890,7 @@ class Lwip::Udp_socket_dir final :
|
|||||||
** Socket_dir interface **
|
** Socket_dir interface **
|
||||||
**************************/
|
**************************/
|
||||||
|
|
||||||
bool read_ready(Lwip_file_handle &handle) override
|
bool read_ready(Lwip_file_handle const &handle) const override
|
||||||
{
|
{
|
||||||
switch (handle.kind) {
|
switch (handle.kind) {
|
||||||
case Lwip_file_handle::DATA:
|
case Lwip_file_handle::DATA:
|
||||||
@ -1254,7 +1253,7 @@ class Lwip::Tcp_socket_dir final :
|
|||||||
** Socket_dir interface **
|
** Socket_dir interface **
|
||||||
**************************/
|
**************************/
|
||||||
|
|
||||||
bool read_ready(Lwip_file_handle &handle) override
|
bool read_ready(Lwip_file_handle const &handle) const override
|
||||||
{
|
{
|
||||||
switch (handle.kind) {
|
switch (handle.kind) {
|
||||||
case Lwip_file_handle::DATA:
|
case Lwip_file_handle::DATA:
|
||||||
@ -2111,12 +2110,13 @@ class Lwip::File_system final : public Vfs::File_system, public Lwip::Directory,
|
|||||||
return false;
|
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<Lwip_file_handle*>(vfs_handle)) {
|
Lwip_file_handle const * const handle_ptr =
|
||||||
if (handle->socket)
|
dynamic_cast<Lwip_file_handle const *>(&vfs_handle);
|
||||||
return handle->socket->read_ready(*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'
|
* in this case the polled file is a 'new_socket'
|
||||||
|
@ -285,7 +285,7 @@ struct Vfs::Oss_file_system::Audio
|
|||||||
_in->overrun_sigh(sigh);
|
_in->overrun_sigh(sigh);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready()
|
bool read_ready() const
|
||||||
{
|
{
|
||||||
return _info.ifrag_bytes > 0;
|
return _info.ifrag_bytes > 0;
|
||||||
}
|
}
|
||||||
@ -681,7 +681,7 @@ class Vfs::Oss_file_system::Data_file_system : public Single_file_system
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override
|
bool read_ready() const override
|
||||||
{
|
{
|
||||||
return _audio.read_ready();
|
return _audio.read_ready();
|
||||||
}
|
}
|
||||||
|
@ -965,12 +965,12 @@ class Vfs::Dir_file_system : public File_system
|
|||||||
return FTRUNCATE_ERR_NO_PERM;
|
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 true;
|
||||||
|
|
||||||
return handle->fs().read_ready(handle);
|
return handle.fs().read_ready(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool write_ready(Vfs_handle const &handle) const override
|
bool write_ready(Vfs_handle const &handle) const override
|
||||||
|
@ -67,7 +67,7 @@ struct Vfs::File_io_service : Interface
|
|||||||
/**
|
/**
|
||||||
* Return true if the handle has readable data
|
* 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
|
* Return true if the handle might accept a write operation
|
||||||
|
@ -72,8 +72,7 @@ class Vfs::Readonly_value_file_system : public Vfs::Single_file_system
|
|||||||
return WRITE_ERR_IO;
|
return WRITE_ERR_IO;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_ready() const override { return false; }
|
bool write_ready() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ class Vfs::Single_file_system : public File_system
|
|||||||
return SYNC_OK;
|
return SYNC_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool read_ready() = 0;
|
virtual bool read_ready() const = 0;
|
||||||
|
|
||||||
virtual bool write_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;
|
return WRITE_ERR_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_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;
|
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 =
|
Single_vfs_handle const &handle =
|
||||||
static_cast<Single_vfs_handle*>(vfs_handle);
|
static_cast<Single_vfs_handle const &>(vfs_handle);
|
||||||
|
|
||||||
if (handle)
|
return handle.read_ready();
|
||||||
return handle->read_ready();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool write_ready(Vfs_handle const &vfs_handle) const override
|
bool write_ready(Vfs_handle const &vfs_handle) const override
|
||||||
|
@ -84,8 +84,7 @@ class Vfs::Value_file_system : public Vfs::Single_file_system
|
|||||||
return WRITE_OK;
|
return WRITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_ready() const override { return true; }
|
bool write_ready() const override { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -337,8 +337,7 @@ class Vfs::Block_file_system::Data_file_system : public Single_file_system
|
|||||||
return SYNC_OK;
|
return SYNC_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_ready() const override { return true; }
|
bool write_ready() const override { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -67,8 +67,7 @@ class Vfs_capture::Data_file_system : public Single_file_system
|
|||||||
_capture(capture), _capture_ds(capture_ds)
|
_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; }
|
bool write_ready() const override { return true; }
|
||||||
|
|
||||||
Read_result read(char *dst, file_size count,
|
Read_result read(char *dst, file_size count,
|
||||||
|
@ -953,11 +953,11 @@ class Vfs::Fs_file_system : public File_system, private Remote_io
|
|||||||
return result;
|
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<Fs_vfs_handle *>(vfs_handle);
|
Fs_vfs_handle const &handle = static_cast<Fs_vfs_handle const &>(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
|
bool write_ready(Vfs_handle const &) const override
|
||||||
|
@ -89,8 +89,7 @@ class Vfs::Inline_file_system : public Single_file_system
|
|||||||
return WRITE_ERR_INVALID;
|
return WRITE_ERR_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_ready() const override { return false; }
|
bool write_ready() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -126,8 +126,7 @@ class Vfs::Log_file_system : public Single_file_system
|
|||||||
return WRITE_OK;
|
return WRITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return false; }
|
bool read_ready() const override { return false; }
|
||||||
|
|
||||||
bool write_ready() const override { return true; }
|
bool write_ready() const override { return true; }
|
||||||
|
|
||||||
Sync_result sync() override
|
Sync_result sync() override
|
||||||
|
@ -53,8 +53,7 @@ struct Vfs::Null_file_system : Single_file_system
|
|||||||
return WRITE_OK;
|
return WRITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return false; }
|
bool read_ready() const override { return false; }
|
||||||
|
|
||||||
bool write_ready() const override { return true; }
|
bool write_ready() const override { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -966,8 +966,7 @@ class Vfs::Ram_file_system : public Vfs::File_system
|
|||||||
return handle->node.complete_read(dst, count, handle->seek(), out_count);
|
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; }
|
bool write_ready(Vfs_handle const &) const override { return true; }
|
||||||
|
|
||||||
Ftruncate_result ftruncate(Vfs_handle * const vfs_handle, file_size len) override
|
Ftruncate_result ftruncate(Vfs_handle * const vfs_handle, file_size len) override
|
||||||
|
@ -112,8 +112,7 @@ class Vfs::Rom_file_system : public Single_file_system
|
|||||||
return WRITE_ERR_INVALID;
|
return WRITE_ERR_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_ready() const override { return false; }
|
bool write_ready() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -81,8 +81,7 @@ class Vfs::Rtc_file_system : public Single_file_system
|
|||||||
return WRITE_ERR_IO;
|
return WRITE_ERR_IO;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_ready() const override { return false; }
|
bool write_ready() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -53,8 +53,7 @@ class Vfs::Symlink_file_system : public Single_file_system
|
|||||||
file_size&) override {
|
file_size&) override {
|
||||||
return WRITE_ERR_INVALID; }
|
return WRITE_ERR_INVALID; }
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_ready() const override { return false; }
|
bool write_ready() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -131,8 +131,13 @@ class Vfs::Nic_file_system::Nic_vfs_handle : public Single_vfs_handle
|
|||||||
* Vfs_handle interface *
|
* Vfs_handle interface *
|
||||||
************************/
|
************************/
|
||||||
|
|
||||||
bool read_ready() override {
|
bool read_ready() const override
|
||||||
return _link_state && _nic.rx()->packet_avail() && _nic.rx()->ready_to_ack(); }
|
{
|
||||||
|
auto &nonconst_this = const_cast<Nic_vfs_handle &>(*this);
|
||||||
|
auto &rx = *nonconst_this._nic.rx();
|
||||||
|
|
||||||
|
return _link_state && rx.packet_avail() && rx.ready_to_ack();
|
||||||
|
}
|
||||||
|
|
||||||
bool write_ready() const override
|
bool write_ready() const override
|
||||||
{
|
{
|
||||||
|
@ -121,8 +121,13 @@ class Vfs::Uplink_file_system::Uplink_vfs_handle : public Single_vfs_handle,
|
|||||||
* Vfs_handle interface *
|
* Vfs_handle interface *
|
||||||
************************/
|
************************/
|
||||||
|
|
||||||
bool read_ready() override {
|
bool read_ready() const override
|
||||||
return _drv_link_state && _conn->rx()->packet_avail() && _conn->rx()->ready_to_ack(); }
|
{
|
||||||
|
auto &nonconst_this = const_cast<Uplink_vfs_handle &>(*this);
|
||||||
|
auto &rx = *nonconst_this._conn->rx();
|
||||||
|
|
||||||
|
return _drv_link_state && rx.packet_avail() && rx.ready_to_ack();
|
||||||
|
}
|
||||||
|
|
||||||
bool write_ready() const override
|
bool write_ready() const override
|
||||||
{
|
{
|
||||||
|
@ -775,8 +775,7 @@ class Vfs::Tar_file_system : public File_system
|
|||||||
return FTRUNCATE_ERR_NO_PERM;
|
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; }
|
bool write_ready(Vfs_handle const &) const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ class Vfs::Terminal_file_system::Data_file_system : public Single_file_system
|
|||||||
_raw(raw)
|
_raw(raw)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
bool read_ready() override {
|
bool read_ready() const override {
|
||||||
return !_read_buffer.empty(); }
|
return !_read_buffer.empty(); }
|
||||||
|
|
||||||
bool write_ready() const override { return true; }
|
bool write_ready() const override { return true; }
|
||||||
|
@ -81,8 +81,7 @@ struct Vfs::Zero_file_system : Single_file_system
|
|||||||
return WRITE_OK;
|
return WRITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_ready() override { return true; }
|
bool read_ready() const override { return true; }
|
||||||
|
|
||||||
bool write_ready() const override { return true; }
|
bool write_ready() const override { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ class Vfs_server::Io_node : public Vfs_server::Node,
|
|||||||
{
|
{
|
||||||
_read_ready_state = Read_ready_state::REQUESTED;
|
_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 */
|
/* if the handle is ready, send a packet back immediately */
|
||||||
read_ready_response();
|
read_ready_response();
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user