12#include <aquila/fcntl.h>
28 if (S_ISDIR(
file->vnode->mode) && (
file->
flags & (O_WRONLY | O_RDWR)))
35 if (S_ISFIFO(
file->vnode->mode))
38 if (!
file->vnode->fs->fops.open)
41 return file->vnode->fs->fops.open(
file);
61 if (S_ISDIR(
file->vnode->mode))
70 if (!
file->vnode->fs->fops.read)
73 return file->vnode->fs->fops.read(
file, io);
97 if (!
file->vnode->fs->fops.write)
100 return file->vnode->fs->fops.write(
file, io);
119 if (!
file->vnode->fs)
122 if (!
file->vnode->fs->fops.ioctl)
125 return file->vnode->fs->fops.ioctl(
file, request, argp);
144 if (!
file->vnode->fs)
148 if (!
file->vnode->fs->fops.lseek)
151 return file->vnode->fs->fops.lseek(
file, offset, whence);
167 if (!S_ISDIR(
file->vnode->mode))
170 if (!
file->vnode->fs->fops.readdir)
173 return file->vnode->fs->fops.readdir(
file, dirent);
196 if (!
file->vnode->fs)
200 if (!
file->vnode->fs->fops.close)
203 return file->vnode->fs->fops.close(
file);
224 if (!
file->vnode->fs)
227 if (!
file->vnode->fs->fops.trunc)
230 return file->vnode->fs->fops.trunc(
file, len);
251 return write ?
file->vnode->write_queue :
file->vnode->read_queue;
271 if (S_ISREG(
file->vnode->mode) || S_ISDIR(
file->vnode->mode))
277 if (!
file->vnode->fs)
280 if (!
file->vnode->fs->fops.can_read)
283 return file->vnode->fs->fops.can_read(
file, size);
303 if (S_ISREG(
file->vnode->mode))
309 if (!
file->vnode->fs)
312 if (!
file->vnode->fs->fops.can_write)
315 return file->vnode->fs->fops.can_write(
file, size);
333 if (!
file->vnode->fs)
336 if (!
file->vnode->fs->fops.eof)
339 return file->vnode->fs->fops.eof(
file);
void vfs_file_lock_release(struct file *file)
Releases an open file's lock when the file is closed.
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.
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.
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,...
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.
int vfs_file_trunc(struct file *file, off_t len)
Changes the length of an open file.
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().
ssize_t vfs_file_close(struct file *file)
Closes an open file, when its last reference goes: its lock is released, then its socket,...
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.
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-blocki...
ssize_t vfs_file_read(struct file *file, struct iobuf *io)
Reads from an open file, at its offset.
ssize_t kdev_file_close(struct devid *dd, struct file *file)
Closes an open device file, through its driver's file operations.
off_t kdev_file_lseek(struct devid *dd, struct file *file, off_t offset, int whence)
Moves an open device file's offset, through its driver's file operations.
int kdev_file_can_write(struct devid *dd, struct file *file, size_t size)
Asks a device's driver whether a write wouldn't have to wait.
int kdev_file_eof(struct devid *dd, struct file *file)
Asks a device's driver whether a read that found no data is at the end of the file.
ssize_t kdev_file_write(struct devid *dd, struct file *file, struct iobuf *io)
Writes to an open device file, through its driver's file operations.
ssize_t kdev_file_read(struct devid *dd, struct file *file, struct iobuf *io)
Reads an open device file, through its driver's file operations.
int kdev_file_ioctl(struct devid *dd, struct file *file, int request, void *argp)
Passes an ioctl() on an open device file to its driver's file operations.
int kdev_file_open(struct devid *dd, struct file *file)
Opens a device, through its driver's file operations.
int kdev_file_can_read(struct devid *dd, struct file *file, size_t size)
Asks a device's driver whether a read wouldn't have to wait.
int pipefs_fifo_open(struct file *file)
Opens a FIFO: the open file's vnode becomes an end of the FIFO's pipe, made by its first open.
int posix_file_close(struct file *file)
Closes an open file by dropping its reference to its vnode.
int socket_can_write(struct file *file, size_t len)
Says whether a socket has room to write, for select() and poll().
int socket_can_read(struct file *file, size_t len)
Says whether a socket has something to read, for select() and poll().
struct waitq * socket_wait_queue(struct file *file, int write)
Finds the wait queue that a socket's readers (or writers) sleep on, for select() and poll() to regist...
int socket_shutdown(struct file *file, int how)
Releases a socket when its open file is closed (its last descriptor went).
ssize_t socket_recv(struct file *file, struct iobuf *io, int flags, struct sockaddr *from, socklen_t *fromlen)
Receives data from a socket, for recv(), recvfrom() and read().
ssize_t socket_send(struct file *file, struct iobuf *io, int flags, const struct sockaddr *to, socklen_t tolen)
Sends data on a socket, for send(), sendto() and write().
An open file (POSIX's "open file description", fs/file.c).