internal.h 1.82 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef EPICARCIUM_FS_INTERNAL_H_INCLUDED
#define EPICARCIUM_FS_INTERNAL_H_INCLUDED

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>

#include "epicardium.h"

/* Number of bits to use for indexing into our internal pool of files/directories
 * This indirectly specifies the size of the pool as 1^EPIC_FAT_FD_INDEX_BITS
 * Increase if number of open file descriptors is not enough, but be aware of
 * memory usage of the pool!
 */
#define EPIC_FAT_FD_INDEX_BITS 4
#define EPIC_FAT_STATIC_SEMAPHORE 1

// forward declaration, actual definition is in filesystem_fat.c
typedef struct EpicFileSystem EpicFileSystem;

int efs_open(EpicFileSystem *fs, const char *filename, const char *modeString);
int efs_close(EpicFileSystem *fs, int fd);
int efs_read(EpicFileSystem *fs, int fd, void *buf, size_t nbytes);
int efs_write(EpicFileSystem *fs, int fd, const void *buf, size_t nbytes);
int efs_flush(EpicFileSystem *fs, int fd);
int efs_seek(EpicFileSystem *fs, int fd, long offset, int whence);
int efs_tell(EpicFileSystem *fs, int fd);
int efs_stat(EpicFileSystem *fs, const char *filename, struct epic_stat *stat);
29
30
31
int efs_opendir(EpicFileSystem *fs, const char *path);
int efs_readdir(EpicFileSystem *fs, int fd, struct epic_stat *stat);
int efs_unlink(EpicFileSystem *fs, const char *path);
swym's avatar
swym committed
32
33
int efs_rename(EpicFileSystem *fs, const char *oldp, const char *newp);
int efs_mkdir(EpicFileSystem *fs, const char *dirname);
34
35
/**
 * lock global filesystem
Rahix's avatar
Rahix committed
36
 *
37
38
39
40
41
42
43
44
45
46
 * locks the global mutex and, if the global EpicFileSystem has been initialized correctly
 * passes it to *fs
 *
 * Upon successful return, the filesystem has to be re-locked with epic_fs_unlock_global
 * In case of error, the filesystem will be left in a locked state.
 */
int efs_lock_global(EpicFileSystem** fs);
void efs_unlock_global(EpicFileSystem* fs);

#endif// EPICARCIUM_FS_INTERNAL_H_INCLUDED