PatchworkOS
Loading...
Searching...
No Matches
file.h
Go to the documentation of this file.
1#pragma once
2
3#include <kernel/fs/path.h>
5#include <kernel/utils/ref.h>
6
7#include <stdatomic.h>
8#include <stdint.h>
9#include <sys/io.h>
10#include <sys/proc.h>
11
12typedef struct wait_queue wait_queue_t;
13
14typedef struct file file_t;
15typedef struct file_ops file_ops_t;
16typedef struct dentry dentry_t;
17typedef struct inode inode_t;
18typedef struct poll_file poll_file_t;
19
46
56typedef struct file_ops
57{
60 void (*close)(file_t* file);
62 uint64_t (*write)(file_t* file, const void* buffer, uint64_t count, uint64_t* offset);
64 uint64_t (*ioctl)(file_t* file, uint64_t request, void* argp, uint64_t size);
65 wait_queue_t* (*poll)(file_t* file, poll_events_t* revents);
66 void* (*mmap)(file_t* file, void* address, uint64_t length, uint64_t* offset, pml_flags_t flags);
68
79
93file_t* file_new(inode_t* inode, const path_t* path, path_flags_t flags);
94
103
file_t * file_new(inode_t *inode, const path_t *path, path_flags_t flags)
Create a new file structure.
Definition file.c:31
uint64_t file_generic_seek(file_t *file, int64_t offset, seek_origin_t origin)
Helper function for basic seeking.
Definition file.c:51
path_flags_t
Path flags.
Definition path.h:83
fd_t open(const char *path)
System call for opening files.
Definition open.c:9
uint64_t close(fd_t fd)
System call for closing files.
Definition close.c:9
uint64_t seek(fd_t fd, int64_t offset, seek_origin_t origin)
System call for changing the file offset.
Definition seek.c:9
uint64_t ioctl(fd_t fd, uint64_t request, void *argp, uint64_t size)
System call for extended driver behaviour.
Definition ioctl.c:9
uint8_t seek_origin_t
Type for the seek() origin argument.
Definition io.h:262
uint64_t read(fd_t fd, void *buffer, uint64_t count)
System call for reading from files.
Definition read.c:9
poll_events_t
Poll events type.
Definition io.h:288
uint64_t open2(const char *path, fd_t fd[2])
System call for opening 2 file descriptors from one file.
Definition open2.c:9
uint64_t write(fd_t fd, const void *buffer, uint64_t count)
System call for writing to files.
Definition write.c:9
static uintptr_t address
Definition hpet.c:12
static list_t files
Definition file.c:9
static dentry_t * file
Definition log_file.c:17
EFI_PHYSICAL_ADDRESS buffer
Definition mem.c:15
static atomic_long count
Definition main.c:9
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
__INT64_TYPE__ int64_t
Definition stdint.h:16
Directory entry structure.
Definition dentry.h:83
File operations structure.
Definition file.h:57
File structure.
Definition file.h:37
const file_ops_t * ops
Definition file.h:43
path_flags_t flags
Definition file.h:40
ref_t ref
Definition file.h:38
inode_t * inode
Definition file.h:41
path_t path
Definition file.h:42
uint64_t pos
Definition file.h:39
Inode structure.
Definition inode.h:54
Path structure.
Definition path.h:110
A entry in a page table without a specified address or callback ID.
Structure for polling multiple files.
Definition file.h:74
file_t * file
Definition file.h:75
poll_events_t events
Definition file.h:76
poll_events_t revents
Definition file.h:77
Reference counting structure.
Definition ref.h:30
Wait queue structure.
Definition wait.h:166