KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
fs_ramdisk.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 kos/fs_ramdisk.h
4 (c)2002 Megan Potter
5
6*/
7
8/** \file kos/fs_ramdisk.h
9 \brief RAM-based virtual file system.
10 \ingroup vfs_ramdisk
11
12 This file contains support for a ramdisk VFS. This VFS allows you to map
13 memory into files that will appear in /ram. Files in this VFS can grow as
14 large as memory allows, and there is full read/write support here. This is
15 useful, for (for instance) caching files read from the CD-ROM or for making
16 temporary files.
17
18 You only have one ramdisk available, and its mounted on /ram.
19
20 \author Megan Potter
21*/
22
23#ifndef __KOS_FS_RAMDISK_H
24#define __KOS_FS_RAMDISK_H
25
26#include <sys/cdefs.h>
27__BEGIN_DECLS
28
29#include <kos/fs.h>
30
31/** \defgroup vfs_ramdisk Ramdisk
32 \brief Filesystem driver for accessing in-ram images
33 \ingroup vfs
34
35 @{
36*/
37
38/** \cond */
39void fs_ramdisk_init(void);
40void fs_ramdisk_shutdown(void);
41/** \endcond */
42
43/** \brief Attach a block of memory as a file in the ramdisk.
44
45 This function takes a block of memory and associates it with a file on the
46 ramdisk. This memory should be allocated with malloc(), as an unlink() of
47 the file will call free on the block of memory. The ramdisk then effectively
48 takes control of the block, and is responsible for it at that point.
49
50 \param fn The name to give the new file
51 \param obj The block of memory to associate
52 \param size The size of the block of memory
53 \retval 0 On success
54 \retval -1 On failure
55*/
56int fs_ramdisk_attach(const char * fn, void * obj, size_t size);
57
58/** \brief Detach a file from the ramdisk.
59
60 This function retrieves the block of memory associated with the file,
61 removing it from the ramdisk. You are responsible for freeing obj when you
62 are done with it.
63
64 \param fn The name of the file to look for.
65 \param obj A pointer to return the address of the object in.
66 \param size A pointer to return the size of the object in.
67 \retval 0 On success
68 \retval -1 On failure
69*/
70int fs_ramdisk_detach(const char * fn, void ** obj, size_t * size);
71
72/** @} */
73
74__END_DECLS
75
76#endif /* __KOS_FS_RAMDISK_H */
77
Virtual filesystem support.
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.