KallistiOS  ##version##
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
fs_romdisk.h
Go to the documentation of this file.
1 /* KallistiOS ##version##
2 
3  kos/fs_romdisk.h
4  (c)2001 Dan Potter
5 
6 */
7 
8 /** \file kos/fs_romdisk.h
9  \brief ROMFS virtual file system.
10 
11  This file contains support for the romdisk VFS. This VFS allows you to make
12  Linux-style ROMFS images and either embed them into your binary or load them
13  at runtime from some other source (such as a CD-ROM). These images are made
14  with the genromfs program that is included in the utils portion of the tree.
15 
16  You can choose to automount one ROMFS image by embedding it into your binary
17  and using the appropriate KOS_INIT_FLAGS() setting. The embedded ROMFS will
18  mount itself on /rom. You can also mount additional images that you load
19  from some other source on whatever mountpoint you want.
20 
21  \author Dan Potter
22 */
23 
24 #ifndef __KOS_FS_ROMDISK_H
25 #define __KOS_FS_ROMDISK_H
26 
27 #include <sys/cdefs.h>
28 __BEGIN_DECLS
29 
30 #include <arch/types.h>
31 #include <kos/limits.h>
32 #include <kos/fs.h>
33 
34 /** \brief The maximum number of files that can be open at a time. */
35 #define MAX_RD_FILES 16
36 
37 /** \cond */
38 /* Initialize the file system */
39 int fs_romdisk_init();
40 
41 /* De-init the file system; also unmounts any mounted images. */
42 int fs_romdisk_shutdown();
43 /** \endcond */
44 
45 /* NOTE: the mount/unmount are _not_ thread safe as regards doing multiple
46  mounts/unmounts in different threads at the same time, and they don't
47  check for open files currently either. Caveat emptor! */
48 
49 /** \brief Mount a ROMFS image as a new filesystem.
50 
51  This function will mount a ROMFS image that has been loaded into memory to
52  the specified mountpoint.
53 
54  \param mountpoint The directory to mount this romdisk on
55  \param img The ROMFS image
56  \param own_buffer If 0, you are still responsible for img, and must
57  free it if appropriate. If non-zero, img will be
58  freed when it is unmounted
59  \retval 0 On success
60  \retval -1 On error
61 */
62 int fs_romdisk_mount(const char * mountpoint, const uint8 *img, int own_buffer);
63 
64 /** \brief Unmount a ROMFS image.
65 
66  This function unmounts a ROMFS image that has been previously mounted with
67  fs_romdisk_mount(). This function does not check for open files on the fs,
68  so make sure that all files have been closed before calling it. If the VFS
69  owns the buffer (own_buffer was non-zero when you called the mount function)
70  then this function will also free the buffer.
71 
72  \param mountpoint The ROMFS to unmount
73  \retval 0 On success
74  \retval -1 On error
75 
76  \par Error Conditions:
77  \em ENOENT - no such ROMFS was mounted
78 */
79 int fs_romdisk_unmount(const char * mountpoint);
80 
81 __END_DECLS
82 
83 #endif /* __KOS_FS_ROMDISK_H */
84 
Common integer types.
Virtual filesystem support.
int fs_romdisk_mount(const char *mountpoint, const uint8 *img, int own_buffer)
Mount a ROMFS image as a new filesystem.
int fs_romdisk_unmount(const char *mountpoint)
Unmount a ROMFS image.
unsigned char uint8
8-bit unsigned integer
Definition: types.h:30
Limits.