L4Re Operating System Framework
Interface and Usage Documentation
•All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ns_fs.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#include <l4/sys/capability>
12#include <l4/re/namespace>
13#include <l4/re/unique_cap>
14
15namespace L4Re { namespace Core {
16
17using cxx::Ref_ptr;
18
19class Env_dir : public L4Re::Vfs::Be_file
20{
21public:
22 explicit Env_dir(L4Re::Env const *env)
23 : _env(env), _current_cap_entry(env->initial_caps())
24 {}
25
26 ssize_t readv(const struct iovec*, int) noexcept override { return -EISDIR; }
27 ssize_t writev(const struct iovec*, int) noexcept override { return -EISDIR; }
28 ssize_t preadv(const struct iovec*, int, off64_t) noexcept override { return -EISDIR; }
29 ssize_t pwritev(const struct iovec*, int, off64_t) noexcept override { return -EISDIR; }
30 int fstat64(struct stat64 *) const noexcept override;
31 int faccessat(const char *path, int mode, int flags) noexcept override;
32 int get_entry(const char *path, int flags, mode_t mode,
33 Ref_ptr<L4Re::Vfs::File> *) noexcept override;
34 ssize_t getdents(char *, size_t) noexcept override;
35
36 ~Env_dir() noexcept {}
37
38private:
39 int get_ds(const char *path, L4Re::Unique_cap<L4Re::Dataspace> *ds) noexcept;
40 bool check_type(Env::Cap_entry const *e, long protocol) noexcept;
41
42 L4Re::Env const *_env;
43 Env::Cap_entry const *_current_cap_entry;
44};
45
46class Ns_dir : public L4Re::Vfs::Be_file
47{
48public:
49 explicit Ns_dir(L4::Cap<L4Re::Namespace> ns)
50 : _ns(ns), _current_dir_pos(0)
51 {}
52
53 ssize_t readv(const struct iovec*, int) noexcept override { return -EISDIR; }
54 ssize_t writev(const struct iovec*, int) noexcept override { return -EISDIR; }
55 ssize_t preadv(const struct iovec*, int, off64_t) noexcept override { return -EISDIR; }
56 ssize_t pwritev(const struct iovec*, int, off64_t) noexcept override { return -EISDIR; }
57 int fstat64(struct stat64 *) const noexcept override;
58 int faccessat(const char *path, int mode, int flags) noexcept override;
59 int get_entry(const char *path, int flags, mode_t mode,
60 Ref_ptr<L4Re::Vfs::File> *) noexcept override;
61 ssize_t getdents(char *, size_t) noexcept override;
62
63 ~Ns_dir() noexcept {}
64
65private:
66 int get_ds(const char *path, L4Re::Unique_cap<L4Re::Dataspace> *ds) noexcept;
67
69 size_t _current_dir_pos;
70};
71
72}}
L4::Cap related definitions.
C++ interface of the initial environment that is provided to an L4 task.
Definition env:78
l4re_env_cap_entry_t Cap_entry
C++ type for an entry in the initial objects array.
Definition env:86
Boiler plate class for implementing an open file for L4Re::Vfs.
Definition backend:29
C++ interface for capabilities.
Definition capability.h:219
A reference-counting pointer with automatic cleanup.
Definition ref_ptr:71
L4Re C++ Interfaces.
Definition cmd_control:14
L4::Detail::Unique_cap_impl< T, Smart_cap_auto< L4_FP_ALL_SPACES > > Unique_cap
Unique capability that implements automatic free and unmap of the capability selector.
Definition unique_cap:31
Namespace interface.
Unique_cap / Unique_del_cap.