L4Re Operating System Framework – Interface and Usage Documentation
Loading...
Searching...
No Matches
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 * This file is part of TUD:OS and distributed under the terms of the
7 * GNU General Public License 2.
8 * Please see the COPYING-GPL-2 file for details.
9 *
10 * As a special exception, you may use this file as part of a free software
11 * library without restriction. Specifically, if other files instantiate
12 * templates or use macros or inline functions from this file, or you compile
13 * this file and link it with other files to produce an executable, this
14 * file does not by itself cause the resulting executable to be covered by
15 * the GNU General Public License. This exception does not however
16 * invalidate any other reasons why the executable file might be covered by
17 * the GNU General Public License.
18 */
19#pragma once
20
21#include <l4/l4re_vfs/backend>
22#include <l4/sys/capability>
23#include <l4/re/namespace>
24#include <l4/re/unique_cap>
25
26namespace L4Re { namespace Core {
27
28using cxx::Ref_ptr;
29
30class Env_dir : public L4Re::Vfs::Be_file
31{
32public:
33 explicit Env_dir(L4Re::Env const *env)
34 : _env(env), _current_cap_entry(env->initial_caps())
35 {}
36
37 ssize_t readv(const struct iovec*, int) noexcept override { return -EISDIR; }
38 ssize_t writev(const struct iovec*, int) noexcept override { return -EISDIR; }
39 ssize_t preadv(const struct iovec*, int, off64_t) noexcept override { return -EISDIR; }
40 ssize_t pwritev(const struct iovec*, int, off64_t) noexcept override { return -EISDIR; }
41 int fstat64(struct stat64 *) const noexcept override;
42 int faccessat(const char *path, int mode, int flags) noexcept override;
43 int get_entry(const char *path, int flags, mode_t mode,
44 Ref_ptr<L4Re::Vfs::File> *) noexcept override;
45 ssize_t getdents(char *, size_t) noexcept override;
46
47 ~Env_dir() noexcept {}
48
49private:
50 int get_ds(const char *path, L4Re::Unique_cap<L4Re::Dataspace> *ds) noexcept;
51 bool check_type(Env::Cap_entry const *e, long protocol) noexcept;
52
53 L4Re::Env const *_env;
54 Env::Cap_entry const *_current_cap_entry;
55};
56
57class Ns_dir : public L4Re::Vfs::Be_file
58{
59public:
60 explicit Ns_dir(L4::Cap<L4Re::Namespace> ns)
61 : _ns(ns), _current_dir_pos(0)
62 {}
63
64 ssize_t readv(const struct iovec*, int) noexcept override { return -EISDIR; }
65 ssize_t writev(const struct iovec*, int) noexcept override { return -EISDIR; }
66 ssize_t preadv(const struct iovec*, int, off64_t) noexcept override { return -EISDIR; }
67 ssize_t pwritev(const struct iovec*, int, off64_t) noexcept override { return -EISDIR; }
68 int fstat64(struct stat64 *) const noexcept override;
69 int faccessat(const char *path, int mode, int flags) noexcept override;
70 int get_entry(const char *path, int flags, mode_t mode,
71 Ref_ptr<L4Re::Vfs::File> *) noexcept override;
72 ssize_t getdents(char *, size_t) noexcept override;
73
74 ~Ns_dir() noexcept {}
75
76private:
77 int get_ds(const char *path, L4Re::Unique_cap<L4Re::Dataspace> *ds) noexcept;
78
80 size_t _current_dir_pos;
81};
82
83}}
L4::Cap related definitions.
C++ interface of the initial environment that is provided to an L4 task.
Definition env:86
l4re_env_cap_entry_t Cap_entry
C++ type for an entry in the initial objects array.
Definition env:94
Boiler plate class for implementing an open file for L4Re::Vfs.
Definition backend:40
C++ interface for capabilities.
Definition capability.h:222
A reference-counting pointer with automatic cleanup.
Definition ref_ptr:82
L4Re C++ Interfaces.
Definition cmd_control:15
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:42
Namespace interface.
Unique_cap / Unique_del_cap.