# UbixOS V2: src/sys/include/vfs/file.h File Reference

# file.h File Reference

`#include <ubixos/types.h>`
`#include <ubixfs/dirCache.h>`
`#include <vfs/mount.h>`

Go to the source code of this file.

## Data Structures

struct | dmadat
struct | fileDescriptorStruct
struct | userFileDescriptorStruct

## Defines

#define | DEV_BSHIFT 9
#define | DEV_BSIZE (1<<DEV_BSHIFT)
#define | SBLOCKSIZE 8192
#define | SEEK_SET 0x0
#define | VBLKSHIFT 12
#define | VBLKSIZE (1 << VBLKSHIFT)

## Typedefs

typedef fileDescriptorStruct | fileDescriptor
typedef userFileDescriptorStruct | userFileDescriptor

## Functions

void | chDir (const char *path)
int | fclose (fileDescriptor *)
int | feof (fileDescriptor *fd)
int | fgetc (fileDescriptor *fd)
fileDescriptor * | fopen (const char *, const char *)
size_t | fread (void *ptr, size_t size, size_t nmemb, fileDescriptor *fd)
int | fseek (fileDescriptor *, long, int)
size_t | fwrite (void *ptr, int size, int nmemb, fileDescriptor *fd)
void | sysChDir (const char *path)
void | sysFseek (userFileDescriptor *, long, int)
int | unlink (const char *path)
char * | verifyDir (const char *path)

## Variables

fileDescriptor * | fdTable

## Define Documentation

#define DEV_BSHIFT 9

Definition at line 36 of file file.h.

#define DEV_BSIZE (1<<DEV_BSHIFT)

Definition at line 37 of file file.h.

#define SBLOCKSIZE 8192

Definition at line 35 of file file.h.

#define SEEK_SET 0x0

Definition at line 31 of file file.h.

Referenced by DiskFS::read(), and DiskFS::write().

#define VBLKSHIFT 12

Definition at line 33 of file file.h.

Referenced by fsread().

#define VBLKSIZE (1 << VBLKSHIFT)

Definition at line 34 of file file.h.

Referenced by fsread().

## Typedef Documentation

typedef struct fileDescriptorStruct fileDescriptor

typedef struct userFileDescriptorStruct userFileDescriptor

## Function Documentation

void chDir | ( | const char * | path | ) |

int fclose | ( | fileDescriptor * |  | ) |

Definition at line 396 of file file.c.

References assert, fdTable, fdTable_lock, kfree(), fileDescriptor::next, NULL, vitalsStruct::openFiles, fileDescriptor::prev, spinLock(), spinUnlock(), systemVitals, and x1.

Referenced by dev_ramDestroy(), dev_ramDrive(), execFile(), kmod_load(), ldEnable(), bTree::Save(), sysExec(), sysFclose(), sysMkDir(), and systemTask().

int feof | ( | fileDescriptor * | fd | ) |

Definition at line 213 of file file.c.

References fdEof.

int fgetc | ( | fileDescriptor * | fd | ) |

Definition at line 244 of file file.c.

References fileDescriptor::offset.

Referenced by sysFgetc().

fileDescriptor* fopen | ( | const char * | ,
|  | const char * |  |
| ) |  |  |

Definition at line 267 of file file.c.

References fdOpen, fdTable, fdTable_lock, fileAppend, fileBinary, fileRead, fileWrite, kfree(), kmalloc(), kprintf(), fileDescriptor::next, NULL, fileDescriptor::offset, vitalsStruct::openFiles, fileDescriptor::prev, spinLock(), spinUnlock(), sprintf(), strstr(), strtok(), systemVitals, and vfs_findMount().

Referenced by dev_ramDestroy(), dev_ramDrive(), DiskFS::DiskFS(), execFile(), kmod_load(), ldEnable(), bTree::Save(), sysExec(), sysFopen(), sysMkDir(), and tcpdump_init().

size_t fread | ( | void * | ptr,
|  | size_t | size,
|  | size_t | nmemb,
|  | fileDescriptor * | fd |
| ) |  |  |

Definition at line 178 of file file.c.

References assert, and fileDescriptor::offset.

Referenced by dev_ramDrive(), execFile(), kmod_load(), ldEnable(), DiskFS::read(), sysExec(), and sysFread().

int fseek | ( | fileDescriptor * | ,
|  | long | ,
|  | int |  |
| ) |  |  |

Definition at line 201 of file file.c.

References fileDescriptor::offset.

Referenced by execFile(), kmod_load(), ldEnable(), DiskFS::read(), sysExec(), and DiskFS::write().

size_t fwrite | ( | void * | ptr,
|  | int | size,
|  | int | nmemb,
|  | fileDescriptor * | fd |
| ) |  |  |

Definition at line 193 of file file.c.

References fileDescriptor::offset.

Referenced by dev_ramDestroy(), bTree::Save(), sysFwrite(), and DiskFS::write().

void sysChDir | ( | const char * | path | ) |

Definition at line 102 of file file.c.

References _current, osInfo::cwd, taskStruct::oInfo, sprintf(), and strstr().

void sysFseek | ( | userFileDescriptor * | ,
|  | long | ,
|  | int |  |
| ) |  |  |

Definition at line 92 of file file.c.

References userFileDescriptorStruct::fd, NULL, and fileDescriptorStruct::offset.

int unlink | ( | const char * | path | ) |

Definition at line 478 of file file.c.

References vfs_mountPoint::fs, vfs_mountPoint::mountPoint, NULL, strtok(), vfs_findMount(), and fileSystem::vfsUnlink.

Referenced by sysUnlink().

char* verifyDir | ( | const char * | path | ) |

## Variable Documentation

fileDescriptor* fdTable

Definition at line 45 of file file.c.

Referenced by fclose(), and fopen().