]> 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 Technische Universität Dresden
3  * This file is part of TUD:OS and distributed under the terms of the
4  * GNU General Public License 2.
5  * Please see the COPYING-GPL-2 file for details.
6  *
7  * As a special exception, you may use this file as part of a free software
8  * library without restriction.  Specifically, if other files instantiate
9  * templates or use macros or inline functions from this file, or you compile
10  * this file and link it with other files to produce an executable, this
11  * file does not by itself cause the resulting executable to be covered by
12  * the GNU General Public License.  This exception does not however
13  * invalidate any other reasons why the executable file might be covered by
14  * the GNU General Public License.
15  */
16 #pragma once
17
18 #include <l4/l4re_vfs/backend>
19 #include <l4/sys/capability>
20 #include <l4/re/namespace>
21 #include "simple_store.h"
22
23 namespace L4Re { namespace Core {
24
25 using cxx::Ref_ptr;
26
27 class Ns_base_dir : public L4Re::Vfs::Be_file
28 {
29 public:
30   enum { Size = sizeof(L4Re::Vfs::Be_file) + sizeof(l4_addr_t) };
31
32   void *operator new(size_t s) throw();
33   void operator delete(void *b) throw();
34
35 protected:
36   static Simple_store_sz<Size> store;
37 };
38
39 class Env_dir : public Ns_base_dir
40 {
41 public:
42   explicit Env_dir(L4Re::Env const *env)
43   : _env(env), _current_cap_entry(env->initial_caps()) {}
44
45   ssize_t readv(const struct iovec*, int) throw() { return -EISDIR; }
46   ssize_t writev(const struct iovec*, int) throw() { return -EISDIR; }
47   int fstat64(struct stat64 *) const throw();
48   int faccessat(const char *path, int mode, int flags) throw();
49   int get_entry(const char *path, int flags, mode_t mode,
50                 Ref_ptr<L4Re::Vfs::File> *) throw();
51   ssize_t getdents(char *, size_t) throw();
52
53   ~Env_dir() throw() {}
54
55
56 private:
57   int get_ds(const char *path, L4Re::Auto_cap<L4Re::Dataspace>::Cap *ds) throw();
58
59   L4Re::Env const *_env;
60   Env::Cap_entry const *_current_cap_entry;
61 };
62
63 class Ns_dir : public Ns_base_dir
64 {
65 public:
66   explicit Ns_dir(L4::Cap<L4Re::Namespace> ns) : _ns(ns) {}
67
68   ssize_t readv(const struct iovec*, int) throw() { return -EISDIR; }
69   ssize_t writev(const struct iovec*, int) throw() { return -EISDIR; }
70   int fstat64(struct stat64 *) const throw();
71   int faccessat(const char *path, int mode, int flags) throw();
72   int get_entry(const char *path, int flags, mode_t mode,
73                 Ref_ptr<L4Re::Vfs::File> *) throw();
74
75   ~Ns_dir() throw() {}
76
77 private:
78   int get_ds(const char *path, L4Re::Auto_cap<L4Re::Dataspace>::Cap *ds) throw();
79
80   L4::Cap<L4Re::Namespace> _ns;
81
82 };
83
84 }}