]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re_vfs/include/impl/ro_file.h
d6e05f7a96e316dab4e9e5bd17c0d10c144af522
[l4.git] / l4 / pkg / l4re_vfs / include / impl / ro_file.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 "simple_store.h"
20
21 namespace L4Re { namespace Core {
22
23 class Ro_file : public L4Re::Vfs::Be_file
24 {
25 private:
26   L4::Cap<L4Re::Dataspace> _ds;
27   off64_t _f_pos;
28   off64_t _size;
29   char const *_addr;
30
31 public:
32   explicit Ro_file(L4::Cap<L4Re::Dataspace> ds) throw()
33   : Be_file(), _ds(ds), _f_pos(0), _addr(0)
34   {
35     _ds->take();
36     _size = _ds->size();
37   }
38
39   L4::Cap<L4Re::Dataspace> data_space() const throw() { return _ds; }
40
41   ssize_t readv(const struct iovec*, int iovcnt) throw();
42   ssize_t writev(const struct iovec*, int iovcnt) throw();
43
44   off64_t lseek64(off64_t, int) throw();
45   int fstat64(struct stat64 *buf) const throw();
46
47   int get_status_flags() const throw()
48   { return O_RDONLY; }
49
50   int set_status_flags(long) throw()
51   { return 0; }
52
53   ~Ro_file() throw();
54
55   void *operator new(size_t s) throw();
56   void operator delete(void *b) throw();
57
58 private:
59
60   ssize_t read(const struct iovec*) throw();
61 //  ssize_t write(const struct iovec*) throw();
62
63
64 private:
65
66   static Simple_store<Ro_file> store;
67 };
68
69
70 }}