diff --git a/lib/libc/include/fcntl.h b/lib/libc/include/fcntl.h index d590e14..4500a26 100644 --- a/lib/libc/include/fcntl.h +++ b/lib/libc/include/fcntl.h @@ -1,6 +1,8 @@ #ifndef FCNTL_H_ #define FCNTL_H_ +#include + #define O_RDONLY 0x0000 /* open for reading only */ #define O_WRONLY 0x0001 /* open for writing only */ #define O_RDWR 0x0002 /* open for reading and writing */ @@ -50,4 +52,47 @@ #define AT_SYMLINK_NOFOLLOW_ANY \ 0x0800 /* Path should not contain any symlinks */ +#define S_IRWXU 00700 +#define S_IRUSR 00400 +#define S_IWUSR 00200 +#define S_IXUSR 00100 +#define S_IRWXG 00070 +#define S_IRGRP 00040 +#define S_IWGRP 00020 +#define S_IXGRP 00010 +#define S_IRWXO 00007 +#define S_IROTH 00004 +#define S_IWOTH 00002 +#define S_IXOTH 00001 +#define S_ISUID 0004000 +#define S_ISGID 0002000 +#define S_ISVTX 0001000 + +#define R_OK 4 +#define W_OK 2 +#define X_OK 1 +#define F_OK 0 + +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_SETLKW 7 + +struct flock { + short l_type; + short l_whence; + off_t l_start; + off_t l_len; + pid_t l_pid; +}; + +struct flock64 { + short l_type; + short l_whence; + off_t l_start; + off_t l_len; + pid_t l_pid; +}; + +extern int fcntl(int fd, int op, ...); + #endif diff --git a/lib/libc/include/stdio.h b/lib/libc/include/stdio.h index ff34c51..f1a33ae 100644 --- a/lib/libc/include/stdio.h +++ b/lib/libc/include/stdio.h @@ -26,6 +26,7 @@ extern int printf(const char *format, ...); extern int vprintf(const char *format, va_list arg); extern int fprintf(FILE *stream, const char *format, ...); extern int vfprintf(FILE *stream, const char *format, va_list arg); +extern int sprintf(char *buffer, const char *format, ...); extern int snprintf(char *buffer, size_t count, const char *format, ...); extern int vsnprintf( char *buffer, @@ -34,6 +35,8 @@ extern int vsnprintf( va_list va); extern FILE *fopen(const char *path, const char *mode); +extern FILE *fdopen(int fildes, const char *mode); + extern int fclose(FILE *stream); extern int feof(FILE *stream); @@ -60,6 +63,7 @@ extern int fputs(const char *restrict str, FILE *restrict stream); extern long ftell(FILE *stream); extern int fseek(FILE *stream, long offset, int origin); +extern int fflush(FILE *stream); extern int sscanf( const char *restrict buffer, diff --git a/lib/libc/include/stdlib.h b/lib/libc/include/stdlib.h index bef2fae..fc53007 100644 --- a/lib/libc/include/stdlib.h +++ b/lib/libc/include/stdlib.h @@ -8,6 +8,11 @@ extern void abort(void); extern void exit(int result); extern int atexit(void (*func)(void)); +extern int abs(int v); +extern int atoi(const char *str); + +extern char *getenv(const char *name); + extern void *malloc(size_t count); extern void *calloc(size_t count, size_t size); extern void *realloc(void *p, size_t count); diff --git a/lib/libc/include/string.h b/lib/libc/include/string.h index 4951bc2..50189c4 100644 --- a/lib/libc/include/string.h +++ b/lib/libc/include/string.h @@ -10,6 +10,7 @@ extern size_t strlen(const char *s); extern size_t strcspn(const char *dest, const char *src); +extern char *strcat(char *dest, const char *src); extern char *strchr(const char *str, int c); extern char *strrchr(const char *str, int ch); diff --git a/lib/libc/include/sys/stat.h b/lib/libc/include/sys/stat.h new file mode 100644 index 0000000..7c6e73c --- /dev/null +++ b/lib/libc/include/sys/stat.h @@ -0,0 +1,8 @@ +#ifndef SYS_STAT_H_ +#define SYS_STAT_H_ + +#include + +extern int mkdir(const char *path, mode_t mode); + +#endif diff --git a/lib/libc/include/sys/types.h b/lib/libc/include/sys/types.h index 72577d9..6630974 100644 --- a/lib/libc/include/sys/types.h +++ b/lib/libc/include/sys/types.h @@ -8,7 +8,7 @@ #define SEEK_END 2 typedef size_t ino_t; -typedef long pid_t; +typedef int pid_t; typedef long mode_t; struct dentry { diff --git a/lib/libc/include/unistd.h b/lib/libc/include/unistd.h index 269b71c..8e69a41 100644 --- a/lib/libc/include/unistd.h +++ b/lib/libc/include/unistd.h @@ -4,12 +4,14 @@ #include #include -extern int open(const char *path, int flags); +extern int open(const char *path, int flags, ...); extern int close(int fd); extern int read(int fd, void *buf, size_t count); extern int write(int fd, const void *buf, size_t count); +extern int access(const char *path, int mode); + extern off_t lseek(int fd, off_t offset, int whence); extern long getdents(int fd, struct dentry *dirp, unsigned int count); @@ -20,7 +22,11 @@ extern int execl(const char *path, const char *arg, ...); extern int execlp(const char *file, const char *arg, ...); extern int execle(const char *path, const char *arg, ...); extern int execv(const char *path, char *const argv[]); +extern int execve(const char *path, char *const argv[], char *const envp[]); extern int execvp(const char *file, char *const argv[]); extern int execvpe(const char *file, char *const argv[], char *const envp[]); +extern pid_t getpid(void); +extern pid_t getppid(void); + #endif