Overview
Filesystem operations are provided through two header files:sys/file.h- Low-level syscall wrapperslv2/sysfs.h- High-level filesystem functions and data structures
Storage Mount Points
The PS3 filesystem uses specific mount points for different storage devices:/dev_hdd1 is reserved for system use only and should not be accessed by applications.File Operations
Opening Files
Files are opened usingsysFsOpen() with various flags to control access mode.
Full path to the file to open
Open flags controlling access mode and behavior
Pointer to receive the file descriptor
Additional arguments (usually NULL)
Size of additional arguments (usually 0)
Returns 0 on success, non-zero error code on failure
Open Flags
Access Mode Flags
Access Mode Flags
| Flag | Value | Description |
|---|---|---|
SYS_O_RDONLY | 0 | Open for reading only |
SYS_O_WRONLY | 1 | Open for writing only |
SYS_O_RDWR | 2 | Open for reading and writing |
SYS_O_ACCMODE | 3 | Access mode mask |
Creation and Behavior Flags
Creation and Behavior Flags
| Flag | Description |
|---|---|
SYS_O_CREAT | Create file if it doesn’t exist |
SYS_O_EXCL | Fail if file already exists (use with CREAT) |
SYS_O_TRUNC | Truncate file to zero length |
SYS_O_APPEND | Append to end of file |
SYS_O_MSELF | Open as MSELF encrypted file |
Reading and Writing
Seeking
SEEK_SET- Offset from beginning of fileSEEK_CUR- Offset from current positionSEEK_END- Offset from end of file
Closing Files
File Information
File Statistics
Directory Operations
Opening and Reading Directories
Creating and Removing Directories
File Management
Deleting Files
Renaming Files
File Permissions
File Truncation
Advanced Features
Asynchronous I/O
PSL1GHT supports asynchronous file operations for non-blocking I/O.I/O Buffering
Free Space Information
Complete Example
Error Handling
All filesystem functions return 0 on success and a negative error code on failure. Common error codes are defined insys/lv2errno.h.
Best Practices
Always Close Files
Always close file descriptors when done to prevent resource leaks.
Check Return Values
Verify all filesystem operations succeed before continuing.
Use Full Paths
Always use absolute paths starting with a mount point like
/dev_hdd0.Flush Critical Data
Use
sysLv2FsFsync() to ensure important data is written to disk.See Also
- Memory Management - Memory allocation for file buffers
- Threads - Thread-safe file access
- Processes - Process-level filesystem operations