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#define FS_FLAG_FILE_SYSTEM_GENERAL (1<<10) //general file system
49
50#define FS_STATUS_FOUND 0x1
51#define FS_STATUS_NF 0x0
52
53#define VFS_MEDIA_TYPE_AHCI 0x1
54#define VFS_MEDIA_TYPE_IDE 0x2
55#define VFS_MEDIA_TYPE_OTHER 0x3
56
57/* file open modes*/
58#define FILE_OPEN_READ_ONLY (1<<1)
59#define FILE_OPEN_WRITE (1<<2)
60#define FILE_OPEN_CREAT (1<<3)
61
62struct __VFS_NODE__;
63
64#ifdef ARCH_X64
65#pragma pack(push,1)
66#endif
75#ifdef ARCH_X64
76#pragma pack(pop)
77#endif
78
79typedef struct __VFS_NODE__* (*open_callback) (struct __VFS_NODE__ *node, char* path);
80typedef size_t(*read_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file, uint64_t* buffer, uint32_t length);
81typedef size_t(*read_block_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file, uint64_t* buffer);
82typedef size_t (*write_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file, uint64_t* buffer, uint32_t length);
83typedef struct __VFS_NODE__*(*create_dir_callback) (struct __VFS_NODE__ *node, char* dirname);
84typedef struct __VFS_NODE__*(*create_file_callback) (struct __VFS_NODE__ *node, char* filename);
85typedef int (*remove_dir_callback) (struct __VFS_NODE__* node, struct __VFS_NODE__ *file);
86typedef int (*remove_file_callback)(struct __VFS_NODE__* node, struct __VFS_NODE__ *file);
87typedef int(*close_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file);
88typedef int(*iocontrol_callback) (struct __VFS_NODE__ *file, int code, void *arg);
89typedef struct __VFS_NODE__* (*opendir_callback) (struct __VFS_NODE__ *fs, char* dirname);
90typedef int(*readdir_callback)(struct __VFS_NODE__* fs, struct __VFS_NODE__* dir, AuDirectoryEntry* dirent);
91typedef uint32_t(*get_disk_block)(struct __VFS_NODE__* fs, struct __VFS_NODE__* file, uint64_t fs_block);
92typedef size_t(*fs_getblockfor) (struct __VFS_NODE__* fs, struct __VFS_NODE__* file, uint64_t offset);
93
94//#pragma pack(push,1)
123//#pragma pack(pop)
124
125//#pragma pack(push,1)
136//#pragma pack(pop)
137
138
150
151
161
162
163
168extern void AuVFSInitialise();
169
175
184AU_EXTERN AU_EXPORT int AuVFSNodeIOControl(AuVFSNode* node, int code, void* arg);
185
192
199
207
216AU_EXTERN AU_EXPORT size_t AuVFSNodeRead(AuVFSNode* node, AuVFSNode* file, uint64_t* buffer, uint32_t length);
217
226
234
242
249extern int AuVFSRemoveFile(AuVFSNode* fsys, AuVFSNode* file);
250
257extern int AuVFSRemoveDir(AuVFSNode* fsys, AuVFSNode* file);
258
266AU_EXTERN AU_EXPORT void AuVFSNodeWrite(AuVFSNode* node, AuVFSNode * file, uint64_t *buffer, uint32_t length);
267
274
284
285
286
287
288
289#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:67
int time
Definition vfs.h:72
int size
Definition vfs.h:70
int index
Definition vfs.h:69
char filename[32]
Definition vfs.h:68
int date
Definition vfs.h:71
uint8_t flags
Definition vfs.h:73
Definition vfs.h:126
uint32_t group_id
Definition vfs.h:132
uint32_t start_block
Definition vfs.h:130
uint32_t current_block
Definition vfs.h:129
uint32_t num_links
Definition vfs.h:133
uint8_t eof
Definition vfs.h:134
uint32_t user_id
Definition vfs.h:131
size_t size
Definition vfs.h:128
uint8_t filemode
Definition vfs.h:127
Definition vfs.h:139
uint8_t uchar_1
Definition vfs.h:141
uint32_t uint_1
Definition vfs.h:145
int syscall_magic
Definition vfs.h:140
uint16_t ushort_2
Definition vfs.h:144
uint32_t uint_2
Definition vfs.h:146
uint64_t ulong_2
Definition vfs.h:148
uint8_t uchar_2
Definition vfs.h:142
uint64_t ulong_1
Definition vfs.h:147
uint16_t ushort_1
Definition vfs.h:143
AuVFSContainer – is a container which contains list of nodes/directories another directory will point...
Definition vfs.h:158
list_t * childs
Definition vfs.h:159
Definition vfs.h:95
write_callback write
Definition vfs.h:111
create_dir_callback create_dir
Definition vfs.h:112
read_callback read
Definition vfs.h:110
read_block_callback read_block
Definition vfs.h:117
remove_file_callback remove_file
Definition vfs.h:115
iocontrol_callback iocontrol
Definition vfs.h:121
void * device
Definition vfs.h:105
uint64_t first_block
Definition vfs.h:101
readdir_callback read_dir
Definition vfs.h:118
fs_getblockfor get_blockfor
Definition vfs.h:120
opendir_callback opendir
Definition vfs.h:109
uint32_t size
Definition vfs.h:97
char filename[32]
Definition vfs.h:96
get_disk_block get_disk_block
Definition vfs.h:119
open_callback open
Definition vfs.h:108
uint64_t current
Definition vfs.h:102
uint8_t eof
Definition vfs.h:98
uint8_t status
Definition vfs.h:104
uint32_t parent_block
Definition vfs.h:100
create_file_callback create_file
Definition vfs.h:113
uint32_t pos
Definition vfs.h:99
uint16_t flags
Definition vfs.h:103
close_callback close
Definition vfs.h:116
remove_dir_callback remove_dir
Definition vfs.h:114
uint16_t fileCopyCount
Definition vfs.h:106
Definition list.h:46
int(* readdir_callback)(struct __VFS_NODE__ *fs, struct __VFS_NODE__ *dir, AuDirectoryEntry *dirent)
Definition vfs.h:90
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:82
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:92
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:81
struct __VFS_NODE__ AuVFSNode
uint32_t(* get_disk_block)(struct __VFS_NODE__ *fs, struct __VFS_NODE__ *file, uint64_t fs_block)
Definition vfs.h:91
struct __VFS_NODE__ *(* opendir_callback)(struct __VFS_NODE__ *fs, char *dirname)
Definition vfs.h:89
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:87
struct __VFS_NODE__ *(* create_file_callback)(struct __VFS_NODE__ *node, char *filename)
Definition vfs.h:84
int(* remove_dir_callback)(struct __VFS_NODE__ *node, struct __VFS_NODE__ *file)
Definition vfs.h:85
struct __VFS_NODE__ *(* create_dir_callback)(struct __VFS_NODE__ *node, char *dirname)
Definition vfs.h:83
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:80
struct _AuDirectoryEnty_ AuDirectoryEntry
struct __VFS_NODE__ *(* open_callback)(struct __VFS_NODE__ *node, char *path)
Definition vfs.h:79
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:86
int(* iocontrol_callback)(struct __VFS_NODE__ *file, int code, void *arg)
Definition vfs.h:88