23 #include <l4/re/util/env_ns> 26 namespace L4Re {
namespace Core {
29 Ref_ptr<L4Re::Vfs::File>
35 L4::Ipc::String<char> name(
sizeof(name_buf), name_buf);
40 return Ref_ptr<L4Re::Vfs::File>();
44 return Ref_ptr<L4Re::Vfs::File>();
46 auto factory = L4Re::Vfs::vfs_ops->get_file_factory(proto);
48 return Ref_ptr<L4Re::Vfs::File>();
51 return factory->create(o);
63 int err = _ns->query(path, file.get());
73 Ns_dir::get_entry(
const char *path,
int flags, mode_t mode,
74 Ref_ptr<L4Re::Vfs::File> *f)
throw()
76 (void)mode; (void)flags;
79 *f = cxx::ref_ptr(
this);
84 int err = get_ds(path, &file);
99 Ns_dir::faccessat(
const char *path,
int mode,
int flags)
throw()
104 if (!tmpcap.is_valid())
107 if (_ns->query(path, tmpcap.get()))
117 Ns_dir::fstat64(
struct stat64 *b)
const throw()
121 b->st_mode = S_IRWXU | S_IFDIR;
136 Ns_dir::getdents(
char *buf,
size_t sz)
throw()
138 struct dirent64 *d = (
struct dirent64 *)buf;
144 int err = get_ds(
".dirinfo", &dirinfofile);
148 infosz = dirinfofile->size();
155 dirinfofile.get(), 0);
156 char *p = (
char *)infoaddr + _current_dir_pos;
157 char *end = (
char *)infoaddr + infosz;
163 for (len = 0; p < end && *p >=
'0' && *p <=
'9'; ++p)
175 unsigned l = len + 1;
176 if (l >
sizeof(d->d_name))
177 l =
sizeof(d->d_name);
179 unsigned n = offsetof (
struct dirent64, d_name) + l;
180 n = (n +
sizeof(long) - 1) & ~(
sizeof(long) - 1);
187 memcpy(d->d_name, p, len);
188 d->d_name[l - 1] = 0;
193 d = (
struct dirent64 *)((
unsigned long)d + n);
197 while (p < end && *p && *p !=
'\n' && *p !=
'\r')
199 while (p < end && *p && (*p ==
'\n' || *p ==
'\r'))
203 _current_dir_pos += p - (
char *)infoaddr;
206 _current_dir_pos = 0;
217 Vfs::Path first = p.strip_first();
239 int err = c->
query(p.path(), p.length(), file.get());
249 Env_dir::get_entry(
const char *path,
int flags, mode_t mode,
250 Ref_ptr<L4Re::Vfs::File> *f)
throw()
252 (void)mode; (void)flags;
255 *f = cxx::ref_ptr(
this);
260 int err = get_ds(path, &file);
275 Env_dir::faccessat(
const char *path,
int mode,
int flags)
throw()
279 Vfs::Path first = p.strip_first();
300 if (!tmpcap.is_valid())
303 if (c->
query(p.path(), p.length(), tmpcap.get()))
313 Env_dir::check_type(
Env::Cap_entry const *e,
long protocol)
throw()
320 Env_dir::fstat64(
struct stat64 *b)
const throw()
324 b->st_mode = S_IRWXU | S_IFDIR;
339 Env_dir::getdents(
char *buf,
size_t sz)
throw()
341 struct dirent64 *d = (
struct dirent64 *)buf;
345 && _current_cap_entry
346 && _current_cap_entry->flags != ~0UL)
348 unsigned l = strlen(_current_cap_entry->name) + 1;
349 if (l >
sizeof(d->d_name))
350 l =
sizeof(d->d_name);
352 unsigned n = offsetof (
struct dirent64, d_name) + l;
353 n = (n +
sizeof(long) - 1) & ~(
sizeof(long) - 1);
359 memcpy(d->d_name, _current_cap_entry->name, l);
360 d->d_name[l - 1] = 0;
362 if (check_type(_current_cap_entry, L4Re::Namespace::Protocol))
364 else if (check_type(_current_cap_entry, L4Re::Dataspace::Protocol))
367 d->d_type = DT_UNKNOWN;
370 d = (
struct dirent64 *)((
unsigned long)d + n);
371 _current_cap_entry++;
379 _current_cap_entry = _env->initial_caps();
l4re_env_cap_entry_t Cap_entry
C++ type for an entry in the initial objects array.
long query(char const *name, L4::Cap< void > const &cap, int timeout=To_default, l4_umword_t *local_id=0, bool iterate=true) const
Query the name space for a named object.
Search for a suitable address range.
long label() const
Get the protocol value.
Cap< T > cap_reinterpret_cast(Cap< F > const &c)
reinterpret_cast for capabilities.
#define L4_PAGESIZE
Minimal page size (in bytes).
static Env const * env()
Returns the initial environment for the current task.
_Cap_alloc & cap_alloc
Capability allocator.
bool is_valid() const
Test whether the capability is a valid capability index (i.e., not L4_INVALID_CAP).
long l4_error(l4_msgtag_t tag) L4_NOTHROW
Return error code of a system call return message tag.
C++ interface for capabilities.
unsigned long l4_addr_t
Address type.
L4::Cap< Rm > rm() const
Object-capability to the region map.