UbixOS  2.0
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 "../fat/fat_filelib.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_tfopen (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_tfdTable = 0x0
 
fileDescriptor_tvfs_fileTable = 0x0
 

Function Documentation

◆ fclose()

int fclose ( fileDescriptor_t fd)

Definition at line 533 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 343 of file file.c.

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

◆ fgetc()

int fgetc ( fileDescriptor_t fd)

Definition at line 372 of file file.c.

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

Referenced by sys_fgetc().

Here is the call graph for this function:

◆ fopen()

◆ fputc()

int fputc ( int  ch,
fileDescriptor_t fd 
)

◆ fread()

◆ fseek()

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

Definition at line 332 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 317 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 192 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 203 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 283 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 81 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 
)

◆ sys_fread()

int sys_fread ( struct thread td,
struct sys_fread_args args 
)

Definition at line 264 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 124 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 
)

◆ sys_lseek()

int sys_lseek ( struct thread td,
struct sys_lseek_args args 
)

Definition at line 154 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 226 of file file.c.

References thread::td_retval.

◆ sysFwrite()

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

Definition at line 71 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 587 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 120 of file file.c.

◆ sysUnlink()

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

Definition at line 231 of file file.c.

◆ unlink()

int unlink ( const char *  node)

Definition at line 629 of file file.c.

Variable Documentation

◆ fdTable

fileDescriptor_t* fdTable = 0x0

Definition at line 45 of file file.c.

◆ vfs_fileTable

fileDescriptor_t* vfs_fileTable = 0x0

Definition at line 47 of file file.c.