KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
fs_fat.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 fat/fs_fat.h
4 Copyright (C) 2012, 2013, 2019 Lawrence Sebald
5*/
6
7/** \file fat/fs_fat.h
8 \brief VFS interface for a FAT filesystem.
9 \ingroup vfs_fat
10
11 This file defines the public interface to add support for the FAT
12 filesystem, as in common use on all kinds of systems and popularized by
13 MS-DOS and Windows. This interface supports FAT12, FAT16, and FAT32, with
14 both short and long names.
15
16 Note that there is a lower-level interface sitting underneath of this layer.
17 This lower-level interface (simply called fatfs) should not generally be
18 used by any normal applications. As of this point, it is completely non
19 thread-safe and the fs_fat layer takes extreme care to overcome those
20 issues with the lower-level interface. Over time, I may fix the thread-
21 safety issues in fatfs, but that is not particularly high on my priority
22 list at the moment. There shouldn't really be a reason to work directly with
23 the fatfs layer anyway, as this layer should give you everything you need
24 by interfacing with the VFS in the normal fashion.
25
26 \author Lawrence Sebald
27*/
28
29#ifndef __FAT_FS_FAT_H
30#define __FAT_FS_FAT_H
31
32#include <sys/cdefs.h>
33__BEGIN_DECLS
34
35#include <stdint.h>
36#include <kos/blockdev.h>
37
38/** \defgroup vfs_fat FAT
39 \brief FAT 12, 16, and 32-bit support for KOS's VFS
40 \ingroup vfs_drivers
41*/
42
43/** \brief Initialize fs_fat.
44 \ingroup vfs_fat
45
46 This function initializes fs_fat, preparing various internal structures for
47 use.
48
49 \retval 0 On success. No error conditions currently defined.
50*/
51int fs_fat_init(void);
52
53/** \brief Shut down fs_fat.
54 \ingroup vfs_fat
55
56 This function shuts down fs_fat, basically undoing what fs_fat_init() did.
57
58 \retval 0 On success. No error conditions currently defined.
59*/
61
62/** \defgroup fat_mount_flags Mount Flags
63 \brief Mount flags for fs_fat
64 \ingroup vfs_fat
65
66 These values are the valid flags that can be passed for the flags parameter
67 to the fs_fat_mount() function. Note that these can be combined, except for
68 the read-only flag.
69
70 Also, it is not possible to mount some filesystems as read-write. For
71 instance, if the filesystem was marked as not cleanly unmounted the driver
72 will fail to mount the device as read-write. Also, if the block device does
73 not support writing, then the filesystem will not be mounted as read-write
74 (for obvious reasons).
75
76 These should stay synchronized with the ones in fatfs.h.
77
78 @{
79*/
80#define FS_FAT_MOUNT_READONLY 0x00000000 /**< \brief Mount read-only */
81#define FS_FAT_MOUNT_READWRITE 0x00000001 /**< \brief Mount read-write */
82/** @} */
83
84/** \brief Mount a FAT filesystem in the VFS.
85 \ingroup vfs_fat
86
87 This function mounts an fat filesystem to the specified mount point on the
88 VFS. This function will detect whether or not an FAT filesystem exists on
89 the given block device and mount it only if there is actually an FAT
90 filesystem.
91
92 \param mp The path to mount the filesystem at.
93 \param dev The block device containing the filesystem.
94 \param flags Mount flags. Bitwise OR of values from fat_mount_flags
95
96 \retval 0 On success.
97 \retval -1 On error.
98*/
99int fs_fat_mount(const char *mp, kos_blockdev_t *dev, uint32_t flags);
100
101/** \brief Unmount a FAT filesystem from the VFS.
102 \ingroup vfs_fat
103
104 This function unmoutns an FAT filesystem that was previously mounted by the
105 fs_fat_mount() function.
106
107 \param mp The mount point of the filesystem to be unmounted.
108
109 \retval 0 On success.
110 \retval -1 On error.
111*/
112int fs_fat_unmount(const char *mp);
113
114/** \brief Sync a FAT filesystem, flushing all pending writes to the block
115 device.
116 \ingroup vfs_fat
117
118 This function completes all pending writes on the filesystem, making sure
119 all data and metadata are in a consistent state on the block device. As both
120 inode and block writes are normally postponed until they are either evicted
121 from the cache or the filesystem is unmounted, doing this periodically may
122 be a good idea if there is a chance that the filesystem will not be
123 unmounted cleanly.
124
125 \note This function has no effect if the filesystem was mounted read-only.
126
127 \param mp The mount point of the filesystem to be synced.
128
129 \retval 0 On success.
130 \retval -1 On error.
131*/
132int fs_fat_sync(const char *mp);
133
134__END_DECLS
135#endif /* !__FAT_FS_FAT_H */
Definitions for a simple block device interface.
int fs_fat_sync(const char *mp)
Sync a FAT filesystem, flushing all pending writes to the block device.
int fs_fat_unmount(const char *mp)
Unmount a FAT filesystem from the VFS.
int fs_fat_mount(const char *mp, kos_blockdev_t *dev, uint32_t flags)
Mount a FAT filesystem in the VFS.
int fs_fat_init(void)
Initialize fs_fat.
int fs_fat_shutdown(void)
Shut down fs_fat.
A simple block device.
Definition blockdev.h:54