mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-05-28 15:34:31 +00:00
feat(userspace/libc): implement brk(), chdir() and getcwd()
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
parent
36bb7b7a88
commit
7087ce7ec5
@ -66,5 +66,9 @@ int sysdep(LStat)(const char *Pathname, struct stat *Statbuf);
|
|||||||
int sysdep(Truncate)(const char *Pathname, off_t Length);
|
int sysdep(Truncate)(const char *Pathname, off_t Length);
|
||||||
int sysdep(MakeDirectory)(const char *Pathname, mode_t Mode);
|
int sysdep(MakeDirectory)(const char *Pathname, mode_t Mode);
|
||||||
int sysdep(ProcessControl)(unsigned long Option, unsigned long Arg1, unsigned long Arg2, unsigned long Arg3, unsigned long Arg4);
|
int sysdep(ProcessControl)(unsigned long Option, unsigned long Arg1, unsigned long Arg2, unsigned long Arg3, unsigned long Arg4);
|
||||||
|
int sysdep(ChangeDirectory)(const char *Pathname);
|
||||||
|
char *sysdep(GetWorkingDirectory)(char *Buffer, size_t Size);
|
||||||
|
int sysdep(Brk)(void *Address);
|
||||||
|
int sysdep(FileControl)(int Descriptor, int Command, void *Arg);
|
||||||
|
|
||||||
#endif // FENNIX_BITS_LIBC_H
|
#endif // FENNIX_BITS_LIBC_H
|
||||||
|
@ -61,8 +61,8 @@ extern "C"
|
|||||||
|
|
||||||
int access(const char *path, int amode);
|
int access(const char *path, int amode);
|
||||||
unsigned int alarm(unsigned int seconds);
|
unsigned int alarm(unsigned int seconds);
|
||||||
int brk(void *);
|
int brk(void *addr);
|
||||||
int chdir(const char *);
|
int chdir(const char *path);
|
||||||
int chroot(const char *);
|
int chroot(const char *);
|
||||||
int chown(const char *, uid_t, gid_t);
|
int chown(const char *, uid_t, gid_t);
|
||||||
int close(int fildes);
|
int close(int fildes);
|
||||||
@ -87,7 +87,7 @@ extern "C"
|
|||||||
long int fpathconf(int, int);
|
long int fpathconf(int, int);
|
||||||
int fsync(int);
|
int fsync(int);
|
||||||
int ftruncate(int, off_t);
|
int ftruncate(int, off_t);
|
||||||
char *getcwd(char *, size_t);
|
char *getcwd(char *buf, size_t size);
|
||||||
int getdtablesize(void);
|
int getdtablesize(void);
|
||||||
gid_t getegid(void);
|
gid_t getegid(void);
|
||||||
uid_t geteuid(void);
|
uid_t geteuid(void);
|
||||||
@ -122,7 +122,7 @@ extern "C"
|
|||||||
ssize_t read(int fildes, void *buf, size_t nbyte);
|
ssize_t read(int fildes, void *buf, size_t nbyte);
|
||||||
int readlink(const char *, char *, size_t);
|
int readlink(const char *, char *, size_t);
|
||||||
int rmdir(const char *);
|
int rmdir(const char *);
|
||||||
void *sbrk(intptr_t);
|
void *sbrk(intptr_t incr);
|
||||||
int setgid(gid_t);
|
int setgid(gid_t);
|
||||||
int setpgid(pid_t, pid_t);
|
int setpgid(pid_t, pid_t);
|
||||||
pid_t setpgrp(void);
|
pid_t setpgrp(void);
|
||||||
|
@ -25,7 +25,14 @@
|
|||||||
|
|
||||||
export int creat(const char *path, mode_t mode) { return open(path, O_WRONLY | O_CREAT | O_TRUNC, mode); }
|
export int creat(const char *path, mode_t mode) { return open(path, O_WRONLY | O_CREAT | O_TRUNC, mode); }
|
||||||
|
|
||||||
export int fcntl(int fildes, int cmd, ...);
|
export int fcntl(int fildes, int cmd, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, cmd);
|
||||||
|
void *arg = va_arg(args, void *);
|
||||||
|
va_end(args);
|
||||||
|
return __check_errno(sysdep(FileControl)(fildes, cmd, arg), -1);
|
||||||
|
}
|
||||||
|
|
||||||
export int open(const char *path, int oflag, ...)
|
export int open(const char *path, int oflag, ...)
|
||||||
{
|
{
|
||||||
|
@ -40,8 +40,16 @@ export unsigned int alarm(unsigned int seconds)
|
|||||||
return __check_errno(-ENOSYS, -1);
|
return __check_errno(-ENOSYS, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export int brk(void *);
|
export int brk(void *addr)
|
||||||
export int chdir(const char *);
|
{
|
||||||
|
return __check_errno(sysdep(Brk)(addr), -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
export int chdir(const char *path)
|
||||||
|
{
|
||||||
|
return __check_errno(sysdep(ChangeDirectory)(path), -1);
|
||||||
|
}
|
||||||
|
|
||||||
export int chroot(const char *);
|
export int chroot(const char *);
|
||||||
export int chown(const char *, uid_t, gid_t);
|
export int chown(const char *, uid_t, gid_t);
|
||||||
|
|
||||||
@ -176,7 +184,12 @@ export pid_t fork(void)
|
|||||||
export long int fpathconf(int, int);
|
export long int fpathconf(int, int);
|
||||||
export int fsync(int);
|
export int fsync(int);
|
||||||
export int ftruncate(int, off_t);
|
export int ftruncate(int, off_t);
|
||||||
export char *getcwd(char *, size_t);
|
|
||||||
|
export char *getcwd(char *buf, size_t size)
|
||||||
|
{
|
||||||
|
return (char *)__check_errno((__iptr)sysdep(GetWorkingDirectory)(buf, size), (__iptr)NULL);
|
||||||
|
}
|
||||||
|
|
||||||
export int getdtablesize(void);
|
export int getdtablesize(void);
|
||||||
export gid_t getegid(void);
|
export gid_t getegid(void);
|
||||||
export uid_t geteuid(void);
|
export uid_t geteuid(void);
|
||||||
@ -281,7 +294,7 @@ export ssize_t read(int fildes, void *buf, size_t nbyte)
|
|||||||
|
|
||||||
export int readlink(const char *, char *, size_t);
|
export int readlink(const char *, char *, size_t);
|
||||||
export int rmdir(const char *);
|
export int rmdir(const char *);
|
||||||
export void *sbrk(intptr_t);
|
export void *sbrk(intptr_t incr);
|
||||||
export int setgid(gid_t);
|
export int setgid(gid_t);
|
||||||
export int setpgid(pid_t, pid_t);
|
export int setpgid(pid_t, pid_t);
|
||||||
export pid_t setpgrp(void);
|
export pid_t setpgrp(void);
|
||||||
|
@ -189,3 +189,23 @@ int sysdep(ProcessControl)(unsigned long Option, unsigned long Arg1, unsigned lo
|
|||||||
{
|
{
|
||||||
return call_prctl(Option, Arg1, Arg2, Arg3, Arg4);
|
return call_prctl(Option, Arg1, Arg2, Arg3, Arg4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int sysdep(ChangeDirectory)(const char *Pathname)
|
||||||
|
{
|
||||||
|
return call_chdir(Pathname);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *sysdep(GetWorkingDirectory)(char *Buffer, size_t Size)
|
||||||
|
{
|
||||||
|
return (char *)call_getcwd(Buffer, Size);
|
||||||
|
}
|
||||||
|
|
||||||
|
int sysdep(Brk)(void *Address)
|
||||||
|
{
|
||||||
|
return call_brk(Address);
|
||||||
|
}
|
||||||
|
|
||||||
|
int sysdep(FileControl)(int Descriptor, int Command, void *Arg)
|
||||||
|
{
|
||||||
|
return call_fcntl(Descriptor, Command, Arg);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user