KallistiOS  2.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Functions
fs_ramdisk.h File Reference

RAM-based virtual file system. More...

#include <sys/cdefs.h>
#include <arch/types.h>
#include <kos/limits.h>
#include <kos/fs.h>

Go to the source code of this file.

Functions

int fs_ramdisk_attach (const char *fn, void *obj, size_t size)
 Attach a block of memory as a file in the ramdisk.
int fs_ramdisk_detach (const char *fn, void **obj, size_t *size)
 Detach a file from the ramdisk.

Detailed Description

RAM-based virtual file system.

This file contains support for a ramdisk VFS. This VFS allows you to map memory into files that will appear in /ram. Files in this VFS can grow as large as memory allows, and there is full read/write support here. This is useful, for (for instance) cacheing files read from the CD-ROM or for making temporary files.

You only have one ramdisk available, and its mounted on /ram.

Author:
Dan Potter

Function Documentation

int fs_ramdisk_attach ( const char *  fn,
void *  obj,
size_t  size 
)

Attach a block of memory as a file in the ramdisk.

This function takes a block of memory and associates it with a file on the ramdisk. This memory should be allocated with malloc(), as an unlink() of the file will call free on the block of memory. The ramdisk then effectively takes control of the block, and is responsible for it at that point.

Parameters:
fnThe name to give the new file
objThe block of memory to associate
sizeThe size of the block of memory
Return values:
0On success
-1On failure
int fs_ramdisk_detach ( const char *  fn,
void **  obj,
size_t *  size 
)

Detach a file from the ramdisk.

This function retrieves the block of memory associated with the file, removing it from the ramdisk. You are responsible for freeing obj when you are done with it.

Parameters:
fnThe name of the file to look for.
objA pointer to return the address of the object in.
sizeA pointer to return the size of the object in.
Return values:
0On success
-1On failure