Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ps3dev/PSL1GHT/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The filesystem API provides functions for file and directory operations on the PlayStation 3. It includes both low-level LV2 syscalls and higher-level wrapper functions.

File Operations

sysFsOpen

Open a file.
s32 sysFsOpen(const char *path, s32 oflags, s32 *fd,
              const void *arg, u64 argsize);
path
const char*
required
File path (e.g., /dev_hdd0/game/data.bin)
oflags
s32
required
Open flags (OR combination):
  • SYS_O_RDONLY - Read only
  • SYS_O_WRONLY - Write only
  • SYS_O_RDWR - Read and write
  • SYS_O_CREAT - Create if doesn’t exist
  • SYS_O_TRUNC - Truncate to zero length
  • SYS_O_APPEND - Append mode
fd
s32*
required
Pointer to storage for file descriptor
arg
const void*
Optional argument (usually NULL)
argsize
u64
Size of optional argument (usually 0)
return
s32
Zero on success, error code otherwise
Example:
s32 fd;
s32 ret = sysFsOpen("/dev_hdd0/game/data.bin",
                    SYS_O_RDWR | SYS_O_CREAT,
                    &fd, NULL, 0);
if (ret == 0) {
    // Use file descriptor
    sysFsClose(fd);
}

sysFsClose

Close a file.
s32 sysFsClose(s32 fd);
fd
s32
required
File descriptor from sysFsOpen
return
s32
Zero on success, error code otherwise

sysFsRead

Read from a file.
s32 sysFsRead(s32 fd, void *ptr, u64 len, u64 *read);
fd
s32
required
File descriptor
ptr
void*
required
Buffer to read into
len
u64
required
Number of bytes to read
read
u64*
required
Pointer to storage for actual bytes read
return
s32
Zero on success, error code otherwise
Example:
char buffer[1024];
u64 bytes_read;

s32 ret = sysFsRead(fd, buffer, sizeof(buffer), &bytes_read);
if (ret == 0) {
    printf("Read %llu bytes\n", bytes_read);
}

sysFsWrite

Write to a file.
s32 sysFsWrite(s32 fd, const void *ptr, u64 size, u64 *written);
fd
s32
required
File descriptor
ptr
const void*
required
Buffer to write from
size
u64
required
Number of bytes to write
written
u64*
required
Pointer to storage for actual bytes written
return
s32
Zero on success, error code otherwise

sysFsLseek

Seek to a position in a file.
s32 sysFsLseek(s32 fd, s64 offset, s32 whence, u64 *position);
fd
s32
required
File descriptor
offset
s64
required
Offset in bytes
whence
s32
required
Seek origin: SEEK_SET, SEEK_CUR, or SEEK_END
position
u64*
Pointer to storage for new file position
return
s32
Zero on success, error code otherwise

sysFsFsync

Flush file buffers to disk.
s32 sysFsFsync(s32 fd);
fd
s32
required
File descriptor
return
s32
Zero on success, error code otherwise

File Information

sysFsStat

Get file information by path.
s32 sysFsStat(const char *path, sysFSStat *stat);
path
const char*
required
File path
stat
sysFSStat*
required
Pointer to stat structure to fill
return
s32
Zero on success, error code otherwise
Example:
sysFSStat stat;
s32 ret = sysFsStat("/dev_hdd0/game/data.bin", &stat);
if (ret == 0) {
    printf("File size: %llu bytes\n", stat.st_size);
    printf("Mode: 0x%x\n", stat.st_mode);
}

sysFsFstat

Get file information by descriptor.
s32 sysFsFstat(s32 fd, sysFSStat *stat);
fd
s32
required
File descriptor
stat
sysFSStat*
required
Pointer to stat structure to fill
return
s32
Zero on success, error code otherwise

File Manipulation

Delete a file.
s32 sysFsUnlink(const char *path);
path
const char*
required
Path to file to delete
return
s32
Zero on success, error code otherwise

sysFsChmod

Change file permissions.
s32 sysFsChmod(const char *path, s32 mode);
path
const char*
required
File path
mode
s32
required
New permission mode
return
s32
Zero on success, error code otherwise

Directory Operations

sysFsMkdir

Create a directory.
s32 sysFsMkdir(const char *path, s32 mode);
path
const char*
required
Directory path to create
mode
s32
required
Directory permissions
return
s32
Zero on success, error code otherwise

sysFsRmdir

Remove an empty directory.
s32 sysFsRmdir(const char *path);
path
const char*
required
Directory path to remove
return
s32
Zero on success, error code otherwise

sysFsOpendir

Open a directory for reading.
s32 sysFsOpendir(const char *path, s32 *fd);
path
const char*
required
Directory path
fd
s32*
required
Pointer to storage for directory descriptor
return
s32
Zero on success, error code otherwise
Example:
s32 fd;
s32 ret = sysFsOpendir("/dev_hdd0/game", &fd);
if (ret == 0) {
    sysFSDirent entry;
    u64 read;
    
    while (sysFsReaddir(fd, &entry, &read) == 0 && read > 0) {
        printf("%s\n", entry.d_name);
    }
    
    sysFsClosedir(fd);
}

sysFsReaddir

Read a directory entry.
s32 sysFsReaddir(s32 fd, sysFSDirent *entry, u64 *read);
fd
s32
required
Directory descriptor from sysFsOpendir
entry
sysFSDirent*
required
Pointer to directory entry structure to fill
read
u64*
required
Pointer to storage for read status (0 = end of directory)
return
s32
Zero on success, error code otherwise

sysFsClosedir

Close a directory.
s32 sysFsClosedir(s32 fd);
fd
s32
required
Directory descriptor
return
s32
Zero on success, error code otherwise

Data Structures

sysFSStat

File status information.
typedef struct _sys_fs_stat {
    s32 st_mode;      // File mode/permissions
    s32 st_uid;       // User ID
    s32 st_gid;       // Group ID
    time_t st_atime;  // Access time
    time_t st_mtime;  // Modification time
    time_t st_ctime;  // Creation time
    u64 st_size;      // File size in bytes
    u64 st_blksize;   // Block size
} sysFSStat;

sysFSDirent

Directory entry.
typedef struct _sys_fs_dirent {
    u8 d_type;                  // Entry type
    u8 d_namlen;                // Name length
    char d_name[MAXPATHLEN + 1]; // Entry name
} sysFSDirent;

Constants

Open Flags

  • SYS_O_RDONLY (000000) - Read only
  • SYS_O_WRONLY (000001) - Write only
  • SYS_O_RDWR (000002) - Read and write
  • SYS_O_CREAT (000100) - Create file if it doesn’t exist
  • SYS_O_EXCL (000200) - Exclusive create (fail if exists)
  • SYS_O_TRUNC (001000) - Truncate to zero length
  • SYS_O_APPEND (002000) - Append mode
  • SYS_O_MSELF (010000) - MSELF file

Low-Level LV2 Functions

The following functions provide direct access to LV2 syscalls:
  • sysLv2FsOpen() - Syscall 801
  • sysLv2FsRead() - Syscall 802
  • sysLv2FsWrite() - Syscall 803
  • sysLv2FsClose() - Syscall 804
  • sysLv2FsOpenDir() - Syscall 805
  • sysLv2FsReadDir() - Syscall 806
  • sysLv2FsCloseDir() - Syscall 807
  • sysLv2FsStat() - Syscall 808
  • sysLv2FsFStat() - Syscall 809
  • sysLv2FsMkdir() - Syscall 811
  • sysLv2FsRename() - Syscall 812
  • sysLv2FsRmdir() - Syscall 813
  • sysLv2FsUnlink() - Syscall 814

Header Files

#include <sys/file.h>   // File I/O functions (LV2 syscalls)
#include <lv2/sysfs.h>  // Filesystem types and wrapper functions

Build docs developers (and LLMs) love