UbixOS V2 2.0

Functions | Variables
file.c File Reference
`#include <ubixos/sched.h>`
`#include <vfs/vfs.h>`
`#include <ubixos/vitals.h>`
`#include <ubixos/kpanic.h>`
`#include <ubixos/spinlock.h>`
`#include <lib/kmalloc.h>`
`#include <string.h>`
`#include <vmm/paging.h>`
`#include <lib/kprintf.h>`
`#include <assert.h>`
`#include <sys/descrip.h>`
Include dependency graph for file.c:

Go to the source code of this file.

## Functions
int | fclose (fileDescriptor_t *fd)
int | feof (fileDescriptor_t *fd)
int | fgetc (fileDescriptor_t *fd)
fileDescriptor_t * | fopen (const char *file, const char *flags)
int | fputc (int ch, fileDescriptor_t *fd)
size_t | fread (void *ptr, size_t size, size_t nmemb, fileDescriptor_t *fd)
int | fseek (fileDescriptor_t *tmpFd, long offset, int whence)
size_t | fwrite (void *ptr, int size, int nmemb, fileDescriptor_t *fd)
int | sys_chdir (struct thread *td, struct sys_chdir_args *args)
int | sys_fchdir (struct thread *td, struct sys_fchdir_args *args)
int | sys_fclose (struct thread *td, struct sys_fclose_args *args)
int | sys_fgetc (struct thread *td, struct sys_fgetc_args *args)
int | sys_fopen (struct thread *td, struct sys_fopen_args *args)
int | sys_fread (struct thread *td, struct sys_fread_args *args)
int | sys_fseek (struct thread *td, struct sys_fseek_args *args)
int | sys_fwrite (struct thread *td, struct sys_fwrite_args *uap)
int | sys_lseek (struct thread *td, struct sys_lseek_args *args)
int | sys_rename (struct thread *td, struct sys_rename_args *args)
void | sysFwrite (char *ptr, int size, userFileDescriptor *userFd)
void | sysMkDir (const char *path)
void | sysRmDir ()
int | sysUnlink (const char *path, int *retVal)
int | unlink (const char *node)

## Variables
fileDescriptor_t * | fdTable = 0x0
fileDescriptor_t * | vfs_fileTable = 0x0

## Function Documentation

## ◆ fclose()

int fclose | ( | fileDescriptor_t * | fd | ) |

Definition at line 526 of file file.c.

References file::fd, and spinLock().

Referenced by _sys_stat(), dup2(), elf_load_file(), execFile(), fcntl(), kmod_load(), ldEnable(), sys_close(), sys_fclose(), sys_fstatat(), sysExec(), sysMkDir(), and systemTask().

Here is the call graph for this function:

## ◆ feof()

int feof | ( | fileDescriptor_t * | fd | ) |

Definition at line 337 of file file.c.

References file::fd, fdEof, and fileDescriptor::status.

## ◆ fgetc()

int fgetc | ( | fileDescriptor_t * | fd | ) |

Definition at line 366 of file file.c.

References file::fd, vfs_mountPoint::fs, fileDescriptor::mp, fileDescriptor::offset, and fileSystem::vfsRead.

Referenced by sys_fgetc().

## ◆ fopen()

fileDescriptor_t* fopen | ( | const char * | file,
|  | const char * | flags
| ) |  |

Definition at line 388 of file file.c.

References _current, fileDescriptor::buffer, osInfo::cwd, file, fileAppend, fileBinary, fileDescriptor::fileName, fileRead, fileWrite, vfs_mountPoint::fs, kfree(), kmalloc(), kprintf(), memset(), fileDescriptor::mode, fileDescriptor::mp, NULL, taskStruct::oInfo, spinUnlock(), sprintf(), strcpy(), strstr(), strtok(), vfs_findMount(), and fileSystem::vfsOpenFile.

Referenced by _sys_stat(), elf_load_file(), execFile(), kern_openat(), kmod_load(), ldEnable(), sys_fopen(), sys_fstatat(), sys_openat(), sys_statfs(), sysExec(), sysMkDir(), and tcpdump_init().

Here is the call graph for this function:

## ◆ fputc()

int fputc | ( | int | ch,
|  | fileDescriptor_t * | fd
| ) |  |

Definition at line 350 of file file.c.

References file::fd, vfs_mountPoint::fs, fileDescriptor::mp, fileDescriptor::offset, and fileSystem::vfsWrite.

## ◆ fread()

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

Definition at line 291 of file file.c.

References assert, file::fd, vfs_mountPoint::fs, fileDescriptor::mp, fileDescriptor::offset, and fileSystem::vfsRead.

Referenced by elf_load_file(), execFile(), kmod_load(), ldEnable(), read(), sys_fread(), sys_getdirentries(), sys_mmap(), sys_pread(), sys_read(), and sysExec().

## ◆ fseek()

int fseek | ( | fileDescriptor_t * | tmpFd,
|  | long | offset,
|  | int | whence
| ) |  |

Definition at line 326 of file file.c.

Referenced by elf_load_file(), execFile(), kmod_load(), ldEnable(), sys_mmap(), and sysExec().

## ◆ fwrite()

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

Definition at line 311 of file file.c.

Referenced by sys_fwrite(), sys_write(), and sysFwrite().

## ◆ sys_chdir()

int sys_chdir | ( | struct thread * | td,
|  | struct sys_chdir_args * | args
| ) |  |

Definition at line 186 of file file.c.

References _current, osInfo::cwd, taskStruct::oInfo, sys_chdir_args::path, sprintf(), strstr(), and thread::td_retval.

Here is the call graph for this function:

## ◆ sys_fchdir()

int sys_fchdir | ( | struct thread * | td,
|  | struct sys_fchdir_args * | args
| ) |  |

Definition at line 197 of file file.c.

References _current, osInfo::cwd, file::fd, sys_fchdir_args::fd, fileDescriptor::fileName, getfd(), taskStruct::oInfo, sprintf(), and strstr().

Here is the call graph for this function:

## ◆ sys_fclose()

int sys_fclose | ( | struct thread * | td,
|  | struct sys_fclose_args * | args
| ) |  |

Definition at line 277 of file file.c.

References fclose(), userFileDescriptorStruct::fd, sys_fclose_args::FILE, and NULL.

Here is the call graph for this function:

## ◆ sys_fgetc()

int sys_fgetc | ( | struct thread * | td,
|  | struct sys_fgetc_args * | args
| ) |  |

Definition at line 76 of file file.c.

References _current, userFileDescriptorStruct::fd, fgetc(), sys_fgetc_args::FILE, getchar(), sched_yield(), thread::td_retval, taskStruct::term, and tty_foreground.

Here is the call graph for this function:

## ◆ sys_fopen()

int sys_fopen | ( | struct thread * | td,
|  | struct sys_fopen_args * | args
| ) |  |

Definition at line 237 of file file.c.

References userFileDescriptorStruct::fd, userFileDescriptorStruct::fdSize, sys_fopen_args::FILE, fopen(), kprintf(), sys_fopen_args::mode, NULL, sys_fopen_args::path, and fileDescriptor::size.

Here is the call graph for this function:

## ◆ sys_fread()

int sys_fread | ( | struct thread * | td,
|  | struct sys_fread_args * | args
| ) |  |

Definition at line 258 of file file.c.

References userFileDescriptorStruct::fd, sys_fread_args::FILE, fread(), sys_fread_args::nmemb, NULL, sys_fread_args::ptr, sys_fread_args::size, and thread::td_retval.

Here is the call graph for this function:

## ◆ sys_fseek()

int sys_fseek | ( | struct thread * | td,
|  | struct sys_fseek_args * | args
| ) |  |

Definition at line 119 of file file.c.

References userFileDescriptorStruct::fd, sys_fseek_args::FILE, kprintf(), NULL, fileDescriptor::offset, sys_fseek_args::offset, thread::td_retval, and sys_fseek_args::whence.

Here is the call graph for this function:

## ◆ sys_fwrite()

int sys_fwrite | ( | struct thread * | td,
|  | struct sys_fwrite_args * | uap
| ) |  |

Definition at line 47 of file file.c.

References _current, sys_fwrite_args::buf, userFileDescriptorStruct::fd, sys_fwrite_args::fd, fwrite(), kprintf(), sys_fwrite_args::nbytes, thread::td_retval, taskStruct::term, and tty_print().

Here is the call graph for this function:

## ◆ sys_lseek()

int sys_lseek | ( | struct thread * | td,
|  | struct sys_lseek_args * | args
| ) |  |

Definition at line 149 of file file.c.

References file::fd, sys_lseek_args::fd, getfd(), kprintf(), fileDescriptor::offset, sys_lseek_args::offset, SEEK_CUR, SEEK_SET, thread::td_retval, and sys_lseek_args::whence.

Here is the call graph for this function:

## ◆ sys_rename()

int sys_rename | ( | struct thread * | td,
|  | struct sys_rename_args * | args
| ) |  |

Definition at line 220 of file file.c.

References thread::td_retval.

## ◆ sysFwrite()

void sysFwrite | ( | char * | ptr,
|  | int | size,
|  | userFileDescriptor * | userFd
| ) |  |

Definition at line 66 of file file.c.

References _current, userFileDescriptorStruct::fd, fwrite(), taskStruct::term, and tty_print().

Here is the call graph for this function:

## ◆ sysMkDir()

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

Definition at line 576 of file file.c.

References _current, osInfo::cwd, fclose(), fopen(), vfs_mountPoint::fs, kprintf(), fileDescriptor::mp, NULL, taskStruct::oInfo, sprintf(), strstr(), strtok(), and fileSystem::vfsMakeDir.

Here is the call graph for this function:

## ◆ sysRmDir()

void sysRmDir | ( |  | ) |

Definition at line 115 of file file.c.

## ◆ sysUnlink()

int sysUnlink | ( | const char * | path,
|  | int * | retVal
| ) |  |

Definition at line 225 of file file.c.

## ◆ unlink()

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

Definition at line 618 of file file.c.

## Variable Documentation

## ◆ fdTable

fileDescriptor_t* fdTable = 0x0

Definition at line 43 of file file.c.

## ◆ vfs_fileTable

fileDescriptor_t* vfs_fileTable = 0x0

Definition at line 45 of file file.c.