KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
fs.h File Reference

Virtual filesystem support. More...

#include <sys/cdefs.h>
#include <sys/types.h>
#include <kos/limits.h>
#include <kos/opts.h>
#include <time.h>
#include <sys/queue.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <kos/nmmgr.h>
#include <sys/fcntl.h>

Go to the source code of this file.

Data Structures

struct  dirent_t
 Directory entry. More...
 
struct  vfs_handler_t
 VFS handler interface. More...
 

Macros

#define STAT_UNIQUE_NONE   0
 stat_t.unique: Constant to use denoting file has no unique ID
 
#define STAT_TYPE_NONE   0
 stat_t.type: Unknown / undefined / not relevant
 
#define STAT_TYPE_FILE   1
 stat_t.type: Standard file
 
#define STAT_TYPE_DIR   2
 stat_t.type: Standard directory
 
#define STAT_TYPE_PIPE   3
 stat_t.type: A virtual device of some sort (pipe, socket, etc)
 
#define STAT_TYPE_META   4
 stat_t.type: Meta data
 
#define STAT_TYPE_SYMLINK   5
 stat_t.type: Symbolic link
 
#define STAT_ATTR_NONE   0x00
 stat_t.attr: No attributes
 
#define STAT_ATTR_R   0x01
 stat_t.attr: Read-capable
 
#define STAT_ATTR_W   0x02
 stat_t.attr: Write-capable
 
#define STAT_ATTR_RW   (STAT_ATTR_R | STAT_ATTR_W)
 stat_t.attr: Read/Write capable
 
#define FILEHND_INVALID   ((file_t)-1)
 Invalid file handle constant (for open failure, etc)
 
File Open Modes

#define O_MODE_MASK   0x0f
 Mask for mode numbers.
 
#define O_ASYNC   0x0200
 Open for asynchronous I/O.
 
#define O_DIR   0x1000
 Open as directory.
 
#define O_META   0x2000
 Open as metadata.
 
Seek Modes

These are the values you can pass for the whence parameter to fs_seek().

#define SEEK_SET   0
 Set position to offset.
 
#define SEEK_CUR   1
 Seek from current position.
 
#define SEEK_END   2
 Seek from end of file.
 

Typedefs

typedef int file_t
 File descriptor type.
 

Functions

file_t fs_open (const char *fn, int mode)
 Open a file on the VFS.
 
int fs_close (file_t hnd)
 Close an opened file.
 
ssize_t fs_read (file_t hnd, void *buffer, size_t cnt)
 Read from an opened file.
 
ssize_t fs_write (file_t hnd, const void *buffer, size_t cnt)
 Write to an opened file.
 
off_t fs_seek (file_t hnd, off_t offset, int whence)
 Seek to a new position within a file.
 
_off64_t fs_seek64 (file_t hnd, _off64_t offset, int whence)
 Seek to a new position within a file (64-bit offsets).
 
off_t fs_tell (file_t hnd)
 Retrieve the position of the pointer within a file.
 
_off64_t fs_tell64 (file_t hnd)
 Retrieve the position of the 64-bit pointer within a file.
 
size_t fs_total (file_t hnd)
 Retrieve the length of an opened file.
 
uint64 fs_total64 (file_t hnd)
 Retrieve the length of an opened file as a 64-bit integer.
 
dirent_tfs_readdir (file_t hnd)
 Read an entry from an opened directory.
 
int fs_ioctl (file_t hnd, int cmd,...)
 Execute a device-specific command on a file descriptor.
 
int fs_rename (const char *fn1, const char *fn2)
 Rename the specified file to the given filename.
 
int fs_unlink (const char *fn)
 Delete the specified file.
 
int fs_chdir (const char *fn)
 Change the current working directory of the current thread.
 
void * fs_mmap (file_t hnd)
 Memory-map a previously opened file.
 
int fs_complete (file_t fd, ssize_t *rv)
 Perform an I/O completion on the given file descriptor.
 
int fs_mkdir (const char *fn)
 Create a directory.
 
int fs_rmdir (const char *fn)
 Remove a directory by name.
 
int fs_fcntl (file_t fd, int cmd,...)
 Manipulate file control flags.
 
int fs_link (const char *path1, const char *path2)
 Create a hard link.
 
int fs_symlink (const char *path1, const char *path2)
 Create a symbolic link.
 
ssize_t fs_readlink (const char *path, char *buf, size_t bufsize)
 Read the value of a symbolic link.
 
int fs_stat (const char *path, struct stat *buf, int flag)
 Retrieve information about the specified path.
 
int fs_rewinddir (file_t hnd)
 Rewind a directory to the start.
 
int fs_fstat (file_t hnd, struct stat *buf)
 Retrieve information about an opened file.
 
file_t fs_dup (file_t oldfd)
 Duplicate a file descriptor.
 
file_t fs_dup2 (file_t oldfd, file_t newfd)
 Duplicate a file descriptor onto the specified descriptor.
 
file_t fs_open_handle (vfs_handler_t *vfs, void *hnd)
 Create a "transient" file descriptor.
 
vfs_handler_tfs_get_handler (file_t fd)
 Retrieve the VFS Handler for a file descriptor.
 
void * fs_get_handle (file_t fd)
 Retrieve the internal handle for a file descriptor.
 
const char * fs_getwd (void)
 Get the current working directory of the running thread.
 
ssize_t fs_copy (const char *src, const char *dst)
 Copy a file.
 
ssize_t fs_load (const char *src, void **out_ptr)
 Open and read a whole file into RAM.
 
ssize_t fs_path_append (char *dst, const char *src, size_t len)
 Append a path component to a string.
 
char * fs_normalize_path (const char *__RESTRICT path, char *__RESTRICT resolved)
 Normalize the specified path.
 
int fs_init (void)
 Initialize the virtual filesystem.
 
void fs_shutdown (void)
 Shut down the virtual filesystem.
 

Detailed Description

Virtual filesystem support.

This file contains the interface to the virtual filesystem (VFS) of KOS. The functions defined in this file make up the base of the filesystem operations that can be performed by programs. The functions in here are abstracted by various other layers in libc, and shouldn't be necessarily used (for portability reasons). However, if you want only to interact with KOS in your programs, feel free to use them to your heart's content!

Author
Megan Potter
Lawrence Sebald