From 8e2385801d189356c0c818c5a9b15f449619ecaa Mon Sep 17 00:00:00 2001 From: Francisco Javier Trujillo Mata Date: Tue, 23 Jan 2024 22:47:54 +0100 Subject: [PATCH 1/2] Fix getentropy after newlib upgrade --- src/libcglue/Makefile.am | 2 +- src/libcglue/glue.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcglue/Makefile.am b/src/libcglue/Makefile.am index c65bb52f79..b7e271e6e1 100755 --- a/src/libcglue/Makefile.am +++ b/src/libcglue/Makefile.am @@ -27,7 +27,7 @@ FDMAN_OBJS = __descriptor_data_pool.o __descriptormap.o __fdman_init.o __fdman_g GLUE_OBJS = __dummy_passwd.o __psp_heap_blockid.o __psp_free_heap.o _fork.o _wait.o _open.o _close.o _read.o \ _write.o _fstat.o _stat.o lstat.o access.o _fcntl.o _lseek.o chdir.o mkdir.o rmdir.o getdents.o _link.o _unlink.o \ _rename.o _getpid.o _kill.o _sbrk.o _gettimeofday.o _times.o ftime.o clock_getres.o clock_gettime.o clock_settime.o \ - _isatty.o symlink.o truncate.o chmod.o fchmod.o fchmodat.o pathconf.o readlink.o utime.o fchown.o getentropy.o getpwuid.o \ + _isatty.o symlink.o truncate.o chmod.o fchmod.o fchmodat.o pathconf.o readlink.o utime.o fchown.o _getentropy.o getpwuid.o \ fsync.o getpwnam.o getuid.o geteuid.o basename.o statvfs.o INIT_OBJS = __libpthreadglue_init.o __libcglue_init.o __libcglue_deinit.o _exit.o abort.o exit.o diff --git a/src/libcglue/glue.c b/src/libcglue/glue.c index 3e1ccc5f1b..3f55b99bbd 100755 --- a/src/libcglue/glue.c +++ b/src/libcglue/glue.c @@ -956,8 +956,8 @@ int fchown(int fd, uid_t owner, gid_t group) } #endif -#ifdef F_getentropy -int getentropy(void *buffer, size_t length) { +#ifdef F__getentropy +int _getentropy(void *buffer, size_t length) { size_t i; SceKernelUtilsMt19937Context ctx; sceKernelUtilsMt19937Init(&ctx, time(NULL)); From 26dd2a97f9806eaf20874a6a8ea34ed4a6450b63 Mon Sep 17 00:00:00 2001 From: Francisco Javier Trujillo Mata Date: Wed, 24 Jan 2024 11:05:16 +0100 Subject: [PATCH 2/2] Adding ATFILE glue functions --- src/libcglue/Makefile.am | 5 +- src/libcglue/glue.c | 113 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 109 insertions(+), 9 deletions(-) diff --git a/src/libcglue/Makefile.am b/src/libcglue/Makefile.am index b7e271e6e1..2495ae0247 100755 --- a/src/libcglue/Makefile.am +++ b/src/libcglue/Makefile.am @@ -27,8 +27,9 @@ FDMAN_OBJS = __descriptor_data_pool.o __descriptormap.o __fdman_init.o __fdman_g GLUE_OBJS = __dummy_passwd.o __psp_heap_blockid.o __psp_free_heap.o _fork.o _wait.o _open.o _close.o _read.o \ _write.o _fstat.o _stat.o lstat.o access.o _fcntl.o _lseek.o chdir.o mkdir.o rmdir.o getdents.o _link.o _unlink.o \ _rename.o _getpid.o _kill.o _sbrk.o _gettimeofday.o _times.o ftime.o clock_getres.o clock_gettime.o clock_settime.o \ - _isatty.o symlink.o truncate.o chmod.o fchmod.o fchmodat.o pathconf.o readlink.o utime.o fchown.o _getentropy.o getpwuid.o \ - fsync.o getpwnam.o getuid.o geteuid.o basename.o statvfs.o + _isatty.o symlink.o truncate.o chmod.o fchmod.o pathconf.o readlink.o utime.o fchown.o _getentropy.o getpwuid.o \ + fsync.o getpwnam.o getuid.o geteuid.o basename.o statvfs.o \ + openat.o renameat.o fchmodat.o fstatat.o mkdirat.o faccessat.o fchownat.o linkat.o readlinkat.o unlinkat.o INIT_OBJS = __libpthreadglue_init.o __libcglue_init.o __libcglue_deinit.o _exit.o abort.o exit.o diff --git a/src/libcglue/glue.c b/src/libcglue/glue.c index 3f55b99bbd..0f2a7f7ac2 100755 --- a/src/libcglue/glue.c +++ b/src/libcglue/glue.c @@ -886,13 +886,6 @@ int fchmod(int fd, mode_t mode) } #endif -#ifdef F_fchmodat -int fchmodat(int fd, const char *path, mode_t mode, int flag) -{ - return chmod(path, mode); -} -#endif - #ifdef F_pathconf long int pathconf(const char *path, int name) { errno = ENOSYS; @@ -1058,3 +1051,109 @@ int statvfs (const char *__path, struct statvfs *__buf) __buf->f_namemax = MAXNAMLEN; } #endif /* F_statvfs */ + +/* ATFILE functions */ + +#ifdef F_openat +int openat(int dirfd, const char *pathname, int flags, ...) +{ + // TODO: Do better implementation following https://linux.die.net/man/2/openat + // for now use the same as open + + // Extract mode from variable arguments + va_list args; + va_start(args, flags); + + // Get the mode argument + int mode = va_arg(args, int); + + // Clean up the va_list + va_end(args); + return _open(pathname, flags, mode); +} +#endif /* F_openat */ + +#ifdef F_renameat +int renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath) +{ + // TODO: Do better implementation following https://linux.die.net/man/2/renameat + // for now use the same as rename + return _rename(oldpath, newpath); +} +#endif /* F_renameat */ + +#ifdef F_fchmodat +int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags) +{ + // TODO: Do better implementation following https://linux.die.net/man/2/fchmodat + // for now use the same as chmod + return chmod(pathname, mode); +} +#endif /* F_fchmodat */ + +#ifdef F_fstatat +int fstatat(int dirfd, const char *pathname, struct stat *buf, int flags) +{ + // TODO: Do better implementation following https://linux.die.net/man/2/fstatat + // for now use the same as stat + return _stat(pathname, buf); +} +#endif /* F_fstatat */ + +#ifdef F_mkdirat +int mkdirat(int dirfd, const char *pathname, mode_t mode) +{ + // TODO: Do better implementation following https://linux.die.net/man/2/mkdirat + // for now use the same as mkdir + return mkdir(pathname, mode); +} +#endif /* F_mkdirat */ + +#ifdef F_faccessat +int faccessat(int dirfd, const char *pathname, int mode, int flags) +{ + // TODO: Do better implementation following https://linux.die.net/man/2/faccessat + // for now use the same as access + return access(pathname, mode); +} +#endif /* F_faccessat */ + +#ifdef F_fchownat +int fchownat(int dirfd, const char *pathname, uid_t owner, gid_t group, int flags) +{ + // TODO: Do better implementation following https://linux.die.net/man/2/fchownat + // for now use the same as chown + return chown(pathname, owner, group); +} +#endif /* F_fchownat */ + +#ifdef F_linkat +int linkat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags) { + // TODO: Do better implementation following https://linux.die.net/man/2/linkat + // for now use the same as link + return link(oldpath, newpath); +} +#endif /* F_linkat */ + +#ifdef F_readlinkat +int readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz) +{ + // TODO: Do better implementation following https://linux.die.net/man/2/linkat + // for now use the same as readlink + return readlink(pathname, buf, bufsiz); +} +#endif /* F_readlinkat */ + +#ifdef F_unlinkat +int unlinkat(int dirfd, const char *pathname, int flags) +{ + // If flags contains AT_REMOVEDIR, then the path refers to a directory. + // Otherwise, the path refers to a file. + if (flags & AT_REMOVEDIR) { + return rmdir(pathname); + } + else { + return unlink(pathname); + } +} +#endif /* F_unlinkat */