XenevaOS
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
vfs.h File Reference
#include <stdint.h>
#include <list.h>
#include <aurora.h>
Include dependency graph for vfs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _AuDirectoryEnty_
 
struct  __VFS_NODE__
 
struct  _AuFileStatus_
 
struct  _FileControl_
 
struct  __VFS_Container__
 AuVFSContainer – is a container which contains list of nodes/directories another directory will point to another newly created container. More...
 

Macros

#define FS_FLAG_DIRECTORY   (1<<1)
 
#define FS_FLAG_GENERAL   (1<<2)
 
#define FS_FLAG_DEVICE   (1<<3)
 
#define FS_FLAG_DELETED   (1<<4)
 
#define FS_FLAG_INVALID   (1<<5)
 
#define FS_FLAG_FILE_SYSTEM   (1<<6)
 
#define FS_FLAG_PIPE   (1<<7)
 
#define FS_FLAG_TTY   (1<<8)
 
#define FS_FLAG_SOCKET   (1<<9)
 
#define FS_STATUS_FOUND   0x1
 
#define FS_STATUS_NF   0x0
 
#define VFS_MEDIA_TYPE_AHCI   0x1
 
#define VFS_MEDIA_TYPE_IDE   0x2
 
#define VFS_MEDIA_TYPE_OTHER   0x3
 
#define FILE_OPEN_READ_ONLY   (1<<1)
 
#define FILE_OPEN_WRITE   (1<<2)
 
#define FILE_OPEN_CREAT   (1<<3)
 

Typedefs

typedef struct _AuDirectoryEnty_ AuDirectoryEntry
 
typedef struct __VFS_NODE__ *(* open_callback) (struct __VFS_NODE__ *node, char *path)
 
typedef size_t(* read_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file, uint64_t *buffer, uint32_t length)
 
typedef size_t(* read_block_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file, uint64_t *buffer)
 
typedef size_t(* write_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file, uint64_t *buffer, uint32_t length)
 
typedef struct __VFS_NODE__ *(* create_dir_callback) (struct __VFS_NODE__ *node, char *dirname)
 
typedef struct __VFS_NODE__ *(* create_file_callback) (struct __VFS_NODE__ *node, char *filename)
 
typedef int(* remove_dir_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file)
 
typedef int(* remove_file_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file)
 
typedef int(* close_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file)
 
typedef int(* iocontrol_callback) (struct __VFS_NODE__ *file, int code, void *arg)
 
typedef struct __VFS_NODE__ *(* opendir_callback) (struct __VFS_NODE__ *fs, char *dirname)
 
typedef int(* readdir_callback) (struct __VFS_NODE__ *fs, struct __VFS_NODE__ *dir, AuDirectoryEntry *dirent)
 
typedef size_t(* fs_getblockfor) (struct __VFS_NODE__ *fs, struct __VFS_NODE__ *file, uint64_t offset)
 
typedef struct __VFS_NODE__ AuVFSNode
 
typedef struct _AuFileStatus_ AuFileStatus
 
typedef struct _FileControl_ AuFileIOControl
 
typedef struct __VFS_Container__ AuVFSContainer
 AuVFSContainer – is a container which contains list of nodes/directories another directory will point to another newly created container.
 

Functions

void AuVFSInitialise ()
 AuVFSInitialise – initialise the virtual file system.
 
AU_EXTERN AU_EXPORT AuVFSNodeAuVFSOpen (char *path)
 AuVFSOpen – Opens a file.
 
AU_EXTERN AU_EXPORT int AuVFSNodeIOControl (AuVFSNode *node, int code, void *arg)
 AuVFSNodeIOControl – Calls node's iocontrol pointer.
 
AU_EXTERN AU_EXPORT void AuVFSAddFileSystem (AuVFSNode *node)
 AuVFSAddFileSystem – adds a file system to the vfs list.
 
AU_EXTERN AU_EXPORT void AuVFSRegisterRoot (AuVFSNode *fs)
 AuVFSRegisterRoot – register the root file system.
 
AU_EXTERN AU_EXPORT AuVFSNodeAuVFSFind (char *path)
 AuVFSFind – Searches a filesystem an return it to the caller.
 
AU_EXTERN AU_EXPORT size_t AuVFSNodeRead (AuVFSNode *node, AuVFSNode *file, uint64_t *buffer, uint32_t length)
 AuVFSNodeRead – read from file system.
 
AU_EXTERN AU_EXPORT size_t AuVFSNodeReadBlock (AuVFSNode *node, AuVFSNode *file, uint64_t *buffer)
 AuVFSNodeReadBlock – read a block size data from file system.
 
AU_EXTERN AU_EXPORT AuVFSNodeAuVFSCreateDir (AuVFSNode *fsys, char *dirname)
 AuVFSCreateDir – creates a new dir.
 
AU_EXTERN AU_EXPORT AuVFSNodeAuVFSCreateFile (AuVFSNode *fsys, char *filename)
 AuVFSCreateFile – create a new file.
 
int AuVFSRemoveFile (AuVFSNode *fsys, AuVFSNode *file)
 AuVFSRemoveFile –remove a file from a file system.
 
int AuVFSRemoveDir (AuVFSNode *fsys, AuVFSNode *file)
 AuVFSRemoveFile –remove a file from a file system.
 
AU_EXTERN AU_EXPORT void AuVFSNodeWrite (AuVFSNode *node, AuVFSNode *file, uint64_t *buffer, uint32_t length)
 AuVFSNodeWrite – write to file system.
 
AU_EXTERN AU_EXPORT void AuVFSNodeClose (AuVFSNode *node, AuVFSNode *file)
 AuVFSNodeClose – close a file system or file.
 
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.
 

Detailed Description

BSD 2-Clause License

Copyright (c) 2022-2023, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ FILE_OPEN_CREAT

#define FILE_OPEN_CREAT   (1<<3)

◆ FILE_OPEN_READ_ONLY

#define FILE_OPEN_READ_ONLY   (1<<1)

◆ FILE_OPEN_WRITE

#define FILE_OPEN_WRITE   (1<<2)

◆ FS_FLAG_DELETED

#define FS_FLAG_DELETED   (1<<4)

◆ FS_FLAG_DEVICE

#define FS_FLAG_DEVICE   (1<<3)

◆ FS_FLAG_DIRECTORY

#define FS_FLAG_DIRECTORY   (1<<1)

◆ FS_FLAG_FILE_SYSTEM

#define FS_FLAG_FILE_SYSTEM   (1<<6)

◆ FS_FLAG_GENERAL

#define FS_FLAG_GENERAL   (1<<2)

◆ FS_FLAG_INVALID

#define FS_FLAG_INVALID   (1<<5)

◆ FS_FLAG_PIPE

#define FS_FLAG_PIPE   (1<<7)

◆ FS_FLAG_SOCKET

#define FS_FLAG_SOCKET   (1<<9)

◆ FS_FLAG_TTY

#define FS_FLAG_TTY   (1<<8)

◆ FS_STATUS_FOUND

#define FS_STATUS_FOUND   0x1

◆ FS_STATUS_NF

#define FS_STATUS_NF   0x0

◆ VFS_MEDIA_TYPE_AHCI

#define VFS_MEDIA_TYPE_AHCI   0x1

◆ VFS_MEDIA_TYPE_IDE

#define VFS_MEDIA_TYPE_IDE   0x2

◆ VFS_MEDIA_TYPE_OTHER

#define VFS_MEDIA_TYPE_OTHER   0x3

Typedef Documentation

◆ AuDirectoryEntry

◆ AuFileIOControl

◆ AuFileStatus

typedef struct _AuFileStatus_ AuFileStatus

◆ AuVFSContainer

AuVFSContainer – is a container which contains list of nodes/directories another directory will point to another newly created container.

◆ AuVFSNode

typedef struct __VFS_NODE__ AuVFSNode

◆ close_callback

typedef int(* close_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file)

◆ create_dir_callback

typedef struct __VFS_NODE__ *(* create_dir_callback) (struct __VFS_NODE__ *node, char *dirname)

◆ create_file_callback

typedef struct __VFS_NODE__ *(* create_file_callback) (struct __VFS_NODE__ *node, char *filename)

◆ fs_getblockfor

typedef size_t(* fs_getblockfor) (struct __VFS_NODE__ *fs, struct __VFS_NODE__ *file, uint64_t offset)

◆ iocontrol_callback

typedef int(* iocontrol_callback) (struct __VFS_NODE__ *file, int code, void *arg)

◆ open_callback

typedef struct __VFS_NODE__ *(* open_callback) (struct __VFS_NODE__ *node, char *path)

◆ opendir_callback

typedef struct __VFS_NODE__ *(* opendir_callback) (struct __VFS_NODE__ *fs, char *dirname)

◆ read_block_callback

typedef size_t(* read_block_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file, uint64_t *buffer)

◆ read_callback

typedef size_t(* read_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file, uint64_t *buffer, uint32_t length)

◆ readdir_callback

typedef int(* readdir_callback) (struct __VFS_NODE__ *fs, struct __VFS_NODE__ *dir, AuDirectoryEntry *dirent)

◆ remove_dir_callback

typedef int(* remove_dir_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file)

◆ remove_file_callback

typedef int(* remove_file_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file)

◆ write_callback

typedef size_t(* write_callback) (struct __VFS_NODE__ *node, struct __VFS_NODE__ *file, uint64_t *buffer, uint32_t length)

Function Documentation

◆ AuVFSAddFileSystem()

AU_EXTERN AU_EXPORT void AuVFSAddFileSystem ( AuVFSNode node)

AuVFSAddFileSystem – adds a file system to the vfs list.

Parameters
node– file system node to add

◆ AuVFSCreateDir()

AU_EXTERN AU_EXPORT AuVFSNode * AuVFSCreateDir ( AuVFSNode fsys,
char *  dirname 
)

AuVFSCreateDir – creates a new dir.

Parameters
fsys– Pointer to file system
dirname– directory name
Returns
pointer to newly created directory node

◆ AuVFSCreateFile()

AU_EXTERN AU_EXPORT AuVFSNode * AuVFSCreateFile ( AuVFSNode fsys,
char *  filename 
)

AuVFSCreateFile – create a new file.

Parameters
fsys– Pointer to file system
filename– filename
Returns
pointer to newly created file node

◆ AuVFSFind()

AU_EXTERN AU_EXPORT AuVFSNode * AuVFSFind ( char *  path)

AuVFSFind – Searches a filesystem an return it to the caller.

Parameters
path– path of the file system
Returns
pointer to file system extracted from path

◆ AuVFSGetBlockFor()

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.

Parameters
node– file system node
file– pointer to file structure
offset– byte offset
Returns
block number of that offset

◆ AuVFSInitialise()

void AuVFSInitialise ( )
extern

AuVFSInitialise – initialise the virtual file system.

◆ AuVFSNodeClose()

AU_EXTERN AU_EXPORT void AuVFSNodeClose ( AuVFSNode node,
AuVFSNode file 
)

AuVFSNodeClose – close a file system or file.

Parameters
node– file system node to use
file– file to close

◆ AuVFSNodeIOControl()

AU_EXTERN AU_EXPORT int AuVFSNodeIOControl ( AuVFSNode node,
int  code,
void *  arg 
)

AuVFSNodeIOControl – Calls node's iocontrol pointer.

Parameters
node– pointer to fsnode
code– code to pass
arg– extra arguments
Returns
return value returned by specific iocontrol handler to the caller

◆ AuVFSNodeRead()

AU_EXTERN AU_EXPORT size_t AuVFSNodeRead ( AuVFSNode node,
AuVFSNode file,
uint64_t buffer,
uint32_t  length 
)

AuVFSNodeRead – read from file system.

Parameters
node– file system node to use
file– file information to use
buffer– buffer to write to
length– length of the file
Returns
amount of data being read in bytes

◆ AuVFSNodeReadBlock()

AU_EXTERN AU_EXPORT size_t AuVFSNodeReadBlock ( AuVFSNode node,
AuVFSNode file,
uint64_t buffer 
)

AuVFSNodeReadBlock – read a block size data from file system.

Parameters
node– file system node to use
file– file node to use
buffer– buffer area to read to
Returns
always <= 4kib

◆ AuVFSNodeWrite()

AU_EXTERN AU_EXPORT void AuVFSNodeWrite ( AuVFSNode node,
AuVFSNode file,
uint64_t buffer,
uint32_t  length 
)

AuVFSNodeWrite – write to file system.

Parameters
node– file system node to use
file– file node to use
buffer– buffer to write
length– length of the data

◆ AuVFSOpen()

AU_EXTERN AU_EXPORT AuVFSNode * AuVFSOpen ( char *  path)

AuVFSOpen – Opens a file.

Parameters
path– path to open
path– path to open
Returns
pointer to file node, on success

◆ AuVFSRegisterRoot()

AU_EXTERN AU_EXPORT void AuVFSRegisterRoot ( AuVFSNode fs)

AuVFSRegisterRoot – register the root file system.

Parameters
fs– fsnode to add

◆ AuVFSRemoveDir()

int AuVFSRemoveDir ( AuVFSNode fsys,
AuVFSNode file 
)
extern

AuVFSRemoveFile –remove a file from a file system.

Parameters
fsys– Pointer to file system
file– Pointer to file to remove
Returns
0 on success, -1 on failure

AuVFSRemoveFile –remove a file from a file system.

Parameters
fsys– Pointer to file system
file– Pointer to directory needs to be deleted
Returns
0 on success, -1 on failure

◆ AuVFSRemoveFile()

int AuVFSRemoveFile ( AuVFSNode fsys,
AuVFSNode file 
)
extern

AuVFSRemoveFile –remove a file from a file system.

Parameters
fsys– Pointer to file system
file– Pointer to file to remove
Returns
0 on success, -1 on failure