# ubixfs.h File Reference

`#include <ubixos/types.h>`
`#include <sys/device.h>`
`#include <vfs/file.h>`

Go to the source code of this file.

## Data Structures
struct | blockAllocationTableEntry
struct | bootSect
| Bootsector structure. More...
struct | directoryEntry
| UbixFS Directory Entry. More...
struct | partitionInformation
struct | ubixDiskLabel
| Partition Information. More...
struct | ubixDiskLabel.drivePartitions
struct | ubixFsInfo
## Defines
#define | UBIXDISKMAGIC ((uInt32)0x45)
#define | MAXPARTITIONS 4
#define | blockSize 8
#define | blockByteSize blockSize*512
#define | EOBC -1
#define | typeFile 1
#define | typeContainer 2
#define | typeDirectory 4
#define | typeDeleted 8
## Functions
int | readFile (char *file)
int | writeFileByte (int ch, fileDescriptor *fd, long offset)
int | openFileUbixFS (char *file, fileDescriptor *fd)
int | mkDirUbixFS (char *dir, fileDescriptor *fd)
int | getFreeBlocks (int count, fileDescriptor *fd)
int | enableUbixFS ()
void | initUbixFS (struct mountPoints *mp)
int | readUbixFS (fileDescriptor *fd, char *data, long offset, long size)
int | writeUbixFS (fileDescriptor *fd, char *data, long offset, long size)
void | syncBat (struct mountPoints *mp)
int | freeBlocks (int block, fileDescriptor *fd)
int | addDirEntry (struct directoryEntry *dir, fileDescriptor *fd)
void | ubixFSUnlink (char *path, struct mountPoints *mp)

## Define Documentation

#define blockByteSize blockSize*512

#define blockSize 8

#define EOBC -1

#define MAXPARTITIONS 4

#define typeContainer 2

#define typeDeleted 8

#define typeDirectory 4

#define typeFile 1

#define UBIXDISKMAGIC ((uInt32)0x45)

| The disk magic number

## Function Documentation

int addDirEntry | ( | struct directoryEntry * | dir,
|  | fileDescriptor * | fd
| ) |

int enableUbixFS | ( |  | ) |

| Registers UbixFS functions with the virtual file-system (using vfsRegisterFS). Returns 1 if a failure happened, and 0 if success.

int freeBlocks | ( | int | block,
|  | fileDescriptor * | fd
| ) |

int getFreeBlocks | ( | int | count,
|  | fileDescriptor * | fd
| ) |

void initUbixFS | ( | struct mountPoints * | mp | ) |

| Sets up the Ubix filesystem with appropriate data. If the medium is a hard-drive (or any medium?), it looks in the partition table.

int mkDirUbixFS | ( | char * | dir,
|  | fileDescriptor * | fd
| ) |

| Makes a directory with the name directory. Returns 0

int openFileUbixFS | ( | char * | file,
|  | fileDescriptor * | fd
| ) |

| Depending on fd->mode, it fills fd with data about the file (start, size, permissions etc.), if the string file is matched with a filename in the current directory. Returns 1 on success, and 0 on failure. The fileDescriptor struct definition can be found in VFS

int readFile | ( | char * | file | ) |

int readUbixFS | ( | fileDescriptor * | fd,
|  | char * | data,
|  | long | offset,
|  | long | size
| ) |

| Reads part (or can be whole) of a file into the memory pointed to by data. Returns size if successful, and 0 on failure.

void syncBat | ( | struct mountPoints * | mp | ) |

void ubixFSUnlink | ( | char * | path,
|  | struct mountPoints * | mp
| ) |

| Effectively erases the file or directory from the filesystem

int writeFileByte | ( | int | ch,
|  | fileDescriptor * | fd,
|  | long | offset
| ) |

int writeUbixFS | ( | fileDescriptor * | fd,
|  | char * | data,
|  | long | offset,
|  | long | size
| ) |

| Writes part (or can be whole) of a file from the memory pointed to by data. Extends file if necessary. Returns size.