XenevaOS
Loading...
Searching...
No Matches
vfs.h
Go to the documentation of this file.
32#ifndef __VFS_H__
33#define __VFS_H__
34
35#include <stdint.h>
36#include <list.h>
37#include <aurora.h>
38
39#define FS_FLAG_DIRECTORY (1<<1) //temporary/freeable
40#define FS_FLAG_GENERAL (1<<2) //tempoary/freeable
41#define FS_FLAG_DEVICE (1<<3) //permanent/non-freeable
42#define FS_FLAG_DELETED (1<<4) //state
43#define FS_FLAG_INVALID (1<<5) //state
44#define FS_FLAG_FILE_SYSTEM (1<<6) //parment/non-freeable
45#define FS_FLAG_PIPE (1<<7) //temporary/freeable
46#define FS_FLAG_TTY (1<<8) //temporary/freeable with count
47#define FS_FLAG_SOCKET (1<<9) //temporary/freeable
48
49#define FS_STATUS_FOUND 0x1
50#define FS_STATUS_NF 0x0
51
52#define VFS_MEDIA_TYPE_AHCI 0x1
53#define VFS_MEDIA_TYPE_IDE 0x2
54#define VFS_MEDIA_TYPE_OTHER 0x3
55
56/* file open modes*/
57#define FILE_OPEN_READ_ONLY (1<<1)
58#define FILE_OPEN_WRITE (1<<2)
59#define FILE_OPEN_CREAT (1<<3)
60
61struct __VFS_NODE__;
62
63#pragma pack(push,1)
72#pragma pack(pop)
73
74typedef struct __VFS_NODE__* (*open_callback) (struct __VFS_NODE__ *node, char* path);
75typedef size_t(*read_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file, uint64_t* buffer, uint32_t length);
76typedef size_t(*read_block_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file, uint64_t* buffer);
77typedef size_t (*write_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file, uint64_t* buffer, uint32_t length);
78typedef struct __VFS_NODE__*(*create_dir_callback) (struct __VFS_NODE__ *node, char* dirname);
79typedef struct __VFS_NODE__*(*create_file_callback) (struct __VFS_NODE__ *node, char* filename);
80typedef int (*remove_dir_callback) (struct __VFS_NODE__* node, struct __VFS_NODE__ *file);
81typedef int (*remove_file_callback)(struct __VFS_NODE__* node, struct __VFS_NODE__ *file);
82typedef int(*close_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file);
83typedef int(*iocontrol_callback) (struct __VFS_NODE__ *file, int code, void *arg);
84typedef struct __VFS_NODE__* (*opendir_callback) (struct __VFS_NODE__ *fs, char* dirname);
85typedef int(*readdir_callback)(struct __VFS_NODE__* fs, struct __VFS_NODE__* dir, AuDirectoryEntry* dirent);
86typedef size_t(*fs_getblockfor) (struct __VFS_NODE__* fs, struct __VFS_NODE__* file, uint64_t offset);
87
88//#pragma pack(push,1)
116//#pragma pack(pop)
117
118//#pragma pack(push,1)
129//#pragma pack(pop)
130
131
143
144
154
155
156
161extern void AuVFSInitialise();
162
168
177AU_EXTERN AU_EXPORT int AuVFSNodeIOControl(AuVFSNode* node, int code, void* arg);
178
185
192
200
209AU_EXTERN AU_EXPORT size_t AuVFSNodeRead(AuVFSNode* node, AuVFSNode* file, uint64_t* buffer, uint32_t length);
210
219
227
235
242extern int AuVFSRemoveFile(AuVFSNode* fsys, AuVFSNode* file);
243
250extern int AuVFSRemoveDir(AuVFSNode* fsys, AuVFSNode* file);
251
259AU_EXTERN AU_EXPORT void AuVFSNodeWrite(AuVFSNode* node, AuVFSNode * file, uint64_t *buffer, uint32_t length);
260
267
277
278
279
280
281
282#endif
#define AU_EXTERN
Definition aurora.h:50
#define AU_EXPORT
Definition aurora.h:38
uint64_t size_t
Definition stdint.h:101
char * path
Definition main.cpp:62
unsigned int uint32_t
Definition acefiex.h:163
unsigned char uint8_t
Definition acefiex.h:161
COMPILER_DEPENDENT_UINT64 uint64_t
Definition acefiex.h:165
unsigned short int uint16_t
Definition acefiex.h:162
Definition vfs.h:64
int time
Definition vfs.h:69
int size
Definition vfs.h:67
int index
Definition vfs.h:66
char filename[32]
Definition vfs.h:65
int date
Definition vfs.h:68
uint8_t flags
Definition vfs.h:70
Definition vfs.h:119
uint32_t group_id
Definition vfs.h:125
uint32_t start_block
Definition vfs.h:123
uint32_t current_block
Definition vfs.h:122
uint32_t num_links
Definition vfs.h:126
uint8_t eof
Definition vfs.h:127
uint32_t user_id
Definition vfs.h:124
size_t size
Definition vfs.h:121
uint8_t filemode
Definition vfs.h:120
Definition vfs.h:132
uint8_t uchar_1
Definition vfs.h:134
uint32_t uint_1
Definition vfs.h:138
int syscall_magic
Definition vfs.h:133
uint16_t ushort_2
Definition vfs.h:137
uint32_t uint_2
Definition vfs.h:139
uint64_t ulong_2
Definition vfs.h:141
uint8_t uchar_2
Definition vfs.h:135
uint64_t ulong_1
Definition vfs.h:140
uint16_t ushort_1
Definition vfs.h:136
AuVFSContainer – is a container which contains list of nodes/directories another directory will point...
Definition vfs.h:151
list_t * childs
Definition vfs.h:152
Definition vfs.h:89
write_callback write
Definition vfs.h:105
create_dir_callback create_dir
Definition vfs.h:106
read_callback read
Definition vfs.h:104
read_block_callback read_block
Definition vfs.h:111
remove_file_callback remove_file
Definition vfs.h:109
iocontrol_callback iocontrol
Definition vfs.h:114
void * device
Definition vfs.h:99
uint64_t first_block
Definition vfs.h:95
readdir_callback read_dir
Definition vfs.h:112
fs_getblockfor get_blockfor
Definition vfs.h:113
opendir_callback opendir
Definition vfs.h:103
uint32_t size
Definition vfs.h:91
char filename[32]
Definition vfs.h:90
open_callback open
Definition vfs.h:102
uint64_t current
Definition vfs.h:96
uint8_t eof
Definition vfs.h:92
uint8_t status
Definition vfs.h:98
uint32_t parent_block
Definition vfs.h:94
create_file_callback create_file
Definition vfs.h:107
uint32_t pos
Definition vfs.h:93
uint16_t flags
Definition vfs.h:97
close_callback close
Definition vfs.h:110
remove_dir_callback remove_dir
Definition vfs.h:108
uint16_t fileCopyCount
Definition vfs.h:100
Definition list.h:46
int(* readdir_callback)(struct __VFS_NODE__ *fs, struct __VFS_NODE__ *dir, AuDirectoryEntry *dirent)
Definition vfs.h:85
AU_EXTERN AU_EXPORT size_t AuVFSNodeRead(AuVFSNode *node, AuVFSNode *file, uint64_t *buffer, uint32_t length)
AuVFSNodeRead – read from file system.
Definition vfs.cpp:197
size_t(* write_callback)(struct __VFS_NODE__ *node, struct __VFS_NODE__ *file, uint64_t *buffer, uint32_t length)
Definition vfs.h:77
AU_EXTERN AU_EXPORT AuVFSNode * AuVFSOpen(char *path)
AuVFSOpen – Opens a file.
Definition vfs.cpp:133
size_t(* fs_getblockfor)(struct __VFS_NODE__ *fs, struct __VFS_NODE__ *file, uint64_t offset)
Definition vfs.h:86
AU_EXTERN AU_EXPORT void AuVFSNodeWrite(AuVFSNode *node, AuVFSNode *file, uint64_t *buffer, uint32_t length)
AuVFSNodeWrite – write to file system.
Definition vfs.cpp:212
struct _FileControl_ AuFileIOControl
int AuVFSRemoveDir(AuVFSNode *fsys, AuVFSNode *file)
AuVFSRemoveFile –remove a file from a file system.
Definition vfs.cpp:287
size_t(* read_block_callback)(struct __VFS_NODE__ *node, struct __VFS_NODE__ *file, uint64_t *buffer)
Definition vfs.h:76
struct __VFS_NODE__ AuVFSNode
struct __VFS_NODE__ *(* opendir_callback)(struct __VFS_NODE__ *fs, char *dirname)
Definition vfs.h:84
int AuVFSRemoveFile(AuVFSNode *fsys, AuVFSNode *file)
AuVFSRemoveFile –remove a file from a file system.
Definition vfs.cpp:267
AU_EXTERN AU_EXPORT void AuVFSAddFileSystem(AuVFSNode *node)
AuVFSAddFileSystem – adds a file system to the vfs list.
Definition vfs.cpp:107
int(* close_callback)(struct __VFS_NODE__ *node, struct __VFS_NODE__ *file)
Definition vfs.h:82
struct __VFS_NODE__ *(* create_file_callback)(struct __VFS_NODE__ *node, char *filename)
Definition vfs.h:79
int(* remove_dir_callback)(struct __VFS_NODE__ *node, struct __VFS_NODE__ *file)
Definition vfs.h:80
struct __VFS_NODE__ *(* create_dir_callback)(struct __VFS_NODE__ *node, char *dirname)
Definition vfs.h:78
AU_EXTERN AU_EXPORT size_t AuVFSGetBlockFor(AuVFSNode *node, AuVFSNode *file, uint64_t offset)
AuVFSGetBlockFor – returns a block number for certain byte offset of file.
Definition vfs.cpp:339
AU_EXTERN AU_EXPORT AuVFSNode * AuVFSFind(char *path)
AuVFSFind – Searches a filesystem an return it to the caller.
Definition vfs.cpp:68
AU_EXTERN AU_EXPORT AuVFSNode * AuVFSCreateFile(AuVFSNode *fsys, char *filename)
AuVFSCreateFile – create a new file.
Definition vfs.cpp:253
AU_EXTERN AU_EXPORT void AuVFSRegisterRoot(AuVFSNode *fs)
AuVFSRegisterRoot – register the root file system.
Definition vfs.cpp:122
struct _AuFileStatus_ AuFileStatus
size_t(* read_callback)(struct __VFS_NODE__ *node, struct __VFS_NODE__ *file, uint64_t *buffer, uint32_t length)
Definition vfs.h:75
struct _AuDirectoryEnty_ AuDirectoryEntry
struct __VFS_NODE__ *(* open_callback)(struct __VFS_NODE__ *node, char *path)
Definition vfs.h:74
AU_EXTERN AU_EXPORT int AuVFSNodeIOControl(AuVFSNode *node, int code, void *arg)
AuVFSNodeIOControl – Calls node's iocontrol pointer.
Definition vfs.cpp:182
struct __VFS_Container__ AuVFSContainer
AuVFSContainer – is a container which contains list of nodes/directories another directory will point...
AU_EXTERN AU_EXPORT void AuVFSNodeClose(AuVFSNode *node, AuVFSNode *file)
AuVFSNodeClose – close a file system or file.
Definition vfs.cpp:304
AU_EXTERN AU_EXPORT AuVFSNode * AuVFSCreateDir(AuVFSNode *fsys, char *dirname)
AuVFSCreateDir – creates a new dir.
Definition vfs.cpp:239
AU_EXTERN AU_EXPORT size_t AuVFSNodeReadBlock(AuVFSNode *node, AuVFSNode *file, uint64_t *buffer)
AuVFSNodeReadBlock – read a block size data from file system.
Definition vfs.cpp:225
void AuVFSInitialise()
AuVFSInitialise – initialise the virtual file system.
Definition vfs.cpp:48
int(* remove_file_callback)(struct __VFS_NODE__ *node, struct __VFS_NODE__ *file)
Definition vfs.h:81
int(* iocontrol_callback)(struct __VFS_NODE__ *file, int code, void *arg)
Definition vfs.h:83