diff options
author | Zhangjin Wu | 2023-07-08 02:34:21 +0800 |
---|---|---|
committer | Willy Tarreau | 2023-08-23 04:38:02 +0200 |
commit | f4191f3d524289080284fa3a48ccd096b319d280 (patch) | |
tree | 3249da691f87d9de34d83f34ee5eaf3767f44fbc /tools/include | |
parent | f7a419e35ba3c6301fa096370548599853ef2b5d (diff) |
tools/nolibc: add rmdir() support
a reverse operation of mkdir() is meaningful, add rmdir() here.
required by nolibc-test to remove /proc while CONFIG_PROC_FS is not
enabled.
Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Diffstat (limited to 'tools/include')
-rw-r--r-- | tools/include/nolibc/sys.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 804bc0231ec7..dee56894a811 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -611,6 +611,28 @@ int mkdir(const char *path, mode_t mode) return __sysret(sys_mkdir(path, mode)); } +/* + * int rmdir(const char *path); + */ + +static __attribute__((unused)) +int sys_rmdir(const char *path) +{ +#ifdef __NR_rmdir + return my_syscall1(__NR_rmdir, path); +#elif defined(__NR_unlinkat) + return my_syscall3(__NR_unlinkat, AT_FDCWD, path, AT_REMOVEDIR); +#else + return -ENOSYS; +#endif +} + +static __attribute__((unused)) +int rmdir(const char *path) +{ + return __sysret(sys_rmdir(path)); +} + /* * int mknod(const char *path, mode_t mode, dev_t dev); |