blob: 1c62a807aa8b7ff9bd7585b82aac85ce555b8df1 [file] [log] [blame]
swissChili8efa4922021-03-02 16:34:49 -08001#pragma once
2
3#include "kint.h"
4
5struct fs_vtable;
6
7struct fs_node
8{
9 char name[128]; /* file name */
10 uint inode; /* identifier */
11 uint flags; /* type of node */
12 uint mask; /* permissions */
13 uint gid; /* group id */
14 uint uid; /* user id */
15 size_t size; /* size in bytes */
16 uint dri_res; /* reserved for driver */
17
18 struct fs_vtable *vtable;
19
20 struct fs_node *mount; /* used for mounts */
21};
22
23struct fs_dirent
24{
25 char name[128];
26 uint inode;
27};
28
29typedef uint (* fs_read_t)(struct fs_node *node, size_t offset, size_t size, uchar *buffer);
30typedef uint (* fs_write_t)(struct fs_node *node, size_t offset, size_t size, uchar *buffer);
31typedef void (* fs_open_t)(struct fs_node *node);
32typedef void (* fs_close_t)(struct fs_node *node);
33
34typedef struct fs_dirent *(* fs_readdir_t)(struct fs_node *node, uint index);
35typedef struct fs_node *(* fs_finddir_t)(struct fs_node *node, char *name);
36
37struct fs_vtable
38{
39 fs_read_t read;
40 fs_write_t write;
41 fs_open_t open;
42 fs_close_t close;
43 fs_readdir_t readdir;
44 fs_finddir_t finddir;
45};
46
47enum fs_flags
48{
49 FS_FILE = 1,
50 FS_DIRECTORY,
51 FS_CHARDEVICE,
52 FS_BLOCKDEVICE,
53 FS_PIPE,
54 FS_SYMLINK,
55
56 FS_MOUNT = 8, /* Can be or'd with others */
57};
58
59/* Not to be confused normal open, close, etc functions, these operate
60 * on the VFS directly */
61
62uint fs_read(struct fs_node *node, size_t offset, size_t size, uchar *buffer);
63uint fs_write(struct fs_node *node, size_t offset, size_t size, uchar *buffer);
64void fs_open(struct fs_node *node);
65void fs_close(struct fs_node *node);
66
67struct fs_dirent *fs_readdir(struct fs_node *node, uint index);
68struct fs_node *fs_finddir(struct fs_node *node, char *name);