IBNOS
Functions | Variables
Filesystem

Functions

struct directorydirectoryCreate (struct directory *parent, char *name, uint32_t nameLength)
 Creates a new kernel directory object. More...
 
struct filefileCreate (struct directory *parent, char *name, uint32_t nameLength, uint8_t *staticBuffer, uint32_t staticSize)
 Creates a new kernel file object. More...
 
struct openedFilefileOpen (struct file *file)
 Creates a new kernel openedFile object. More...
 
struct openedDirectorydirectoryOpen (struct directory *directory)
 Creates a new kernel openedDirectory object. More...
 
void fileSystemInit (void *addr, uint32_t length)
 Initializes the root file system. More...
 
struct directoryfileSystemIsValidDirectory (struct object *obj)
 Checks if a given object is of the type directory and casts it if possible. More...
 
struct filefileSystemIsValidFile (struct object *obj)
 Checks if a given object is of the type file and casts it if possible. More...
 
struct directoryfileSystemGetRoot ()
 Returns a reference to the root node of the file system. More...
 
struct directoryfileSystemSearchDirectory (struct directory *directory, char *path, uint32_t pathLength, bool create)
 Opens or creates a directory. More...
 
struct filefileSystemSearchFile (struct directory *directory, char *path, uint32_t pathLength, bool create)
 Opens or creates a file. More...
 

Variables

struct directoryfileSystemRoot
 

Detailed Description

The filesystem implementation is still work in progress. It is similar to file handling on other platforms and based on named files and directory structures.

Function Documentation

◆ directoryCreate()

struct directory* directoryCreate ( struct directory parent,
char *  name,
uint32_t  nameLength 
)

Creates a new kernel directory object.

Parameters
parentPointer to the parent directory
nameName of the directory or NULL if the directory doesn't have a name
nameLengthLength of the name
Returns
Pointer to the kernel directory object

Definition at line 174 of file filesystem.c.

◆ directoryOpen()

struct openedDirectory* directoryOpen ( struct directory directory)

Creates a new kernel openedDirectory object.

Parameters
directoryPointer to the directory
Returns
Pointer to the kernel openedDirectory object

Definition at line 699 of file filesystem.c.

◆ fileCreate()

struct file* fileCreate ( struct directory parent,
char *  name,
uint32_t  nameLength,
uint8_t *  staticBuffer,
uint32_t  staticSize 
)

Creates a new kernel file object.

Parameters
parentPointer to the parent directory
nameName of the file or NULL if the file doesn't have a name
nameLengthLength of the name
staticBufferOptional pointer to some heap memory
staticSizeSize of the heap memory buffer
Returns
Pointer to the kernel file object

Definition at line 333 of file filesystem.c.

◆ fileOpen()

struct openedFile* fileOpen ( struct file file)

Creates a new kernel openedFile object.

Parameters
filePointer to the file
Returns
Pointer to the kernel openedFile object

Definition at line 513 of file filesystem.c.

◆ fileSystemGetRoot()

struct directory* fileSystemGetRoot ( )

Returns a reference to the root node of the file system.

This function returns a reference to the root node of the file system and increases the reference count. When the reference is not needed anymore you have to release the object.

Returns
Reference to the root node of the file system

Definition at line 985 of file filesystem.c.

◆ fileSystemInit()

void fileSystemInit ( void *  addr,
uint32_t  length 
)

Initializes the root file system.

Definition at line 858 of file filesystem.c.

◆ fileSystemIsValidDirectory()

struct directory* fileSystemIsValidDirectory ( struct object obj)

Checks if a given object is of the type directory and casts it if possible.

Use this functio to safely convert an arbitrary object to a directory object pointer. If the object doesn't have the right type (or a NULL pointer is passed), then NULL will be returned.

Parameters
objArbitrary kernel object
Returns
Pointer to a kernel directory object or NULL

Definition at line 934 of file filesystem.c.

◆ fileSystemIsValidFile()

struct file* fileSystemIsValidFile ( struct object obj)

Checks if a given object is of the type file and casts it if possible.

Use this functio to safely convert an arbitrary object to a file object pointer. If the object doesn't have the right type (or a NULL pointer is passed), then NULL will be returned.

Parameters
objArbitrary kernel object
Returns
Pointer to a kernel file object or NULL

Definition at line 960 of file filesystem.c.

◆ fileSystemSearchDirectory()

struct directory* fileSystemSearchDirectory ( struct directory directory,
char *  path,
uint32_t  pathLength,
bool  create 
)

Opens or creates a directory.

This function will search for a given directory in the file system root. If create is true, then the directory object is created if it doesn't exist yet

Parameters
directoryDirectory in which to search for the specific directory or NULL
pathPath to the directory
pathLengthLength of the directory
createIf true the directory (including parent directories) will be created if it doesn't exist yet
Returns
Pointer to the directory object

Definition at line 1004 of file filesystem.c.

◆ fileSystemSearchFile()

struct file* fileSystemSearchFile ( struct directory directory,
char *  path,
uint32_t  pathLength,
bool  create 
)

Opens or creates a file.

This function will search for a given file in the file system root. If create is specified the new file object is created if it doesn't exist yet

Parameters
directoryDirectory in which to search for the specific file or NULL
pathPath to the file
pathLengthLength of the filename
createIf true the file (including parent directories) will be created if it doesn't exist yet
Returns
Pointer to the file object

Definition at line 1092 of file filesystem.c.

Variable Documentation

◆ fileSystemRoot

struct directory* fileSystemRoot

Definition at line 41 of file filesystem.c.