L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
ds_file.h
1/*
2 * (c) 2010 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
3 * Alexander Warg <warg@os.inf.tu-dresden.de>
4 * economic rights: Technische Universität Dresden (Germany)
5 *
6 * License: see LICENSE.spdx (in this directory or the directories above)
7 */
8#pragma once
9
10#include <l4/l4re_vfs/backend>
11
12namespace L4Re { namespace Core {
13
17class Ds_file : public L4Re::Vfs::Be_file_pos
18{
19private:
21 off64_t _size;
22 char *_addr;
23
24 bool _writable; // Is this file writable?
25
26public:
27 explicit Ds_file(L4::Cap<L4Re::Dataspace> ds) noexcept
28 : Be_file_pos(), _ds(ds), _addr(0)
29 {
30 L4Re::Dataspace::Stats ds_stats{}; // Properties of backing dataspace
31
32 // Use a single IPC to query backing dataspace for size and permissions
33 _ds->info(&ds_stats);
34 _size = ds_stats.size;
35
36 // w() returns true if flags has the write permission bit set
37 _writable = ds_stats.flags.w();
38 }
39
40 L4::Cap<L4Re::Dataspace> data_space() noexcept override { return _ds; }
41
42 int fstat(struct stat64 *buf) const noexcept override;
43
44 int ioctl(unsigned long, va_list) noexcept override;
45
46 off64_t size() const noexcept override { return _size; }
47
48 int get_status_flags() const noexcept override
49 { return O_RDONLY; }
50
51 int set_status_flags(long) noexcept override
52 { return 0; }
53
65 bool check_ready(Ready_type rt) noexcept override
66 {
67 if (rt == Read)
68 return true;
69
70 if (rt == Write)
71 return _writable;
72
73 return false;
74 }
75
76 ~Ds_file() noexcept;
77
78private:
79 ssize_t read_single(const struct iovec*, off64_t) noexcept;
80 ssize_t preadv(const struct iovec *, int, off64_t) noexcept override;
81 ssize_t write_single(const struct iovec*, off64_t) noexcept;
82 ssize_t pwritev(const struct iovec *, int , off64_t) noexcept override;
83};
84
85
86}}
Implementation for files backed by an L4Re::Dataspace abstraction.
Definition ds_file.h:18
int fstat(struct stat64 *buf) const noexcept override
Get status information for the file.
int ioctl(unsigned long, va_list) noexcept override
The famous IO control.
L4::Cap< L4Re::Dataspace > data_space() noexcept override
Get an L4Re::Dataspace object for the file.
Definition ds_file.h:40
int set_status_flags(long) noexcept override
Set file status flags (fcntl F_SETFL).
Definition ds_file.h:51
int get_status_flags() const noexcept override
Get file status flags (fcntl F_GETFL).
Definition ds_file.h:48
bool check_ready(Ready_type rt) noexcept override
Check whether the file is ready for an I/O operation/condition.
Definition ds_file.h:65
Ready_type
Type of I/O operation/condition a file can indicate readiness.
Definition vfs.h:61
C++ interface for capabilities.
Definition capability.h:249
L4Re C++ Interfaces.
Definition cmd_control:14
Information about the dataspace.
Definition dataspace:129