|
AquilaOS documentation
How it works, and its code
|
#include <fs/vfs.h>Go to the source code of this file.
Functions | |
| int | posix_file_open (struct file *file) |
| Finishes opening a file: with O_TRUNC, a regular file is truncated to 0 bytes. | |
| int | posix_file_close (struct file *file) |
| Closes an open file by dropping its reference to its vnode. | |
| ssize_t | posix_file_read (struct file *file, struct iobuf *io) |
| Reads from an open file at its offset, and moves the offset past what was read. | |
| ssize_t | posix_file_write (struct file *file, struct iobuf *io) |
| Writes to an open file at its offset, and moves the offset past what was written. | |
| ssize_t | posix_file_readdir (struct file *file, struct dirent *dirent) |
| Reads the directory entry at an open directory's offset, and moves the offset past it. | |
| int | posix_file_ioctl (struct file *file, int request, void *argp) |
| Passes an ioctl() request on to the file's vnode (a device's, or its filesystem's). | |
| off_t | posix_file_lseek (struct file *file, off_t offset, int whence) |
| Moves an open file's offset: to offset (SEEK_SET), by offset from where it is (SEEK_CUR), or by offset from the end of the file (SEEK_END). | |
| int | posix_file_trunc (struct file *file, off_t len) |
| Truncates (or extends) an open file to a new length. | |
| int | posix_file_eof (struct file *file) |
| Says whether a file's offset is at or past its end, so that a read returns nothing. | |
| int posix_file_close | ( | struct file * | file | ) |
Closes an open file by dropping its reference to its vnode.
| file | the open file |
Definition at line 15 of file close.c.
References posix_file_close(), and vfs_close().
Referenced by kdev_file_close(), posix_file_close(), ps2mouse_file_close(), vfs_file_close(), and vt_file_close().
| int posix_file_eof | ( | struct file * | file | ) |
Says whether a file's offset is at or past its end, so that a read returns nothing.
| file | the open file |
Definition at line 17 of file helpers.c.
References file::offset, and posix_file_eof().
Referenced by posix_file_eof().
| int posix_file_ioctl | ( | struct file * | file, |
| int | request, | ||
| void * | argp ) |
Passes an ioctl() request on to the file's vnode (a device's, or its filesystem's).
| file | the open file |
| request | the request |
| argp | its argument, often a pointer to user memory |
Definition at line 19 of file ioctl.c.
References posix_file_ioctl(), and vfs_ioctl().
Referenced by posix_file_ioctl().
Moves an open file's offset: to offset (SEEK_SET), by offset from where it is (SEEK_CUR), or by offset from the end of the file (SEEK_END).
The offset may go past the end of the file.
| file | the open file |
| offset | the offset, or the distance to move it |
| whence | SEEK_SET, SEEK_CUR or SEEK_END |
Definition at line 22 of file lseek.c.
References file::offset, posix_file_lseek(), and vnode::size.
Referenced by posix_file_lseek().
| int posix_file_open | ( | struct file * | file | ) |
Finishes opening a file: with O_TRUNC, a regular file is truncated to 0 bytes.
| file | the file being opened |
Definition at line 17 of file open.c.
References file::flags, posix_file_open(), and vfs_file_trunc().
Referenced by kmsg_file_open(), posix_file_open(), ps2mouse_file_open(), and pts_open().
Reads from an open file at its offset, and moves the offset past what was read.
If there is nothing to read yet, it waits for data (a pipe's, a terminal's), unless the file is non-blocking.
| file | the open file |
| io | where the data goes, and how much is wanted |
Definition at line 29 of file read.c.
References arch_rtime_ns(), file::flags, ISDEV, kdev_fops(), NULL, file::offset, posix_file_read(), fops::read_timeout, iobuf::resid, sched_wait(), vfs_file_eof(), vfs_read_io(), VNODE_DEV, and waitq_wakeup().
Referenced by posix_file_read().
Reads the directory entry at an open directory's offset, and moves the offset past it.
The offset counts entries, not bytes.
| file | the open directory |
| dirent | the entry, filled in |
Definition at line 22 of file readdir.c.
References file::flags, file::offset, posix_file_readdir(), and vfs_readdir().
Referenced by posix_file_readdir().
Truncates (or extends) an open file to a new length.
| file | the open file |
| len | the new length, in bytes |
Definition at line 16 of file trunc.c.
References posix_file_trunc(), and vfs_trunc().
Referenced by posix_file_trunc().
Writes to an open file at its offset, and moves the offset past what was written.
With O_APPEND, a regular file is written at its end. A blocking write waits for room (in a pipe, say) until everything is written; a non-blocking one writes only if it can without waiting.
| file | the open file |
| io | the data, and how much of it |
Definition at line 25 of file write.c.
References iobuf::fault, file::flags, file::offset, posix_file_write(), iobuf::resid, vfs_file_can_write(), vfs_file_eof(), vfs_write_io(), waitq_sleep(), and waitq_wakeup().
Referenced by posix_file_write().