]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re_vfs/include/impl/ns_fs.h
update
[l4.git] / l4 / pkg / l4re_vfs / include / impl / 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 "simple_store.h"
25
26 namespace L4Re { namespace Core {
27
28 using cxx::Ref_ptr;
29
30 class Ns_base_dir : public L4Re::Vfs::Be_file
31 {
32 public:
33   enum { Size = sizeof(L4Re::Vfs::Be_file) + 2 * sizeof(l4_addr_t) };
34
35   void *operator new(size_t s) throw();
36   void operator delete(void *b) throw();
37
38 protected:
39   static Simple_store_sz<Size> store;
40 };
41
42 class Env_dir : public Ns_base_dir
43 {
44 public:
45   explicit Env_dir(L4Re::Env const *env)
46   : _env(env), _current_cap_entry(env->initial_caps())
47   { static_assert(Ns_base_dir::Size >= sizeof(*this), "Size too small"); }
48
49   ssize_t readv(const struct iovec*, int) throw() { return -EISDIR; }
50   ssize_t writev(const struct iovec*, int) throw() { return -EISDIR; }
51   int fstat64(struct stat64 *) const throw();
52   int faccessat(const char *path, int mode, int flags) throw();
53   int get_entry(const char *path, int flags, mode_t mode,
54                 Ref_ptr<L4Re::Vfs::File> *) throw();
55   ssize_t getdents(char *, size_t) throw();
56
57   ~Env_dir() throw() {}
58
59
60 private:
61   int get_ds(const char *path, L4Re::Auto_cap<L4Re::Dataspace>::Cap *ds) throw();
62
63   L4Re::Env const *_env;
64   Env::Cap_entry const *_current_cap_entry;
65 };
66
67 class Ns_dir : public Ns_base_dir
68 {
69 public:
70   explicit Ns_dir(L4::Cap<L4Re::Namespace> ns)
71   : _ns(ns), _current_dir_pos(0)
72   { static_assert(Ns_base_dir::Size >= sizeof(*this), "Size too small"); }
73
74   ssize_t readv(const struct iovec*, int) throw() { return -EISDIR; }
75   ssize_t writev(const struct iovec*, int) throw() { return -EISDIR; }
76   int fstat64(struct stat64 *) const throw();
77   int faccessat(const char *path, int mode, int flags) throw();
78   int get_entry(const char *path, int flags, mode_t mode,
79                 Ref_ptr<L4Re::Vfs::File> *) throw();
80   ssize_t getdents(char *, size_t) throw();
81
82   ~Ns_dir() throw() {}
83
84 private:
85   int get_ds(const char *path, L4Re::Auto_cap<L4Re::Dataspace>::Cap *ds) throw();
86
87   L4::Cap<L4Re::Namespace> _ns;
88   size_t _current_dir_pos;
89 };
90
91 }}