libc: Add 'rmdir' to plugin interface

This commit is contained in:
Norman Feske 2014-04-18 22:58:04 +02:00 committed by Christian Helmuth
parent a011c76d85
commit 7750a399cc
5 changed files with 24 additions and 0 deletions

View File

@ -55,6 +55,7 @@ namespace Libc {
virtual bool supports_pipe();
virtual bool supports_readlink(const char *path, char *buf, size_t bufsiz);
virtual bool supports_rename(const char *oldpath, const char *newpath);
virtual bool supports_rmdir(const char *path);
virtual bool supports_select(int nfds,
fd_set *readfds,
fd_set *writefds,
@ -116,6 +117,7 @@ namespace Libc {
struct sockaddr *src_addr, socklen_t *addrlen);
virtual ssize_t recvmsg(File_descriptor *, struct msghdr *msg, int flags);
virtual int rename(const char *oldpath, const char *newpath);
virtual int rmdir(const char *pathname);
virtual int select(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout);
virtual ssize_t send(File_descriptor *, const void *buf, ::size_t len, int flags);

View File

@ -36,6 +36,7 @@ namespace Libc {
Plugin *get_plugin_for_pipe();
Plugin *get_plugin_for_readlink(const char *path, char *buf, size_t bufsiz);
Plugin *get_plugin_for_rename(const char *oldpath, const char *newpath);
Plugin *get_plugin_for_rmdir(const char *path);
Plugin *get_plugin_for_socket(int domain, int type, int protocol);
Plugin *get_plugin_for_stat(const char *path, struct stat *);
Plugin *get_plugin_for_symlink(const char *oldpath, const char *newpath);

View File

@ -731,6 +731,18 @@ extern "C" int rename(const char *oldpath, const char *newpath)
}
extern "C" int rmdir(const char *path)
{
try {
Absolute_path resolved_path;
resolve_symlinks_except_last_element(path, resolved_path);
FNAME_FUNC_WRAPPER(rmdir, resolved_path.base());
} catch(Symlink_resolve_error) {
return -1;
}
}
extern "C" ssize_t send(int libc_fd, const void *buf, ::size_t len, int flags) {
FD_FUNC_WRAPPER(send, libc_fd, buf, len, flags); }

View File

@ -93,6 +93,12 @@ bool Plugin::supports_rename(const char *, const char *)
}
bool Plugin::supports_rmdir(const char*)
{
return false;
}
bool Plugin::supports_select(int, fd_set *, fd_set *,
fd_set *, struct timeval *)
{
@ -193,6 +199,7 @@ DUMMY(int, -1, munmap, (void *, ::size_t));
DUMMY(int, -1, pipe, (File_descriptor*[2]));
DUMMY(ssize_t, -1, readlink, (const char *, char *, size_t));
DUMMY(int, -1, rename, (const char *, const char *));
DUMMY(int, -1, rmdir, (const char*));
DUMMY(int, -1, select, (int, fd_set *, fd_set *, fd_set *, struct timeval *));
DUMMY(int, -1, stat, (const char*, struct stat*));
DUMMY(int, -1, symlink, (const char*, const char*));

View File

@ -71,6 +71,8 @@ Plugin *Plugin_registry::get_plugin_for_readlink(const char *path, char *buf, si
Plugin *Plugin_registry::get_plugin_for_rename(const char *oldpath, const char *newpath) {
GET_PLUGIN_FOR(rename, oldpath, newpath) }
Plugin *Plugin_registry::get_plugin_for_rmdir(const char *path) {
GET_PLUGIN_FOR(rmdir, path) }
Plugin *Plugin_registry::get_plugin_for_socket(int domain, int type, int protocol) {
GET_PLUGIN_FOR(socket, domain, type, protocol) }