mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-22 00:41:55 +00:00
committed by
Christian Helmuth
parent
289cfa5fcf
commit
8b8c2713ae
@ -27,7 +27,7 @@ class Vfs::Inline_file_system : public Single_file_system
|
||||
private:
|
||||
|
||||
char const * const _base;
|
||||
size_t const _size;
|
||||
file_size const _size;
|
||||
|
||||
public:
|
||||
|
||||
@ -57,23 +57,24 @@ class Vfs::Inline_file_system : public Single_file_system
|
||||
** File I/O service interface **
|
||||
********************************/
|
||||
|
||||
Write_result write(Vfs_handle *, char const *, size_t, size_t &count_out) override
|
||||
Write_result write(Vfs_handle *, char const *, file_size,
|
||||
file_size &count_out) override
|
||||
{
|
||||
count_out = 0;
|
||||
return WRITE_ERR_INVALID;
|
||||
}
|
||||
|
||||
Read_result read(Vfs_handle *vfs_handle, char *dst, size_t count,
|
||||
size_t &out_count) override
|
||||
Read_result read(Vfs_handle *vfs_handle, char *dst, file_size count,
|
||||
file_size &out_count) override
|
||||
{
|
||||
/* file read limit is the size of the dataspace */
|
||||
size_t const max_size = _size;
|
||||
file_size const max_size = _size;
|
||||
|
||||
/* current read offset */
|
||||
size_t const read_offset = vfs_handle->seek();
|
||||
file_size const read_offset = vfs_handle->seek();
|
||||
|
||||
/* maximum read offset, clamped to dataspace size */
|
||||
size_t const end_offset = min(count + read_offset, max_size);
|
||||
file_size const end_offset = min(count + read_offset, max_size);
|
||||
|
||||
/* source address within the dataspace */
|
||||
char const *src = _base + read_offset;
|
||||
@ -85,7 +86,7 @@ class Vfs::Inline_file_system : public Single_file_system
|
||||
}
|
||||
|
||||
/* copy-out bytes from ROM dataspace */
|
||||
size_t const num_bytes = end_offset - read_offset;
|
||||
file_size const num_bytes = end_offset - read_offset;
|
||||
|
||||
memcpy(dst, src, num_bytes);
|
||||
|
||||
|
Reference in New Issue
Block a user