|
AquilaOS documentation
How it works, and its code
|
The operations on open files: each goes to the socket layer, the device's driver, or the vnode's filesystem (its fops). More...
#include <core/system.h>#include <fs/vfs.h>#include <fs/posix.h>#include <fs/pipe.h>#include <dev/dev.h>#include <net/socket.h>#include <aquila/fcntl.h>Go to the source code of this file.
Functions | |
| int | vfs_file_open (struct file *file) |
| Opens a file whose vnode is set: a device's driver, a FIFO's pipe, or the filesystem opens it. | |
| ssize_t | vfs_file_read (struct file *file, struct iobuf *io) |
| Reads from an open file, at its offset. | |
| ssize_t | vfs_file_write (struct file *file, struct iobuf *io) |
| Writes to an open file, at its offset. | |
| int | vfs_file_ioctl (struct file *file, int request, void *argp) |
| Passes an ioctl() request to an open file's device or filesystem. | |
| off_t | vfs_file_lseek (struct file *file, off_t offset, int whence) |
| Moves an open file's offset. | |
| ssize_t | vfs_file_readdir (struct file *file, struct dirent *dirent) |
| Reads the next entry of an open directory. | |
| ssize_t | vfs_file_close (struct file *file) |
| Closes an open file, when its last reference goes: its lock is released, then its socket, device or filesystem closes it. | |
| int | vfs_file_trunc (struct file *file, off_t len) |
| Changes the length of an open file. | |
| struct waitq * | vfs_file_wait_queue (struct file *file, int write) |
| Finds the wait queue that a reader (or a writer) of an open file sleeps on until it can go on, which poll() and select() wait on too. | |
| int | vfs_file_can_read (struct file *file, size_t size) |
| Says whether a read of an open file would go on without waiting, for poll() and select(). | |
| int | vfs_file_can_write (struct file *file, size_t size) |
| Says whether a write to an open file would go on without waiting, for poll(), select() and non-blocking writes. | |
| int | vfs_file_eof (struct file *file) |
| Says whether an open file is at its end, so that a read returns 0 rather than waiting. | |
The operations on open files: each goes to the socket layer, the device's driver, or the vnode's filesystem (its fops).
Definition in file fops.c.
Says whether a read of an open file would go on without waiting, for poll() and select().
A regular file or a directory never waits.
| file | the open file |
| size | how many bytes would be read |
Definition at line 262 of file fops.c.
References FILE_SOCKET, file::flags, ISDEV, kdev_file_can_read(), socket_can_read(), vfs_file_can_read(), and VNODE_DEV.
Referenced by fd_ready(), and vfs_file_can_read().
Says whether a write to an open file would go on without waiting, for poll(), select() and non-blocking writes.
A regular file never waits.
| file | the open file |
| size | how many bytes would be written |
Definition at line 295 of file fops.c.
References FILE_SOCKET, file::flags, ISDEV, kdev_file_can_write(), socket_can_write(), vfs_file_can_write(), and VNODE_DEV.
Referenced by fd_ready(), posix_file_write(), and vfs_file_can_write().
Closes an open file, when its last reference goes: its lock is released, then its socket, device or filesystem closes it.
| file | the open file |
Definition at line 183 of file fops.c.
References FILE_SOCKET, file::flags, ISDEV, kdev_file_close(), posix_file_close(), socket_shutdown(), vfs_file_close(), vfs_file_lock_release(), and VNODE_DEV.
Referenced by file_put(), and vfs_file_close().
| int vfs_file_eof | ( | struct file * | file | ) |
Says whether an open file is at its end, so that a read returns 0 rather than waiting.
| file | the open file |
Definition at line 325 of file fops.c.
References ISDEV, kdev_file_eof(), vfs_file_eof(), and VNODE_DEV.
Referenced by posix_file_read(), posix_file_write(), and vfs_file_eof().
| int vfs_file_ioctl | ( | struct file * | file, |
| int | request, | ||
| void * | argp ) |
Passes an ioctl() request to an open file's device or filesystem.
| file | the open file |
| request | the request |
| argp | its argument |
Definition at line 111 of file fops.c.
References ISDEV, kdev_file_ioctl(), vfs_file_ioctl(), and VNODE_DEV.
Referenced by sys_ioctl(), and vfs_file_ioctl().
Moves an open file's offset.
| file | the open file |
| offset | the offset, or the distance to move it |
| whence | SEEK_SET, SEEK_CUR or SEEK_END |
Definition at line 136 of file fops.c.
References ISDEV, kdev_file_lseek(), vfs_file_lseek(), and VNODE_DEV.
Referenced by sys_lseek(), and vfs_file_lseek().
| int vfs_file_open | ( | struct file * | file | ) |
Opens a file whose vnode is set: a device's driver, a FIFO's pipe, or the filesystem opens it.
| file | the file, its vnode and flags set |
Definition at line 22 of file fops.c.
References file::flags, ISDEV, kdev_file_open(), pipefs_fifo_open(), vfs_file_open(), and VNODE_DEV.
Referenced by do_openat(), and vfs_file_open().
Reads from an open file, at its offset.
| file | the open file |
| io | where the data goes, and how much is wanted |
Definition at line 52 of file fops.c.
References FILE_SOCKET, file::flags, ISDEV, kdev_file_read(), NULL, socket_recv(), vfs_file_read(), and VNODE_DEV.
Referenced by sys_read(), and vfs_file_read().
Reads the next entry of an open directory.
| file | the open directory |
| dirent | the entry, filled in |
Definition at line 162 of file fops.c.
References vfs_file_readdir().
Referenced by sys_readdir(), and vfs_file_readdir().
Changes the length of an open file.
| file | the open file |
| len | the new length, in bytes |
Definition at line 213 of file fops.c.
References FILE_SOCKET, file::flags, ISDEV, and vfs_file_trunc().
Referenced by posix_file_open(), sys_ftruncate(), and vfs_file_trunc().
Finds the wait queue that a reader (or a writer) of an open file sleeps on until it can go on, which poll() and select() wait on too.
A socket says which; a device's and a pipe's are their vnode's (see fs/posix/read.c and write.c).
| file | the open file |
| write | whether it's the writers' queue, rather than the readers' |
Definition at line 243 of file fops.c.
References FILE_SOCKET, file::flags, NULL, socket_wait_queue(), and vfs_file_wait_queue().
Referenced by fd_watch(), and vfs_file_wait_queue().
Writes to an open file, at its offset.
| file | the open file |
| io | the data, and how much of it |
Definition at line 83 of file fops.c.
References FILE_SOCKET, file::flags, ISDEV, kdev_file_write(), NULL, socket_send(), vfs_file_write(), and VNODE_DEV.
Referenced by sys_write(), and vfs_file_write().