26#define O_RDONLY 0x0000
27#define O_WRONLY 0x0001
29#define O_ACCMODE 0x0003
33#define O_APPEND 0x0400
34#define O_NONBLOCK 0x0800
35#define O_DIRECTORY 0x10000
36#define O_CLOEXEC 0x80000
uintptr_t addr_space_t
an address space handle.
Definition arch.h:105
file_t * file_console(void)
the console (keyboard in, screen out).
Definition console_file.c:527
kerr_t
unified kernel error codes.
Definition error.h:14
int32_t file_pwrite(file_t *file, const void *buf, uint32_t count, int64_t offset)
Definition file.c:203
int32_t file_mmap(file_t *file, addr_space_t as, uintptr_t virt, size_t length, int prot, uint64_t offset)
Definition file.c:106
void file_ref(file_t *file)
add a reference to a description.
Definition file.c:40
bool file_is_vfs(const file_t *file)
true if the description is a filesystem file (not a pipe or the console).
Definition file.c:292
int32_t file_stat(file_t *file, struct kstat *st)
Definition file.c:163
int32_t file_ioctl(file_t *file, uint32_t request, void *arg)
Definition file.c:101
uint32_t file_poll(file_t *file)
the readiness of a file (kernel/vfs/poll.h).
Definition file.c:145
bool file_readable(const file_t *file)
true if the description was opened for reading (or writing).
Definition file.c:68
int64_t file_seek(file_t *file, int64_t offset, int whence)
Definition file.c:96
kerr_t file_open(const char *path, uint32_t flags, file_t **out)
open a file or directory through the VFS.
Definition file.c:297
int32_t file_unread_entry(file_t *file, const fs_dirent_t *entry)
give back the entry file_read_entry returned last, so the next call returns it again (getdents,...
Definition file.c:124
file_t * file_new_fifo_end(uint32_t flags)
a new end of a named pipe, not yet joined to one (kernel/vfs/fifo.c joins it).
Definition file.c:392
int32_t file_read(file_t *file, void *buf, uint32_t count)
the operations, with an errno for the unsupported ones: read and write EBADF (wrong access mode,...
Definition file.c:78
int32_t file_write(file_t *file, const void *buf, uint32_t count)
Definition file.c:87
file_t * file_new(const file_ops_t *ops, uint32_t flags)
a new description of another kind (a device stream), with one reference.
Definition file.c:35
bool file_writable(const file_t *file)
Definition file.c:73
int32_t file_read_entry(file_t *file, fs_dirent_t *entry)
Definition file.c:112
int32_t file_truncate(file_t *file, uint64_t length)
Definition file.c:136
kerr_t file_open_pipe(file_t **read_end, file_t **write_end)
make the two ends of a new pipe.
Definition file.c:397
int32_t file_pread(file_t *file, void *buf, uint32_t count, int64_t offset)
read or write at an offset without moving the description's offset (pread, pwrite).
Definition file.c:198
void file_unref(file_t *file)
drop a reference; the last one releases the description.
Definition file.c:48
struct fs_dirent fs_dirent_t
Definition fs.h:36
uint8_t flags
Definition idt.c:3
struct file file_t
Definition file.h:38
unsigned int uint32_t
Definition fb.h:17
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
int int32_t
Definition stdint.h:14
__UINTPTR_TYPE__ uintptr_t
Definition stdint.h:19
__INT64_TYPE__ int64_t
Definition stdint.h:16
struct pipe_buf pipe_buf_t
a pipe.
pipe_dir_t
pipe endpoint direction.
Definition pipe.h:34
what a kind of file can do.
Definition file.h:46
int32_t(*) write(file_t *file, const void *buf, uint32_t count)
Definition file.h:48
int32_t(*) ioctl(file_t *file, uint32_t request, void *arg)
Definition file.h:50
int64_t(*) seek(file_t *file, int64_t offset, int whence)
Definition file.h:49
int32_t(*) mmap(file_t *file, addr_space_t as, uintptr_t virt, size_t length, int prot, uint64_t offset)
Definition file.h:51
uint32_t(*) poll(file_t *file)
Definition file.h:56
int32_t(*) truncate(file_t *file, uint64_t length)
Definition file.h:54
int32_t(*) stat(file_t *file, struct kstat *st)
Definition file.h:55
int32_t(*) read_entry(file_t *file, fs_dirent_t *entry)
Definition file.h:53
int32_t(*) read(file_t *file, void *buf, uint32_t count)
Definition file.h:47
void(*) release(file_t *file)
Definition file.h:57
an open-file description.
Definition file.h:64
uint32_t flags
Definition file.h:67
char * path
Definition file.h:69
fs_dirent_t * lookahead
Definition file.h:68
const file_ops_t * ops
Definition file.h:65
uint32_t refcount
Definition file.h:66
virtual file system file handle structure representing an open file or directory.
Definition vfs.h:21
struct file::@121010160247101261310353350172266371276115374177::@067332303217203003101323037017207353071354347272 pipe