22 #include <l4/l4re_vfs/vfs.h> 23 #include <l4/crtn/initpriorities.h> 25 namespace L4Re {
namespace Vfs {
29 extern L4Re::Cap_alloc *vfs_cap_alloc
asm (
"l4re_env_posix_vfs_cap_alloc");
43 void *
operator new (
size_t size)
throw()
44 {
return vfs_ops->malloc(size); }
46 void *
operator new (size_t,
void *m)
throw()
49 void operator delete (
void *m)
61 ssize_t
readv(
const struct iovec*,
int)
throw()
65 ssize_t
writev(
const struct iovec*,
int)
throw()
69 ssize_t
pwritev(
const struct iovec*,
int, off64_t)
throw()
73 ssize_t
preadv(
const struct iovec*,
int, off64_t)
throw()
93 int ioctl(
unsigned long, va_list)
throw()
96 int fstat64(
struct stat64 *)
const throw()
128 int utime(
const struct utimbuf *)
throw()
132 int utimes(
const struct timeval [2])
throw()
136 int utimensat(
const char *,
const struct timespec [2],
int)
throw()
140 int mkdir(
const char *, mode_t)
throw()
148 int rename(
const char *,
const char *)
throw()
152 int link(
const char *,
const char *)
throw()
156 int symlink(
const char *,
const char *)
throw()
167 ssize_t getdents(
char *,
size_t)
throw()
173 int bind(sockaddr
const *, socklen_t)
throw()
174 {
return -ENOTSOCK; }
176 int connect(sockaddr
const *, socklen_t)
throw()
177 {
return -ENOTSOCK; }
179 ssize_t send(
void const *,
size_t,
int)
throw()
180 {
return -ENOTSOCK; }
182 ssize_t recv(
void *,
size_t,
int)
throw()
183 {
return -ENOTSOCK; }
185 ssize_t sendto(
void const *,
size_t,
int, sockaddr
const *, socklen_t)
throw()
186 {
return -ENOTSOCK; }
188 ssize_t recvfrom(
void *,
size_t,
int, sockaddr *, socklen_t *)
throw()
189 {
return -ENOTSOCK; }
191 ssize_t sendmsg(msghdr
const *,
int)
throw()
192 {
return -ENOTSOCK; }
194 ssize_t recvmsg(msghdr *,
int)
throw()
195 {
return -ENOTSOCK; }
197 int getsockopt(
int,
int,
void *, socklen_t *)
throw()
198 {
return -ENOTSOCK; }
200 int setsockopt(
int,
int,
void const *, socklen_t)
throw()
201 {
return -ENOTSOCK; }
203 int listen(
int)
throw()
204 {
return -ENOTSOCK; }
206 int accept(sockaddr *, socklen_t *)
throw()
207 {
return -ENOTSOCK; }
209 int shutdown(
int)
throw()
210 {
return -ENOTSOCK; }
212 int getsockname(sockaddr *, socklen_t *)
throw()
213 {
return -ENOTSOCK; }
215 int getpeername(sockaddr *, socklen_t *)
throw()
216 {
return -ENOTSOCK; }
230 Be_file::~Be_file()
throw() {}
232 class Be_file_pos :
public Be_file 235 Be_file_pos()
throw() :
Be_file(), _pos(0) {}
237 virtual off64_t size()
const throw() = 0;
239 ssize_t
readv(
const struct iovec *v,
int iovcnt)
throw()
241 ssize_t r =
preadv(v, iovcnt, _pos);
247 ssize_t
writev(
const struct iovec *v,
int iovcnt)
throw()
249 ssize_t r =
pwritev(v, iovcnt, _pos);
255 ssize_t
preadv(
const struct iovec *v,
int iovcnt, off64_t offset)
throw() = 0;
256 ssize_t
pwritev(
const struct iovec *v,
int iovcnt, off64_t offset)
throw() = 0;
258 off64_t
lseek64(off64_t offset,
int whence)
throw()
263 case SEEK_SET: r = offset;
break;
264 case SEEK_CUR: r = _pos + offset;
break;
265 case SEEK_END: r = size() + offset;
break;
266 default:
return -EINVAL;
276 ~Be_file_pos()
throw() = 0;
279 off64_t pos()
const throw() {
return _pos; }
285 inline Be_file_pos::~Be_file_pos()
throw() {}
287 class Be_file_stream :
public Be_file 290 ssize_t
preadv(
const struct iovec *v,
int iovcnt, off64_t)
throw()
291 {
return readv(v, iovcnt); }
293 ssize_t
pwritev(
const struct iovec *v,
int iovcnt, off64_t)
throw()
294 {
return writev(v, iovcnt); }
296 ~Be_file_stream()
throw () = 0;
300 inline Be_file_stream::~Be_file_stream()
throw() {}
311 char const *
const _fstype;
325 vfs_ops->register_file_system(
this);
336 vfs_ops->unregister_file_system(
this);
344 char const *
type()
const throw() {
return _fstype; }
349 #define L4RE_VFS_FILE_SYSTEM_ATTRIBUTE \ 350 __attribute__((init_priority(INIT_PRIO_LATE))) ssize_t pwritev(const struct iovec *, int, off64_t)
Default backend for POSIX pwrite and pwritev functions.
ssize_t readlink(char *, size_t)
Default backend for POSIX readlink, readlinkat.
A reference-counting pointer with automatic cleanup.
Interface for the POSIX backends for an application.
int set_lock(struct flock64 *, bool)
Default backend for POSIX fcntl subfunctions.
int get_lock(struct flock64 *)
Default backend for POSIX fcntl subfunctions.
ssize_t writev(const struct iovec *, int)
Default backend for POSIX write and writev functions.
int ioctl(unsigned long, va_list)
Default backend for POSIX ioctl.
Capability allocator interface.
int fchmod(mode_t)
Default backend for POSIX chmod and fchmod.
int mkdir(const char *, mode_t)
Default backend for POSIX mkdir and mkdirat.
int get_status_flags() const
Default backend for POSIX fcntl subfunctions.
int rmdir(const char *)
Default backend for POSIX rmdir, rmdirat.
The basic interface for an open POSIX file.
int utimes(const struct timeval [2])
Default backend for POSIX utimes.
Boiler plate class for implementing an open file for L4Re::Vfs.
int faccessat(const char *, int, int)
Default backend for POSIX access and faccessat functions.
~Be_file_system()
Destroy a file-system object.
int ftruncate64(off64_t)
Default backend for the POSIX truncate, ftruncate and similar functions.
ssize_t readv(const struct iovec *, int)
Default backend for POSIX read and readv functions.
int symlink(const char *, const char *)
Default backend for POSIX symlink, symlinkat.
int utime(const struct utimbuf *)
Default backend for POSIX utime.
ssize_t preadv(const struct iovec *, int, off64_t)
Default backend for POSIX pread and preadv functions.
int fchmodat(const char *, mode_t, int)
Default backend for POSIX fchmodat function.
L4::Cap< L4Re::Dataspace > data_space() const
Get an L4Re::Dataspace object for the file.
char const * type() const
Return the file-system type.
int utimensat(const char *, const struct timespec [2], int)
Default backend for POSIX utimensat.
int unlock_all_locks()
Unlock all locks on the file.
int fdatasync() const
Default backend for POSIX fdatasync.
int fsync() const
Default backend for POSIX fsync.
int unlink(const char *)
Default backend for POSIX unlink, unlinkat.
Boilerplate class for implementing a L4Re::Vfs::File_system.
int link(const char *, const char *)
Default backend for POSIX link, linkat.
off64_t lseek64(off64_t, int)
Default backend for POSIX seek and lseek functions.
int rename(const char *, const char *)
Default backend for POSIX rename, renameat.
int set_status_flags(long)
Default backend for POSIX fcntl subfunctions.
int fstat64(struct stat64 *) const
Get status information for the file.
Be_file_system(char const *fstype)
Create a file-system object for the given fstype.
Basic interface for an L4Re::Vfs file system.