Skip to content

Commit

Permalink
Merge pull request #156 from bucanero/patch-1
Browse files Browse the repository at this point in the history
Add statvfs() based on sceIoDevctl()
  • Loading branch information
sharkwouter authored Oct 3, 2023
2 parents bbc04c3 + b092fb9 commit 9bd4db5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/libcglue/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 21 additions & 0 deletions src/libcglue/glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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 */

0 comments on commit 9bd4db5

Please sign in to comment.