diff options
Diffstat (limited to 'src/sys')
49 files changed, 404 insertions, 0 deletions
diff --git a/src/sys/stat/S_IRGRP.c b/src/sys/stat/S_IRGRP.c new file mode 100644 index 00000000..98cf739e --- /dev/null +++ b/src/sys/stat/S_IRGRP.c @@ -0,0 +1,6 @@ +#include <sys/stat.h> + +#define S_IRGRP (040) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IROTH.c b/src/sys/stat/S_IROTH.c new file mode 100644 index 00000000..006421ed --- /dev/null +++ b/src/sys/stat/S_IROTH.c @@ -0,0 +1,6 @@ +#include <sys/stat.h> + +#define S_IROTH (04) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IRUSR.c b/src/sys/stat/S_IRUSR.c new file mode 100644 index 00000000..2b62f4f1 --- /dev/null +++ b/src/sys/stat/S_IRUSR.c @@ -0,0 +1,6 @@ +#include <sys/stat.h> + +#define S_IRUSR (0400) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IRWXG.c b/src/sys/stat/S_IRWXG.c new file mode 100644 index 00000000..e051625e --- /dev/null +++ b/src/sys/stat/S_IRWXG.c @@ -0,0 +1,6 @@ +#include <sys/stat.h> + +#define S_IRWXG (070) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IRWXO.c b/src/sys/stat/S_IRWXO.c new file mode 100644 index 00000000..82bbadb3 --- /dev/null +++ b/src/sys/stat/S_IRWXO.c @@ -0,0 +1,6 @@ +#include <sys/stat.h> + +#define S_IRWXO (07) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IRWXU.c b/src/sys/stat/S_IRWXU.c new file mode 100644 index 00000000..a518680e --- /dev/null +++ b/src/sys/stat/S_IRWXU.c @@ -0,0 +1,6 @@ +#include <sys/stat.h> + +#define S_IRWXU (0700) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_ISBLK.C b/src/sys/stat/S_ISBLK.C new file mode 100644 index 00000000..1a1498ef --- /dev/null +++ b/src/sys/stat/S_ISBLK.C @@ -0,0 +1,5 @@ +#includ +#define S_ISBLK(s) /* FIXME */ +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_ISCHR.c b/src/sys/stat/S_ISCHR.c new file mode 100644 index 00000000..a393b84e --- /dev/null +++ b/src/sys/stat/S_ISCHR.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_ISCHR(s) /* fixme */ +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_ISDIR.c b/src/sys/stat/S_ISDIR.c new file mode 100644 index 00000000..5b5720c7 --- /dev/null +++ b/src/sys/stat/S_ISDIR.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_ISDIR(s) (s) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_ISFIFO.c b/src/sys/stat/S_ISFIFO.c new file mode 100644 index 00000000..a28a90e9 --- /dev/null +++ b/src/sys/stat/S_ISFIFO.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_ISFIFO(s) /* fixme */ +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_ISGID.c b/src/sys/stat/S_ISGID.c new file mode 100644 index 00000000..55ceb105 --- /dev/null +++ b/src/sys/stat/S_ISGID.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_ISGID (02000) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_ISREG.c b/src/sys/stat/S_ISREG.c new file mode 100644 index 00000000..7a09ffe5 --- /dev/null +++ b/src/sys/stat/S_ISREG.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_ISREG(s) /* fixme */ +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_ISUID.c b/src/sys/stat/S_ISUID.c new file mode 100644 index 00000000..85295ad3 --- /dev/null +++ b/src/sys/stat/S_ISUID.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_ISUID (04000) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IWGRP.c b/src/sys/stat/S_IWGRP.c new file mode 100644 index 00000000..c7a716e7 --- /dev/null +++ b/src/sys/stat/S_IWGRP.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_IWGRP (020) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IWOTH.c b/src/sys/stat/S_IWOTH.c new file mode 100644 index 00000000..26e75066 --- /dev/null +++ b/src/sys/stat/S_IWOTH.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_IWOTH (02) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IWUSR.c b/src/sys/stat/S_IWUSR.c new file mode 100644 index 00000000..e9af1829 --- /dev/null +++ b/src/sys/stat/S_IWUSR.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_IWUSR (0200) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IXGRP.c b/src/sys/stat/S_IXGRP.c new file mode 100644 index 00000000..34f44729 --- /dev/null +++ b/src/sys/stat/S_IXGRP.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_IXGRP (010) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IXOTH.c b/src/sys/stat/S_IXOTH.c new file mode 100644 index 00000000..10d51686 --- /dev/null +++ b/src/sys/stat/S_IXOTH.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_IXOTH (01) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/S_IXUSR.c b/src/sys/stat/S_IXUSR.c new file mode 100644 index 00000000..b4b8e494 --- /dev/null +++ b/src/sys/stat/S_IXUSR.c @@ -0,0 +1,5 @@ +#include <sys/stat.h> +#define S_IXUSR (0100) +/* +POSIX(1) +*/ diff --git a/src/sys/stat/chmod.c b/src/sys/stat/chmod.c new file mode 100644 index 00000000..f061e1a8 --- /dev/null +++ b/src/sys/stat/chmod.c @@ -0,0 +1,17 @@ +#include "sys/types.h" +#include <sys/stat.h> +#include "nonstd/syscall.h" + +int chmod(const char *path, mode_t mode) +{ + SCNO(scno, "chmod", -1); + int r = __libc.syscall(scno, path, mode); + if (r < 0) { + errno = -r; + return -1; + } + return 0; +} +/* +POSIX(1) +*/ diff --git a/src/sys/stat/fstat.c b/src/sys/stat/fstat.c new file mode 100644 index 00000000..bdd9f574 --- /dev/null +++ b/src/sys/stat/fstat.c @@ -0,0 +1,11 @@ +#include "sys/types.h" +#include <sys/stat.h> + +int fstat(int fildes, struct stat *buf) +{ + (void)fildes; (void)buf; + return 0; +} +/* +POSIX(1) +*/ diff --git a/src/sys/stat/mkdir.c b/src/sys/stat/mkdir.c new file mode 100644 index 00000000..7b3f510d --- /dev/null +++ b/src/sys/stat/mkdir.c @@ -0,0 +1,13 @@ +#include "sys/types.h" +#include <sys/stat.h> +#include "nonstd/syscall.h" + +int mkdir(const char *path, mode_t mode) +{ + (void)path; (void)mode; + return -1; +} + +/* +POSIX(1) +*/ diff --git a/src/sys/stat/mkfifo.c b/src/sys/stat/mkfifo.c new file mode 100644 index 00000000..2d475258 --- /dev/null +++ b/src/sys/stat/mkfifo.c @@ -0,0 +1,11 @@ +#include "sys/types.h" +#include <sys/stat.h> + +int mkfifo(const char *path, mode_t mode) +{ + (void)path; (void)mode; + return 0; +} +/* +POSIX(1) +*/ diff --git a/src/sys/stat/stat.c b/src/sys/stat/stat.c new file mode 100644 index 00000000..c5079295 --- /dev/null +++ b/src/sys/stat/stat.c @@ -0,0 +1,32 @@ +#include "sys/types.h" +#include <sys/stat.h> +#include "stdlib.h" +#include "nonstd/assert.h" + +int stat(const char * restrict path, struct stat * restrict buf) +{ + ASSERT_NONNULL(path); + ASSERT_NONNULL(buf); + + int ret = 0; + #if 0 + char *linkbuf = NULL; + + do { + ret = lstat(path, buf); + if (S_ISLNK(buf->st_mode)) { + linkbuf = realloc(linkbuf, buf->st_size + 1); + readlink(path, linkbuf, buf->st_size); + path = linkbuf; + } else { + path = NULL; + } + } while (path); + realloc(linkbuf, 0); + #endif + + return ret; +} +/* +POSIX(1) +*/ diff --git a/src/sys/stat/struct_stat.c b/src/sys/stat/struct_stat.c new file mode 100644 index 00000000..c825e561 --- /dev/null +++ b/src/sys/stat/struct_stat.c @@ -0,0 +1,23 @@ +#include <sys/stat.h> + +struct stat { + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + off_t st_size; + #if 0 + struct timespec st_atim; + struct timespec st_mtim; + struct timespec st_ctim; + blksize_t st_blksize; + blkcnt_t st_blocks; + #endif +}; + +/* +POSIX(1) +*/ diff --git a/src/sys/stat/umask.c b/src/sys/stat/umask.c new file mode 100644 index 00000000..ca038bad --- /dev/null +++ b/src/sys/stat/umask.c @@ -0,0 +1,11 @@ +#include "sys/types.h" +#include <sys/stat.h> + +mode_t umask(mode_t cmask) +{ + return cmask; +} + +/* +POSIX(1) +*/ diff --git a/src/sys/times/struct_tms.c b/src/sys/times/struct_tms.c new file mode 100644 index 00000000..8e70958b --- /dev/null +++ b/src/sys/times/struct_tms.c @@ -0,0 +1,12 @@ +#include <sys/times.h> + +struct tms { + clock_t tms_utime; + clock_t tms_stime; + clock_t tms_cutime; + clock_t tms_cstime; +}; + +/* +POSIX(1) +*/ diff --git a/src/sys/times/times.c b/src/sys/times/times.c new file mode 100644 index 00000000..753d66ae --- /dev/null +++ b/src/sys/times/times.c @@ -0,0 +1,11 @@ +#include "time.h" +#include <sys/times.h> + +clock_t times(struct tms *buffer) +{ + (void)buffer; + return (clock_t)-1; +} +/* +POSIX(1) +*/ diff --git a/src/sys/types/dev_t.c b/src/sys/types/dev_t.c new file mode 100644 index 00000000..5a98787f --- /dev/null +++ b/src/sys/types/dev_t.c @@ -0,0 +1,6 @@ +#include <sys/types.h> + +typedef unsigned long long int dev_t; +/* +POSIX(1) +*/ diff --git a/src/sys/types/gid_t.c b/src/sys/types/gid_t.c new file mode 100644 index 00000000..b62344a9 --- /dev/null +++ b/src/sys/types/gid_t.c @@ -0,0 +1,6 @@ +#include <sys/types.h> + +typedef unsigned long long int gid_t; +/* +POSIX(1) +*/ diff --git a/src/sys/types/ino_t.c b/src/sys/types/ino_t.c new file mode 100644 index 00000000..a563dd7b --- /dev/null +++ b/src/sys/types/ino_t.c @@ -0,0 +1,6 @@ +#include <sys/types.h> + +typedef unsigned long long int ino_t; +/* +POSIX(1) +*/ diff --git a/src/sys/types/mode_t.c b/src/sys/types/mode_t.c new file mode 100644 index 00000000..9b68ed05 --- /dev/null +++ b/src/sys/types/mode_t.c @@ -0,0 +1,6 @@ +#include <sys/types.h> + +typedef unsigned long int mode_t; +/* +POSIX(1) +*/ diff --git a/src/sys/types/nlink_t.c b/src/sys/types/nlink_t.c new file mode 100644 index 00000000..68eb4f84 --- /dev/null +++ b/src/sys/types/nlink_t.c @@ -0,0 +1,6 @@ +#include <sys/types.h> + +typedef unsigned long long int nlink_t; +/* +POSIX(1) +*/ diff --git a/src/sys/types/off_t.c b/src/sys/types/off_t.c new file mode 100644 index 00000000..f9056020 --- /dev/null +++ b/src/sys/types/off_t.c @@ -0,0 +1,6 @@ +#include <sys/types.h> + +typedef long long int off_t; +/* +POSIX(1) +*/ diff --git a/src/sys/types/pid_t.c b/src/sys/types/pid_t.c new file mode 100644 index 00000000..91307c09 --- /dev/null +++ b/src/sys/types/pid_t.c @@ -0,0 +1,6 @@ +#include <sys/types.h> + +typedef long int pid_t; +/* +POSIX(1) +*/ diff --git a/src/sys/types/ssize_t.c b/src/sys/types/ssize_t.c new file mode 100644 index 00000000..2bfdef89 --- /dev/null +++ b/src/sys/types/ssize_t.c @@ -0,0 +1,7 @@ +#include <sys/types.h> + +typedef long int ssize_t; + +/* +POSIX(1) +*/ diff --git a/src/sys/types/uid_t.c b/src/sys/types/uid_t.c new file mode 100644 index 00000000..ab37f521 --- /dev/null +++ b/src/sys/types/uid_t.c @@ -0,0 +1,6 @@ +#include <sys/types.h> + +typedef unsigned long long int uid_t; +/* +POSIX(1) +*/ diff --git a/src/sys/utsname/struct_utsname.c b/src/sys/utsname/struct_utsname.c new file mode 100644 index 00000000..4b100a7a --- /dev/null +++ b/src/sys/utsname/struct_utsname.c @@ -0,0 +1,13 @@ +#include <sys/utsname.h> + +struct utsname { + char sysname[100]; + char nodename[100]; + char release[100]; + char version[100]; + char machine[100]; +}; + +/* +POSIX(1) +*/ diff --git a/src/sys/utsname/uname.c b/src/sys/utsname/uname.c new file mode 100644 index 00000000..50b53e11 --- /dev/null +++ b/src/sys/utsname/uname.c @@ -0,0 +1,25 @@ +#include <sys/utsname.h> +#include "string.h" +#include "nonstd/assert.h" + +# define __PLATFORM__ "x86" + +int uname(struct utsname *name) +{ + ASSERT_NONNULL(name); + + strcpy(name->sysname, "UNG"); + #if 0 + gethostname(name->nodename, sizeof(name->nodename)); + #else + strcpy(name->sysname, "localhost"); + #endif + strcpy(name->release, "YYYY-MM-DD"); + strcpy(name->version, "MM.mm.pp"); + strcpy(name->machine, __PLATFORM__); + return 1; +} + +/* +POSIX(1) +*/ diff --git a/src/sys/wait/WEXITSTATUS.c b/src/sys/wait/WEXITSTATUS.c new file mode 100644 index 00000000..f0fcafc6 --- /dev/null +++ b/src/sys/wait/WEXITSTATUS.c @@ -0,0 +1,6 @@ +#include <sys/wait.h> + +#define WEXITSTATUS 1 +/* +POSIX(1) +*/ diff --git a/src/sys/wait/WIFEXITED.c b/src/sys/wait/WIFEXITED.c new file mode 100644 index 00000000..e0e32bcb --- /dev/null +++ b/src/sys/wait/WIFEXITED.c @@ -0,0 +1,6 @@ +#include <sys/wait.h> + +#define WIFEXITED 2 +/* +POSIX(1) +*/ diff --git a/src/sys/wait/WIFSIGNALED.c b/src/sys/wait/WIFSIGNALED.c new file mode 100644 index 00000000..cc99a98a --- /dev/null +++ b/src/sys/wait/WIFSIGNALED.c @@ -0,0 +1,6 @@ +#include <sys/wait.h> + +#define WIFSIGNALED 3 +/* +POSIX(1) +*/ diff --git a/src/sys/wait/WIFSTOPPED.c b/src/sys/wait/WIFSTOPPED.c new file mode 100644 index 00000000..3fb06d8c --- /dev/null +++ b/src/sys/wait/WIFSTOPPED.c @@ -0,0 +1,6 @@ +#include <sys/wait.h> + +#define WIFSTOPPED 4 +/* +POSIX(1) +*/ diff --git a/src/sys/wait/WNOHANG.c b/src/sys/wait/WNOHANG.c new file mode 100644 index 00000000..1c28008b --- /dev/null +++ b/src/sys/wait/WNOHANG.c @@ -0,0 +1,6 @@ +#include <sys/wait.h> + +#define WNOHANG 5 +/* +POSIX(1) +*/ diff --git a/src/sys/wait/WSTOPSIG.c b/src/sys/wait/WSTOPSIG.c new file mode 100644 index 00000000..721179c8 --- /dev/null +++ b/src/sys/wait/WSTOPSIG.c @@ -0,0 +1,6 @@ +#include <sys/wait.h> + +#define WSTOPSIG 6 +/* +POSIX(1) +*/ diff --git a/src/sys/wait/WTERMSIG.c b/src/sys/wait/WTERMSIG.c new file mode 100644 index 00000000..6d47fea2 --- /dev/null +++ b/src/sys/wait/WTERMSIG.c @@ -0,0 +1,6 @@ +#include <sys/wait.h> + +#define WTERMSIG 7 +/* +POSIX(1) +*/ diff --git a/src/sys/wait/WUNTRACED.c b/src/sys/wait/WUNTRACED.c new file mode 100644 index 00000000..d082bef5 --- /dev/null +++ b/src/sys/wait/WUNTRACED.c @@ -0,0 +1,6 @@ +#include <sys/wait.h> + +#define WUNTRACED 8 +/* +POSIX(1) +*/ diff --git a/src/sys/wait/wait.c b/src/sys/wait/wait.c new file mode 100644 index 00000000..be1799fe --- /dev/null +++ b/src/sys/wait/wait.c @@ -0,0 +1,10 @@ +#include "sys/types.h" +#include <sys/wait.h> + +pid_t wait(int *stat_loc) +{ + return waitpid((pid_t)-1, stat_loc, 0); +} +/* +POSIX(1) +*/ diff --git a/src/sys/wait/waitpid.c b/src/sys/wait/waitpid.c new file mode 100644 index 00000000..ef196cc1 --- /dev/null +++ b/src/sys/wait/waitpid.c @@ -0,0 +1,11 @@ +#include "sys/types.h" +#include <sys/wait.h> + +pid_t waitpid(pid_t pid, int *stat_loc, int options) +{ + (void)pid; (void)stat_loc; (void)options; + return 0; +} +/* +POSIX(1) +*/ |
