UbixOS  2.0
descrip.c File Reference
#include <sys/descrip.h>
#include <sys/sysproto_posix.h>
#include <sys/thread.h>
#include <lib/kprintf.h>
#include <ubixos/endtask.h>
#include <lib/kmalloc.h>
#include <assert.h>
#include <sys/select.h>
#include <sys/ioctl.h>
Include dependency graph for descrip.c:

Go to the source code of this file.

Functions

int close (struct thread *td, struct close_args *uap)
 
int dup2 (struct thread *td, u_int32_t from, u_int32_t to)
 
int falloc (struct thread *td, struct file **resultfp, int *resultfd)
 
int fcntl (struct thread *td, struct sys_fcntl_args *uap)
 
int fdestroy (struct thread *td, struct file *fp, int fd)
 This destroys a thread local file descriptor. More...
 
int fstat (struct thread *td, struct sys_fstat_args *uap)
 
int getdtablesize (struct thread *td, struct getdtablesize_args *uap)
 return data table size More...
 
int getfd (struct thread *td, struct file **fp, int fd)
 get pointer to file fd in specified thread More...
 
int ioctl (struct thread *td, struct ioctl_args *uap)
 ioctl functionality not implimented yet More...
 
int sys_dup2 (struct thread *td, struct sys_dup2_args *args)
 
int sys_fcntl (struct thread *td, struct sys_fcntl_args *uap)
 
int sys_ioctl (struct thread *td, struct sys_ioctl_args *args)
 
int sys_select (struct thread *td, struct sys_select_args *args)
 

Function Documentation

◆ close()

int close ( struct thread td,
struct close_args uap 
)

Definition at line 161 of file descrip.c.

References close_args::fd, kfree(), kprintf(), thread::o_files, and thread::td_retval.

Here is the call graph for this function:

◆ dup2()

int dup2 ( struct thread td,
u_int32_t  from,
u_int32_t  to 
)

Definition at line 347 of file descrip.c.

References fileDescriptor::dup, fclose(), file::fd, fdestroy(), kmalloc(), kprintf(), MAX_FILES, memcpy(), and thread::o_files.

Referenced by sys_dup2().

Here is the call graph for this function:

◆ falloc()

int falloc ( struct thread td,
struct file **  resultfp,
int *  resultfd 
)

Definition at line 97 of file descrip.c.

References kfree(), kmalloc(), MAX_FILES, and thread::o_files.

Referenced by kern_openat(), pipe(), sys_openat(), sys_pipe2(), and sys_socket().

Here is the call graph for this function:

◆ fcntl()

int fcntl ( struct thread td,
struct sys_fcntl_args uap 
)

Definition at line 41 of file descrip.c.

References sys_fcntl_args::arg, sys_fcntl_args::cmd, file::f_flag, fclose(), FCNTLFLAGS, sys_fcntl_args::fd, fdestroy(), FFLAGS, kmalloc(), kprintf(), MAX_FILES, memcpy(), O_ACCMODE, thread::o_files, and thread::td_retval.

Referenced by sys_fcntl().

Here is the call graph for this function:

◆ fdestroy()

int fdestroy ( struct thread td,
struct file fp,
int  fd 
)

This destroys a thread local file descriptor.

This function will destroy the thread local file file specified as fd, for sanity it requires the file descriptor id and memory address to check before destroying.

Note
This text shall only show you, how such a "note" section is looking. There is nothing which really needs your notice, so you do not really need to read this section.
Parameters
tdPointer to thread which initiated the syscall.
fpPointer to the thread local file which you want to destroy.
fdFile descriptor id that points to the thread local file which you want to destroy.
Returns
The error return code of the function.
Return values
0The function is successfully executed
-1An error occurred

Definition at line 147 of file descrip.c.

References file::fd, kfree(), and thread::o_files.

Referenced by dup2(), fcntl(), kern_openat(), sys_close(), sys_openat(), and sys_socket().

Here is the call graph for this function:

◆ fstat()

int fstat ( struct thread td,
struct sys_fstat_args uap 
)

Definition at line 184 of file descrip.c.

References _current, sys_fstat_args::fd, kprintf(), thread::o_files, sys_fstat_args::sb, stat::st_blksize, stat::st_mode, and taskStruct::td.

Here is the call graph for this function:

◆ getdtablesize()

int getdtablesize ( struct thread td,
struct getdtablesize_args uap 
)

return data table size

Definition at line 175 of file descrip.c.

References kprintf(), O_FILES, and thread::td_retval.

Here is the call graph for this function:

◆ getfd()

int getfd ( struct thread td,
struct file **  fp,
int  fd 
)

get pointer to file fd in specified thread

Returns
returns fp

Definition at line 213 of file descrip.c.

References file::fd, kprintf(), and thread::o_files.

Referenced by read(), sys_close(), sys_fchdir(), sys_fstat(), sys_fstatat(), sys_fstatfs(), sys_getdirentries(), sys_lseek(), sys_mmap(), sys_pread(), sys_read(), sys_sendto(), sys_setsockopt(), and sys_write().

Here is the call graph for this function:

◆ ioctl()

int ioctl ( struct thread td,
struct ioctl_args uap 
)

ioctl functionality not implimented yet

Returns
NULL for now

Definition at line 203 of file descrip.c.

References thread::td_retval.

◆ sys_dup2()

int sys_dup2 ( struct thread td,
struct sys_dup2_args args 
)

Definition at line 375 of file descrip.c.

References dup2(), sys_dup2_args::from, thread::td_retval, and sys_dup2_args::to.

Here is the call graph for this function:

◆ sys_fcntl()

int sys_fcntl ( struct thread td,
struct sys_fcntl_args uap 
)

Definition at line 93 of file descrip.c.

References fcntl().

Here is the call graph for this function:

◆ sys_ioctl()

◆ sys_select()

int sys_select ( struct thread td,
struct sys_select_args args 
)