Provide a default implementation of chdir, fix #68
The default implementation relies on the sequence open, fchdir, close. Enable this implementation for the Noux libc plugin.
This commit is contained in:
parent
d43126e8e7
commit
3c54d39307
|
@ -110,6 +110,18 @@ bool Plugin::supports_unlink(const char*)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default implementations
|
||||||
|
*/
|
||||||
|
|
||||||
|
int Plugin::chdir(const char *path)
|
||||||
|
{
|
||||||
|
Libc::File_descriptor *fd = open(path, 0 /* no rights necessary */);
|
||||||
|
bool success = ((fd != NULL)
|
||||||
|
and (fchdir(fd) == 0)
|
||||||
|
and (close(fd) == 0));
|
||||||
|
return success ? 0 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate dummy member function of Plugin class
|
* Generate dummy member function of Plugin class
|
||||||
|
@ -161,7 +173,6 @@ DUMMY(ssize_t, -1, write, (File_descriptor *, const void *, ::size_t));
|
||||||
/*
|
/*
|
||||||
* Misc
|
* Misc
|
||||||
*/
|
*/
|
||||||
DUMMY(int, -1, chdir, (const char*));
|
|
||||||
DUMMY(void, , freeaddrinfo, (struct ::addrinfo *));
|
DUMMY(void, , freeaddrinfo, (struct ::addrinfo *));
|
||||||
DUMMY(int, -1, getaddrinfo, (const char *, const char *, const struct ::addrinfo *, struct ::addrinfo **));
|
DUMMY(int, -1, getaddrinfo, (const char *, const char *, const struct ::addrinfo *, struct ::addrinfo **));
|
||||||
DUMMY(int, -1, mkdir, (const char*, mode_t));
|
DUMMY(int, -1, mkdir, (const char*, mode_t));
|
||||||
|
|
|
@ -331,6 +331,7 @@ namespace {
|
||||||
_stderr(Libc::file_descriptor_allocator()->alloc(this, noux_context(2), 2))
|
_stderr(Libc::file_descriptor_allocator()->alloc(this, noux_context(2), 2))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
bool supports_chdir(const char *) { return true; }
|
||||||
bool supports_open(const char *, int) { return true; }
|
bool supports_open(const char *, int) { return true; }
|
||||||
bool supports_stat(const char *) { return true; }
|
bool supports_stat(const char *) { return true; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue