]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re_vfs/include/impl/ns_fs.h
0f6d9e9355d3072855f05a44490409efdf84ce1a
[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) : _env(env) {}
43
44   ssize_t readv(const struct iovec*, int) throw() { return -EISDIR; }
45   ssize_t writev(const struct iovec*, int) throw() { return -EISDIR; }
46   int fstat64(struct stat64 *) const throw() { return -EINVAL; }
47   int faccessat(const char *path, int mode, int flags) throw();
48   int get_entry(const char *path, int flags, mode_t mode,
49                 Ref_ptr<L4Re::Vfs::File> *) throw();
50
51   ~Env_dir() throw() {}
52
53
54 private:
55   int get_ds(const char *path, L4Re::Auto_cap<L4Re::Dataspace>::Cap *ds) throw();
56
57   L4Re::Env const *_env;
58
59 };
60
61 class Ns_dir : public Ns_base_dir
62 {
63 public:
64   explicit Ns_dir(L4::Cap<L4Re::Namespace> ns) : _ns(ns) {}
65
66   ssize_t readv(const struct iovec*, int) throw() { return -EISDIR; }
67   ssize_t writev(const struct iovec*, int) throw() { return -EISDIR; }
68   int fstat64(struct stat64 *) const throw() { return -EINVAL; }
69   int faccessat(const char *path, int mode, int flags) throw();
70   int get_entry(const char *path, int flags, mode_t mode,
71                 Ref_ptr<L4Re::Vfs::File> *) throw();
72
73   ~Ns_dir() throw() {}
74
75 private:
76   int get_ds(const char *path, L4Re::Auto_cap<L4Re::Dataspace>::Cap *ds) throw();
77
78   L4::Cap<L4Re::Namespace> _ns;
79
80 };
81
82 }}