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 
23 namespace L4Re { namespace Core {
24 
25 class Ro_file : public L4Re::Vfs::Be_file_pos
26 {
27 private:
28   L4::Cap<L4Re::Dataspace> _ds;
29   off64_t _size;
30   char const *_addr;
31 
32 public:
Ro_file(L4::Cap<L4Re::Dataspace> ds)33   explicit Ro_file(L4::Cap<L4Re::Dataspace> ds) throw()
34   : Be_file_pos(), _ds(ds), _addr(0)
35   {
36     _size = _ds->size();
37   }
38 
data_space()39   L4::Cap<L4Re::Dataspace> data_space() const throw() { return _ds; }
40 
41   int fstat64(struct stat64 *buf) const throw();
42 
43   int ioctl(unsigned long, va_list) throw();
44 
size()45   off64_t size() const throw() { return _size; }
46 
get_status_flags()47   int get_status_flags() const throw()
48   { return O_RDONLY; }
49 
set_status_flags(long)50   int set_status_flags(long) throw()
51   { return 0; }
52 
53   ~Ro_file() throw();
54 
55 private:
56   ssize_t read_single(const struct iovec*, off64_t) throw();
57   ssize_t preadv(const struct iovec *, int, off64_t) throw();
58   ssize_t pwritev(const struct iovec *, int , off64_t) throw();
59 };
60 
61 
62 }}
63