From b9bb8f67bbac9bab5314fb00974ad469476e936e Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Fri, 7 Sep 2012 00:48:25 -0400 Subject: [PATCH] cleanup src/linux and src/misc trees, etc. previously, it was pretty much random which one of these trees a given function appeared in. they have now been organized into: src/linux: non-POSIX linux syscalls (possibly shard with other nixen) src/legacy: various obsolete/legacy functions, mostly wrappers src/misc: still mostly uncategorized; some misc POSIX, some nonstd src/crypt: crypt hash functions further cleanup will be done later. --- src/{misc => crypt}/crypt.c | 0 src/{misc => crypt}/crypt_blowfish.c | 0 src/{misc => crypt}/crypt_des.c | 0 src/{misc => crypt}/crypt_r.c | 0 src/{misc => crypt}/crypt_sha256.c | 0 src/{misc => crypt}/crypt_sha512.c | 0 src/{misc => legacy}/cuserid.c | 0 src/{linux => legacy}/daemon.c | 0 src/{linux => legacy}/err.c | 0 src/{misc => legacy}/ftw.c | 0 src/{misc => legacy}/futimes.c | 0 src/{linux => legacy}/getdtablesize.c | 0 src/{linux => legacy}/getpagesize.c | 0 src/{linux => legacy}/getpass.c | 0 src/{misc => legacy}/getusershell.c | 0 src/{misc => legacy}/isastream.c | 0 src/{misc => legacy}/lutimes.c | 0 src/{misc => legacy}/ulimit.c | 0 src/{stub => legacy}/utmpx.c | 0 src/linux/epoll.c | 27 +++++++++++++++++++++++++++ src/linux/epoll_create.c | 7 ------- src/linux/epoll_create1.c | 7 ------- src/linux/epoll_ctl.c | 7 ------- src/linux/epoll_pwait.c | 7 ------- src/linux/epoll_wait.c | 7 ------- src/linux/eventfd.c | 11 +++++++++++ src/linux/eventfd_read.c | 7 ------- src/linux/eventfd_write.c | 7 ------- src/linux/inotify.c | 21 +++++++++++++++++++++ src/linux/inotify_add_watch.c | 7 ------- src/linux/inotify_init.c | 7 ------- src/linux/inotify_init1.c | 7 ------- src/linux/inotify_rm_watch.c | 7 ------- src/linux/mount.c | 10 ++++++++++ src/{misc => linux}/prlimit.c | 0 src/{misc => linux}/ptrace.c | 0 src/linux/{swapon.c => swap.c} | 5 +++++ src/linux/swapoff.c | 7 ------- src/linux/umount.c | 7 ------- src/linux/umount2.c | 7 ------- src/{linux => misc}/gethostid.c | 0 src/{linux => misc}/getopt_long.c | 0 src/{linux => misc}/initgroups.c | 0 src/{linux => misc}/mntent.c | 0 src/{linux => misc}/syscall.c | 0 45 files changed, 74 insertions(+), 98 deletions(-) rename src/{misc => crypt}/crypt.c (100%) rename src/{misc => crypt}/crypt_blowfish.c (100%) rename src/{misc => crypt}/crypt_des.c (100%) rename src/{misc => crypt}/crypt_r.c (100%) rename src/{misc => crypt}/crypt_sha256.c (100%) rename src/{misc => crypt}/crypt_sha512.c (100%) rename src/{misc => legacy}/cuserid.c (100%) rename src/{linux => legacy}/daemon.c (100%) rename src/{linux => legacy}/err.c (100%) rename src/{misc => legacy}/ftw.c (100%) rename src/{misc => legacy}/futimes.c (100%) rename src/{linux => legacy}/getdtablesize.c (100%) rename src/{linux => legacy}/getpagesize.c (100%) rename src/{linux => legacy}/getpass.c (100%) rename src/{misc => legacy}/getusershell.c (100%) rename src/{misc => legacy}/isastream.c (100%) rename src/{misc => legacy}/lutimes.c (100%) rename src/{misc => legacy}/ulimit.c (100%) rename src/{stub => legacy}/utmpx.c (100%) create mode 100644 src/linux/epoll.c delete mode 100644 src/linux/epoll_create.c delete mode 100644 src/linux/epoll_create1.c delete mode 100644 src/linux/epoll_ctl.c delete mode 100644 src/linux/epoll_pwait.c delete mode 100644 src/linux/epoll_wait.c delete mode 100644 src/linux/eventfd_read.c delete mode 100644 src/linux/eventfd_write.c create mode 100644 src/linux/inotify.c delete mode 100644 src/linux/inotify_add_watch.c delete mode 100644 src/linux/inotify_init.c delete mode 100644 src/linux/inotify_init1.c delete mode 100644 src/linux/inotify_rm_watch.c rename src/{misc => linux}/prlimit.c (100%) rename src/{misc => linux}/ptrace.c (100%) rename src/linux/{swapon.c => swap.c} (64%) delete mode 100644 src/linux/swapoff.c delete mode 100644 src/linux/umount.c delete mode 100644 src/linux/umount2.c rename src/{linux => misc}/gethostid.c (100%) rename src/{linux => misc}/getopt_long.c (100%) rename src/{linux => misc}/initgroups.c (100%) rename src/{linux => misc}/mntent.c (100%) rename src/{linux => misc}/syscall.c (100%) diff --git a/src/misc/crypt.c b/src/crypt/crypt.c similarity index 100% rename from src/misc/crypt.c rename to src/crypt/crypt.c diff --git a/src/misc/crypt_blowfish.c b/src/crypt/crypt_blowfish.c similarity index 100% rename from src/misc/crypt_blowfish.c rename to src/crypt/crypt_blowfish.c diff --git a/src/misc/crypt_des.c b/src/crypt/crypt_des.c similarity index 100% rename from src/misc/crypt_des.c rename to src/crypt/crypt_des.c diff --git a/src/misc/crypt_r.c b/src/crypt/crypt_r.c similarity index 100% rename from src/misc/crypt_r.c rename to src/crypt/crypt_r.c diff --git a/src/misc/crypt_sha256.c b/src/crypt/crypt_sha256.c similarity index 100% rename from src/misc/crypt_sha256.c rename to src/crypt/crypt_sha256.c diff --git a/src/misc/crypt_sha512.c b/src/crypt/crypt_sha512.c similarity index 100% rename from src/misc/crypt_sha512.c rename to src/crypt/crypt_sha512.c diff --git a/src/misc/cuserid.c b/src/legacy/cuserid.c similarity index 100% rename from src/misc/cuserid.c rename to src/legacy/cuserid.c diff --git a/src/linux/daemon.c b/src/legacy/daemon.c similarity index 100% rename from src/linux/daemon.c rename to src/legacy/daemon.c diff --git a/src/linux/err.c b/src/legacy/err.c similarity index 100% rename from src/linux/err.c rename to src/legacy/err.c diff --git a/src/misc/ftw.c b/src/legacy/ftw.c similarity index 100% rename from src/misc/ftw.c rename to src/legacy/ftw.c diff --git a/src/misc/futimes.c b/src/legacy/futimes.c similarity index 100% rename from src/misc/futimes.c rename to src/legacy/futimes.c diff --git a/src/linux/getdtablesize.c b/src/legacy/getdtablesize.c similarity index 100% rename from src/linux/getdtablesize.c rename to src/legacy/getdtablesize.c diff --git a/src/linux/getpagesize.c b/src/legacy/getpagesize.c similarity index 100% rename from src/linux/getpagesize.c rename to src/legacy/getpagesize.c diff --git a/src/linux/getpass.c b/src/legacy/getpass.c similarity index 100% rename from src/linux/getpass.c rename to src/legacy/getpass.c diff --git a/src/misc/getusershell.c b/src/legacy/getusershell.c similarity index 100% rename from src/misc/getusershell.c rename to src/legacy/getusershell.c diff --git a/src/misc/isastream.c b/src/legacy/isastream.c similarity index 100% rename from src/misc/isastream.c rename to src/legacy/isastream.c diff --git a/src/misc/lutimes.c b/src/legacy/lutimes.c similarity index 100% rename from src/misc/lutimes.c rename to src/legacy/lutimes.c diff --git a/src/misc/ulimit.c b/src/legacy/ulimit.c similarity index 100% rename from src/misc/ulimit.c rename to src/legacy/ulimit.c diff --git a/src/stub/utmpx.c b/src/legacy/utmpx.c similarity index 100% rename from src/stub/utmpx.c rename to src/legacy/utmpx.c diff --git a/src/linux/epoll.c b/src/linux/epoll.c new file mode 100644 index 00000000..35f70ed1 --- /dev/null +++ b/src/linux/epoll.c @@ -0,0 +1,27 @@ +#include +#include "syscall.h" + +int epoll_create(int size) +{ + return syscall(SYS_epoll_create, size); +} + +int epoll_create1(int flags) +{ + return syscall(SYS_epoll_create1, flags); +} + +int epoll_ctl(int fd, int op, int fd2, struct epoll_event *ev) +{ + return syscall(SYS_epoll_ctl, fd, op, fd2, ev); +} + +int epoll_pwait(int fd, struct epoll_event *ev, int cnt, int to, const sigset_t *sigs) +{ + return syscall(SYS_epoll_pwait, fd, ev, cnt, to, sigs, __SYSCALL_SSLEN); +} + +int epoll_wait(int fd, struct epoll_event *ev, int cnt, int to) +{ + return syscall(SYS_epoll_wait, fd, ev, cnt, to); +} diff --git a/src/linux/epoll_create.c b/src/linux/epoll_create.c deleted file mode 100644 index 29d82999..00000000 --- a/src/linux/epoll_create.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "syscall.h" - -int epoll_create(int size) -{ - return syscall(SYS_epoll_create, size); -} diff --git a/src/linux/epoll_create1.c b/src/linux/epoll_create1.c deleted file mode 100644 index 380b5dad..00000000 --- a/src/linux/epoll_create1.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "syscall.h" - -int epoll_create1(int flags) -{ - return syscall(SYS_epoll_create1, flags); -} diff --git a/src/linux/epoll_ctl.c b/src/linux/epoll_ctl.c deleted file mode 100644 index da3e999b..00000000 --- a/src/linux/epoll_ctl.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "syscall.h" - -int epoll_ctl(int fd, int op, int fd2, struct epoll_event *ev) -{ - return syscall(SYS_epoll_ctl, fd, op, fd2, ev); -} diff --git a/src/linux/epoll_pwait.c b/src/linux/epoll_pwait.c deleted file mode 100644 index 3ecdbb59..00000000 --- a/src/linux/epoll_pwait.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "syscall.h" - -int epoll_pwait(int fd, struct epoll_event *ev, int cnt, int to, const sigset_t *sigs) -{ - return syscall(SYS_epoll_pwait, fd, ev, cnt, to, sigs, __SYSCALL_SSLEN); -} diff --git a/src/linux/epoll_wait.c b/src/linux/epoll_wait.c deleted file mode 100644 index 9d3924e0..00000000 --- a/src/linux/epoll_wait.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "syscall.h" - -int epoll_wait(int fd, struct epoll_event *ev, int cnt, int to) -{ - return syscall(SYS_epoll_wait, fd, ev, cnt, to); -} diff --git a/src/linux/eventfd.c b/src/linux/eventfd.c index cb39a7ba..53066487 100644 --- a/src/linux/eventfd.c +++ b/src/linux/eventfd.c @@ -1,7 +1,18 @@ #include +#include #include "syscall.h" int eventfd(unsigned int count, int flags) { return syscall(flags ? SYS_eventfd2 : SYS_eventfd, count, flags); } + +int eventfd_read(int fd, eventfd_t *value) +{ + return (sizeof(*value) == read(fd, value, sizeof(*value))) ? 0 : -1; +} + +int eventfd_write(int fd, eventfd_t value) +{ + return (sizeof(value) == write(fd, &value, sizeof(value))) ? 0 : -1; +} diff --git a/src/linux/eventfd_read.c b/src/linux/eventfd_read.c deleted file mode 100644 index 969e6615..00000000 --- a/src/linux/eventfd_read.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -int eventfd_read(int fd, eventfd_t *value) -{ - return (sizeof(*value) == read(fd, value, sizeof(*value))) ? 0 : -1; -} diff --git a/src/linux/eventfd_write.c b/src/linux/eventfd_write.c deleted file mode 100644 index 734fa367..00000000 --- a/src/linux/eventfd_write.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -int eventfd_write(int fd, eventfd_t value) -{ - return (sizeof(value) == write(fd, &value, sizeof(value))) ? 0 : -1; -} diff --git a/src/linux/inotify.c b/src/linux/inotify.c new file mode 100644 index 00000000..d3b4fa0b --- /dev/null +++ b/src/linux/inotify.c @@ -0,0 +1,21 @@ +#include +#include "syscall.h" + +int inotify_init() +{ + return syscall(SYS_inotify_init); +} +int inotify_init1(int flags) +{ + return syscall(SYS_inotify_init1, flags); +} + +int inotify_add_watch(int fd, const char *pathname, uint32_t mask) +{ + return syscall(SYS_inotify_add_watch, fd, pathname, mask); +} + +int inotify_rm_watch(int fd, uint32_t wd) +{ + return syscall(SYS_inotify_rm_watch, fd, wd); +} diff --git a/src/linux/inotify_add_watch.c b/src/linux/inotify_add_watch.c deleted file mode 100644 index 75f207d7..00000000 --- a/src/linux/inotify_add_watch.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "syscall.h" - -int inotify_add_watch(int fd, const char *pathname, uint32_t mask) -{ - return syscall(SYS_inotify_add_watch, fd, pathname, mask); -} diff --git a/src/linux/inotify_init.c b/src/linux/inotify_init.c deleted file mode 100644 index 05070846..00000000 --- a/src/linux/inotify_init.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "syscall.h" - -int inotify_init() -{ - return syscall(SYS_inotify_init); -} diff --git a/src/linux/inotify_init1.c b/src/linux/inotify_init1.c deleted file mode 100644 index 6472a7b2..00000000 --- a/src/linux/inotify_init1.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "syscall.h" - -int inotify_init1(int flags) -{ - return syscall(SYS_inotify_init1, flags); -} diff --git a/src/linux/inotify_rm_watch.c b/src/linux/inotify_rm_watch.c deleted file mode 100644 index cba597eb..00000000 --- a/src/linux/inotify_rm_watch.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "syscall.h" - -int inotify_rm_watch(int fd, uint32_t wd) -{ - return syscall(SYS_inotify_rm_watch, fd, wd); -} diff --git a/src/linux/mount.c b/src/linux/mount.c index 83a8db44..34e11af1 100644 --- a/src/linux/mount.c +++ b/src/linux/mount.c @@ -5,3 +5,13 @@ int mount(const char *special, const char *dir, const char *fstype, unsigned lon { return syscall(SYS_mount, special, dir, fstype, flags, data); } + +int umount(const char *special) +{ + return syscall(SYS_umount2, special, 0); +} + +int umount2(const char *special, int flags) +{ + return syscall(SYS_umount2, special, flags); +} diff --git a/src/misc/prlimit.c b/src/linux/prlimit.c similarity index 100% rename from src/misc/prlimit.c rename to src/linux/prlimit.c diff --git a/src/misc/ptrace.c b/src/linux/ptrace.c similarity index 100% rename from src/misc/ptrace.c rename to src/linux/ptrace.c diff --git a/src/linux/swapon.c b/src/linux/swap.c similarity index 64% rename from src/linux/swapon.c rename to src/linux/swap.c index 2b40a30b..8137d51e 100644 --- a/src/linux/swapon.c +++ b/src/linux/swap.c @@ -5,3 +5,8 @@ int swapon(const char *path, int flags) { return syscall(SYS_swapon, path, flags); } + +int swapoff(const char *path) +{ + return syscall(SYS_swapoff, path); +} diff --git a/src/linux/swapoff.c b/src/linux/swapoff.c deleted file mode 100644 index 9f95e82d..00000000 --- a/src/linux/swapoff.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "syscall.h" - -int swapoff(const char *path) -{ - return syscall(SYS_swapoff, path); -} diff --git a/src/linux/umount.c b/src/linux/umount.c deleted file mode 100644 index fb9b5e73..00000000 --- a/src/linux/umount.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "syscall.h" - -int umount(const char *special) -{ - return syscall(SYS_umount2, special, 0); -} diff --git a/src/linux/umount2.c b/src/linux/umount2.c deleted file mode 100644 index 25ad057c..00000000 --- a/src/linux/umount2.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include "syscall.h" - -int umount2(const char *special, int flags) -{ - return syscall(SYS_umount2, special, flags); -} diff --git a/src/linux/gethostid.c b/src/misc/gethostid.c similarity index 100% rename from src/linux/gethostid.c rename to src/misc/gethostid.c diff --git a/src/linux/getopt_long.c b/src/misc/getopt_long.c similarity index 100% rename from src/linux/getopt_long.c rename to src/misc/getopt_long.c diff --git a/src/linux/initgroups.c b/src/misc/initgroups.c similarity index 100% rename from src/linux/initgroups.c rename to src/misc/initgroups.c diff --git a/src/linux/mntent.c b/src/misc/mntent.c similarity index 100% rename from src/linux/mntent.c rename to src/misc/mntent.c diff --git a/src/linux/syscall.c b/src/misc/syscall.c similarity index 100% rename from src/linux/syscall.c rename to src/misc/syscall.c -- 2.25.1