PatchworkOS
Loading...
Searching...
No Matches
vfs_ctx.h
Go to the documentation of this file.
1#pragma once
2
3#include <kernel/config.h>
4#include <kernel/fs/path.h>
5#include <kernel/sync/lock.h>
6
7#include <sys/bitmap.h>
8#include <sys/io.h>
9
10typedef struct file file_t;
11typedef struct dir_entry dir_entry_t;
12
39
46void vfs_ctx_init(vfs_ctx_t* ctx, const path_t* cwd);
47
55void vfs_ctx_deinit(vfs_ctx_t* ctx);
56
65
78
89
100
112
123
133fd_t vfs_ctx_dup(vfs_ctx_t* ctx, fd_t oldFd);
134
145fd_t vfs_ctx_dup2(vfs_ctx_t* ctx, fd_t oldFd, fd_t newFd);
146
void vfs_ctx_deinit(vfs_ctx_t *ctx)
Deinitialize a VFS context.
Definition vfs_ctx.c:30
fd_t vfs_ctx_set_fd(vfs_ctx_t *ctx, fd_t fd, file_t *file)
Allocate a specific file descriptor in a VFS context.
Definition vfs_ctx.c:164
fd_t vfs_ctx_dup(vfs_ctx_t *ctx, fd_t oldFd)
Duplicate a file descriptor in a VFS context.
Definition vfs_ctx.c:218
void vfs_ctx_init(vfs_ctx_t *ctx, const path_t *cwd)
Initialize a VFS context.
Definition vfs_ctx.c:11
uint64_t vfs_ctx_get_cwd(vfs_ctx_t *ctx, path_t *outCwd)
Definition vfs_ctx.c:67
fd_t vfs_ctx_alloc_fd(vfs_ctx_t *ctx, file_t *file)
Allocate a new file descriptor in a VFS context.
Definition vfs_ctx.c:142
fd_t vfs_ctx_dup2(vfs_ctx_t *ctx, fd_t oldFd, fd_t newFd)
Duplicate a file descriptor in a VFS context to a specific file descriptor.
Definition vfs_ctx.c:251
uint64_t vfs_ctx_free_fd(vfs_ctx_t *ctx, fd_t fd)
Free a file descriptor in a VFS context.
Definition vfs_ctx.c:191
uint64_t vfs_ctx_set_cwd(vfs_ctx_t *ctx, const path_t *cwd)
Set the current working directory of a VFS context.
Definition vfs_ctx.c:93
file_t * vfs_ctx_get_file(vfs_ctx_t *ctx, fd_t fd)
Get a file from a VFS context.
Definition vfs_ctx.c:48
#define CONFIG_MAX_FD
Maximum file descriptor configuration.
Definition config.h:47
#define BITMAP_BITS_TO_QWORDS(bits)
Convert number of bits to number of qwords.
Definition bitmap.h:34
__UINT64_TYPE__ fd_t
A file descriptor.
Definition fd_t.h:12
static list_t files
Definition file.c:9
static dentry_t * file
Definition log_file.c:17
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
Bitmap structure.
Definition bitmap.h:22
File structure.
Definition file.h:37
A simple ticket lock implementation.
Definition lock.h:43
Path structure.
Definition path.h:110
VFS context structure.
Definition vfs_ctx.h:31
bitmap_t allocBitmap
Bitmap tracking allocated file descriptors.
Definition vfs_ctx.h:34
lock_t lock
Definition vfs_ctx.h:36
path_t cwd
Definition vfs_ctx.h:32
bool initalized
Definition vfs_ctx.h:37
struct dir_entry dir_entry_t
Definition vfs_ctx.h:11