13#include <aquila/errno.h>
19MALLOC_DEFINE(M_MINIX_SB,
"minix-sb",
"minix filesystem superblock structure");
40 if (!inode)
return -ENOMEM;
91 struct minix *desc = inode->
p;
127 if (sb ==
NULL)
return -ENOMEM;
129 if ((err =
vfs_read(
dev, 1024,
sizeof(*sb), sb)) < 0)
155 if (!desc)
goto e_nomem;
194 err = r < 0 ? (int) r : -EIO;
248 if (!args || !args->dev)
void bcache_init(struct bcache *bcache)
Sets up an empty block cache.
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.
#define MALLOC_DEFINE(type, _name, _desc)
void * kmalloc(size_t size, struct malloc_type *type, int flags)
Allocates memory for one of the kernel's structures.
void kfree(void *)
Frees an object that kmalloc() gave.
int vfs_lookup(const char *path, struct uio *uio, struct vnode **ref)
Finds the vnode a path names.
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),...
int minix_inode_read(struct minix *desc, ino_t ino, struct minix_inode *ref)
Reads an inode from the disk.
int minix_inode_write(struct minix *desc, ino_t ino, struct minix_inode *ref)
Writes an inode to the disk.
static int minix_mount(struct vnode *dir, int flags, void *_args)
Mounts the minix filesystem of a device (the dev argument) on a directory.
int minix_inode_build(struct minix *desc, ino_t ino, struct vnode **ref)
Gets the vnode of an inode: the cached one if it's in use, or a new one made from the inode on the di...
int minix_inode_sync(struct vnode *inode)
Writes a vnode's attributes back to its inode on the disk.
static int minix_load(struct vnode *dev, struct vnode **super)
Loads a minix filesystem from a device: its superblock, its bitmaps, and its root directory's vnode i...
static int minix_init()
Installs the minix filesystem at boot.
ssize_t minix_read(struct vnode *inode, off_t offset, struct iobuf *io)
Reads from a file.
int minix_vget(struct vnode *super, ino_t ino, struct vnode **ref)
Gets the vnode of an inode, by its number.
int minix_finddir(struct vnode *dir, const char *fn, struct dirent *dirent)
Finds the entry of a directory that has a name.
int minix_trunc(struct vnode *inode, off_t len)
Changes a file's length.
ssize_t minix_readdir(struct vnode *dir, off_t offset, struct dirent *dirent)
Reads a directory's entry at an offset; unused entries don't count.
int minix_vmknod(struct vnode *dir, const char *fn, mode_t mode, dev_t dev, struct uio *uio, struct vnode **ref)
Makes a node in a directory: a new inode, and an entry for it.
ssize_t minix_write(struct vnode *inode, off_t offset, struct iobuf *io)
Writes to a file, which grows if the write goes past its end.
#define MODULE_INIT(name, i, f)
int posix_file_open(struct file *file)
Finishes opening a file: with O_TRUNC, a regular file is truncated to 0 bytes.
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_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_trunc(struct file *file, off_t len)
Truncates (or extends) an open file to a new length.
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 vfs_read(struct vnode *vnode, off_t off, size_t size, void *buf)
Reads from a vnode into a kernel buffer.
A filesystem's block cache (fs/bcache.c): its blocks that were read, by their offset.
A device driver: its operations, any of which may be NULL.
int(*) load(struct vnode *dev, struct vnode **super)
A minix v1 inode, as it is on the disk.
The superblock of minix v1 and v2, as it is on the disk.
A mounted minix filesystem.
struct minix_superblock * superblock
Who does a filesystem operation: where its paths start, and its credentials and umask.
A filesystem's vnode cache (fs/vcache.c): its vnodes in memory, by their inode number,...
A file in memory (a vnode): what its inode says, and the kernel's own state.
void * p
the filesystem's own data
void vcache_init(struct vcache *vcache)
Sets up an empty vnode cache.
struct vnode * vcache_find(struct vcache *vcache, ino_t ino)
Finds the cached vnode of an inode.
int vcache_insert(struct vcache *vcache, struct vnode *vnode)
Adds a vnode to a cache.
int vfs_bind(struct vnode *dir, struct vnode *root)
Mounts a filesystem on a directory: a lookup that reaches dir goes on in root instead.
int vfs_install(struct fs *fs)
Installs a filesystem, so that it can be mounted by name.