-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibFS.h
More file actions
60 lines (49 loc) · 1.37 KB
/
Copy pathLibFS.h
File metadata and controls
60 lines (49 loc) · 1.37 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/***************************/
/* DO NOT MODIFY THIS FILE */
/***************************/
#ifndef __LibFS_h__
#define __LibFS_h__
// error types
typedef enum {
E_GENERAL, // general
E_CREATE,
E_NO_SUCH_FILE,
E_TOO_MANY_OPEN_FILES,
E_BAD_FD,
E_NO_SPACE,
E_FILE_TOO_BIG,
E_SEEK_OUT_OF_BOUNDS,
E_FILE_IN_USE,
E_NO_SUCH_DIR,
E_DIR_NOT_EMPTY,
E_ROOT_DIR,
E_BUFFER_TOO_SMALL,
} FS_Error_t;
// used for errors
extern int osErrno;
// a few file system parameters
// the total number of files and directories in the file system has a
// maximum limit of 1000
#define MAX_FILES 1000
// each file can have a maximum of 30 sectors; we treat the data
// blocks of the file/director the same as sectors
#define MAX_SECTORS_PER_FILE 30
// the size of a file or directory is limited
#define MAX_FILE_SIZE (MAX_SECTORS_PER_FILE*SECTOR_SIZE)
// file system generic calls
int FS_Boot(char *path);
int FS_Sync();
// file ops
int File_Create(char *file);
int File_Open(char *file);
int File_Read(int fd, void *buffer, int size);
int File_Write(int fd, void *buffer, int size);
int File_Seek(int fd, int offset);
int File_Close(int fd);
int File_Unlink(char *file);
// directory ops
int Dir_Create(char *path);
int Dir_Unlink(char *path);
int Dir_Size(char *path);
int Dir_Read(char *path, void *buffer, int size);
#endif /* __LibFS_h__ */