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 <arch/types.h>
30#include <kos/fs.h>
31
32/** \defgroup vfs_ramdisk Ramdisk
33 \brief Filesystem driver for accessing in-ram images
34 \ingroup vfs
35
36 @{
37*/
38
39/** \cond */
40int fs_ramdisk_init(void);
41int fs_ramdisk_shutdown(void);
42/** \endcond */
43
44/** \brief Attach a block of memory as a file in the ramdisk.
45
46 This function takes a block of memory and associates it with a file on the
47 ramdisk. This memory should be allocated with malloc(), as an unlink() of
48 the file will call free on the block of memory. The ramdisk then effectively
49 takes control of the block, and is responsible for it at that point.
50
51 \param fn The name to give the new file
52 \param obj The block of memory to associate
53 \param size The size of the block of memory
54 \retval 0 On success
55 \retval -1 On failure
56*/
57int fs_ramdisk_attach(const char * fn, void * obj, size_t size);
58
59/** \brief Detach a file from the ramdisk.
60
61 This function retrieves the block of memory associated with the file,
62 removing it from the ramdisk. You are responsible for freeing obj when you
63 are done with it.
64
65 \param fn The name of the file to look for.
66 \param obj A pointer to return the address of the object in.
67 \param size A pointer to return the size of the object in.
68 \retval 0 On success
69 \retval -1 On failure
70*/
71int fs_ramdisk_detach(const char * fn, void ** obj, size_t * size);
72
73/** @} */
74
75__END_DECLS
76
77#endif /* __KOS_FS_RAMDISK_H */
78
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.
Common integer types.