Merge pull request #156 from bucanero/patch-1

Add statvfs() based on sceIoDevctl()
This commit is contained in:
Wouter Wijsman
2023-10-03 22:59:31 +02:00
committed by GitHub
2 changed files with 22 additions and 1 deletions

View File

@@ -28,7 +28,7 @@ GLUE_OBJS = __dummy_passwd.o __fill_stat.o __psp_heap_blockid.o __psp_free_heap.
_write.o _fstat.o _stat.o lstat.o access.o _fcntl.o _lseek.o chdir.o mkdir.o rmdir.o getdents.o _seekdir.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
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

View File

@@ -30,6 +30,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/statvfs.h>
#include <psptypes.h>
#include <pspiofilemgr.h>
@@ -1027,3 +1028,23 @@ char* basename (char *path)
return p + 1;
}
#endif /* F_basename */
#ifdef F_statvfs
int statvfs (const char *__path, struct statvfs *__buf)
{
SceDevInf inf;
SceDevctlCmd cmd;
cmd.dev_inf = &inf;
memset(&inf, 0, sizeof(SceDevInf));
sceIoDevctl(__path, SCE_PR_GETDEV, &cmd, sizeof(SceDevctlCmd), NULL, 0);
memset(__buf, 0, sizeof(struct statvfs));
__buf->f_bsize = (inf.sectorSize * inf.sectorCount);
__buf->f_frsize = (inf.sectorSize * inf.sectorCount);
__buf->f_blocks = inf.maxClusters;
__buf->f_bfree = inf.freeClusters;
__buf->f_bavail = inf.freeClusters;
__buf->f_namemax = MAXNAMLEN;
}
#endif /* F_statvfs */