PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
vfs.c File Reference
#include <kernel/fs/vfs.h>
#include <kernel/cpu/syscall.h>
#include <kernel/fs/cwd.h>
#include <kernel/fs/dentry.h>
#include <kernel/fs/file_table.h>
#include <kernel/fs/inode.h>
#include <kernel/fs/key.h>
#include <kernel/fs/mount.h>
#include <kernel/fs/path.h>
#include <kernel/fs/sysfs.h>
#include <kernel/log/log.h>
#include <kernel/log/panic.h>
#include <kernel/mem/vmm.h>
#include <kernel/proc/process.h>
#include <kernel/sched/sched.h>
#include <kernel/sched/clock.h>
#include <kernel/sched/timer.h>
#include <kernel/sched/wait.h>
#include <kernel/sync/mutex.h>
#include <kernel/sync/rwlock.h>
#include <kernel/utils/ref.h>
#include <kernel/cpu/regs.h>
#include <assert.h>
#include <errno.h>
#include <stdint.h>
#include <string.h>
#include <sys/io.h>
#include <sys/list.h>
Include dependency graph for vfs.c:

Go to the source code of this file.

Data Structures

struct  vfs_poll_ctx_t
 

Functions

static uint64_t vfs_create (path_t *path, const pathname_t *pathname, namespace_t *ns)
 
static uint64_t vfs_open_lookup (path_t *path, const pathname_t *pathname, namespace_t *namespace)
 
file_tvfs_open (const pathname_t *pathname, process_t *process)
 Open a file.
 
uint64_t vfs_open2 (const pathname_t *pathname, file_t *files[2], process_t *process)
 Open one file, returning two file handles.
 
file_tvfs_openat (const path_t *from, const pathname_t *pathname, process_t *process)
 Open a file relative to another path.
 
uint64_t vfs_read (file_t *file, void *buffer, uint64_t count)
 Read from a file.
 
uint64_t vfs_write (file_t *file, const void *buffer, uint64_t count)
 Write to a file.
 
uint64_t vfs_seek (file_t *file, int64_t offset, seek_origin_t origin)
 Seek in a file.
 
uint64_t vfs_ioctl (file_t *file, uint64_t request, void *argp, uint64_t size)
 Perform an ioctl operation on a file.
 
void * vfs_mmap (file_t *file, void *address, uint64_t length, pml_flags_t flags)
 Memory map a file.
 
static uint64_t vfs_poll_ctx_init (vfs_poll_ctx_t *ctx, poll_file_t *files, uint64_t amount)
 
static uint64_t vfs_poll_ctx_check_events (vfs_poll_ctx_t *ctx, poll_file_t *files, uint64_t amount)
 
uint64_t vfs_poll (poll_file_t *files, uint64_t amount, clock_t timeout)
 Poll multiple files.
 
uint64_t vfs_getdents (file_t *file, dirent_t *buffer, uint64_t count)
 Get directory entries from a directory file.
 
uint64_t vfs_stat (const pathname_t *pathname, stat_t *buffer, process_t *process)
 Get file information.
 
uint64_t vfs_link (const pathname_t *oldPathname, const pathname_t *newPathname, process_t *process)
 Make the same file appear twice in the filesystem.
 
uint64_t vfs_remove (const pathname_t *pathname, process_t *process)
 Remove a file or directory.
 
uint64_t vfs_id_get (void)
 Generates a new unique ID, to be used for any VFS object.
 
 SYSCALL_DEFINE (SYS_OPEN, fd_t, const char *pathString)
 
 SYSCALL_DEFINE (SYS_OPEN2, uint64_t, const char *pathString, fd_t fds[2])
 
 SYSCALL_DEFINE (SYS_OPENAT, fd_t, fd_t from, const char *pathString)
 
 SYSCALL_DEFINE (SYS_READ, uint64_t, fd_t fd, void *buffer, uint64_t count)
 
 SYSCALL_DEFINE (SYS_WRITE, uint64_t, fd_t fd, const void *buffer, uint64_t count)
 
 SYSCALL_DEFINE (SYS_SEEK, uint64_t, fd_t fd, int64_t offset, seek_origin_t origin)
 
 SYSCALL_DEFINE (SYS_IOCTL, uint64_t, fd_t fd, uint64_t request, void *argp, uint64_t size)
 
 SYSCALL_DEFINE (SYS_MMAP, void *, fd_t fd, void *address, uint64_t length, prot_t prot)
 
 SYSCALL_DEFINE (SYS_POLL, uint64_t, pollfd_t *fds, uint64_t amount, clock_t timeout)
 
 SYSCALL_DEFINE (SYS_GETDENTS, uint64_t, fd_t fd, dirent_t *buffer, uint64_t count)
 
 SYSCALL_DEFINE (SYS_STAT, uint64_t, const char *pathString, stat_t *buffer)
 
 SYSCALL_DEFINE (SYS_LINK, uint64_t, const char *oldPathString, const char *newPathString)
 
 SYSCALL_DEFINE (SYS_REMOVE, uint64_t, const char *pathString)
 

Function Documentation

◆ vfs_create()

static uint64_t vfs_create ( path_t path,
const pathname_t pathname,
namespace_t ns 
)
static

Definition at line 33 of file vfs.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vfs_open_lookup()

static uint64_t vfs_open_lookup ( path_t path,
const pathname_t pathname,
namespace_t namespace 
)
static

Definition at line 79 of file vfs.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vfs_poll_ctx_init()

static uint64_t vfs_poll_ctx_init ( vfs_poll_ctx_t ctx,
poll_file_t files,
uint64_t  amount 
)
static

Definition at line 371 of file vfs.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vfs_poll_ctx_check_events()

static uint64_t vfs_poll_ctx_check_events ( vfs_poll_ctx_t ctx,
poll_file_t files,
uint64_t  amount 
)
static

Definition at line 409 of file vfs.c.

Here is the caller graph for this function:

◆ SYSCALL_DEFINE() [1/13]

SYSCALL_DEFINE ( SYS_OPEN  ,
fd_t  ,
const char *  pathString 
)

Definition at line 772 of file vfs.c.

Here is the call graph for this function:

◆ SYSCALL_DEFINE() [2/13]

SYSCALL_DEFINE ( SYS_OPEN2  ,
uint64_t  ,
const char *  pathString,
fd_t  fds[2] 
)

Definition at line 793 of file vfs.c.

Here is the call graph for this function:

◆ SYSCALL_DEFINE() [3/13]

SYSCALL_DEFINE ( SYS_OPENAT  ,
fd_t  ,
fd_t  from,
const char *  pathString 
)

Definition at line 841 of file vfs.c.

Here is the call graph for this function:

◆ SYSCALL_DEFINE() [4/13]

SYSCALL_DEFINE ( SYS_READ  ,
uint64_t  ,
fd_t  fd,
void *  buffer,
uint64_t  count 
)

Definition at line 881 of file vfs.c.

Here is the call graph for this function:

◆ SYSCALL_DEFINE() [5/13]

SYSCALL_DEFINE ( SYS_WRITE  ,
uint64_t  ,
fd_t  fd,
const void *  buffer,
uint64_t  count 
)

Definition at line 902 of file vfs.c.

Here is the call graph for this function:

◆ SYSCALL_DEFINE() [6/13]

SYSCALL_DEFINE ( SYS_SEEK  ,
uint64_t  ,
fd_t  fd,
int64_t  offset,
seek_origin_t  origin 
)

Definition at line 923 of file vfs.c.

Here is the call graph for this function:

◆ SYSCALL_DEFINE() [7/13]

SYSCALL_DEFINE ( SYS_IOCTL  ,
uint64_t  ,
fd_t  fd,
uint64_t  request,
void *  argp,
uint64_t  size 
)

Definition at line 937 of file vfs.c.

Here is the call graph for this function:

◆ SYSCALL_DEFINE() [8/13]

SYSCALL_DEFINE ( SYS_MMAP  ,
void *  ,
fd_t  fd,
void *  address,
uint64_t  length,
prot_t  prot 
)

Definition at line 958 of file vfs.c.

Here is the call graph for this function:

◆ SYSCALL_DEFINE() [9/13]

SYSCALL_DEFINE ( SYS_POLL  ,
uint64_t  ,
pollfd_t fds,
uint64_t  amount,
clock_t  timeout 
)

Definition at line 992 of file vfs.c.

Here is the call graph for this function:

◆ SYSCALL_DEFINE() [10/13]

SYSCALL_DEFINE ( SYS_GETDENTS  ,
uint64_t  ,
fd_t  fd,
dirent_t buffer,
uint64_t  count 
)

Definition at line 1049 of file vfs.c.

Here is the call graph for this function:

◆ SYSCALL_DEFINE() [11/13]

SYSCALL_DEFINE ( SYS_STAT  ,
uint64_t  ,
const char *  pathString,
stat_t buffer 
)

Definition at line 1070 of file vfs.c.

Here is the call graph for this function:

◆ SYSCALL_DEFINE() [12/13]

SYSCALL_DEFINE ( SYS_LINK  ,
uint64_t  ,
const char *  oldPathString,
const char *  newPathString 
)

Definition at line 1090 of file vfs.c.

Here is the call graph for this function:

◆ SYSCALL_DEFINE() [13/13]

SYSCALL_DEFINE ( SYS_REMOVE  ,
uint64_t  ,
const char *  pathString 
)

Definition at line 1110 of file vfs.c.

Here is the call graph for this function: