AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
minix.c File Reference

minix: loading and mounting the filesystem, and the vnodes of its inodes. More...

#include <core/system.h>
#include <core/module.h>
#include <fs/vfs.h>
#include <fs/posix.h>
#include <fs/vcache.h>
#include <fs/bcache.h>
#include <aquila/errno.h>
#include <ds/bitmap.h>
#include <minix.h>

Go to the source code of this file.

Functions

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 disk.
int minix_inode_sync (struct vnode *inode)
 Writes a vnode's attributes back to its inode on the disk.
static int minix_init ()
 Installs the minix filesystem at boot.
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 in *super.
static int minix_mount (struct vnode *dir, int flags, void *_args)
 Mounts the minix filesystem of a device (the dev argument) on a directory.

Variables

struct fs minixfs

Detailed Description

minix: loading and mounting the filesystem, and the vnodes of its inodes.

The inode and zone bitmaps are kept in memory, and the vnodes in use in a cache by inode number. See minix.h for the disk's format.

Definition in file minix.c.

Function Documentation

◆ minix_init()

int minix_init ( )
static

Installs the minix filesystem at boot.

Definition at line 110 of file minix.c.

References minix_init(), minixfs, and vfs_install().

Referenced by minix_init().

◆ minix_inode_build()

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 disk.

Parameters
descthe mounted filesystem
inothe inode number
refif not NULL, set to the vnode
Returns
0, -ENOMEM, or an I/O error

Definition at line 30 of file minix.c.

References vnode::fs, minix_inode::gid, vnode::gid, vnode::ino, kfree(), kmalloc(), M_ZERO, minix_inode_build(), minix_inode_read(), minixfs, minix_inode::mode, vnode::mode, minix_inode::mtime, vnode::mtime, vnode::nlink, minix_inode::nlinks, NULL, vnode::p, vnode::rdev, minix_inode::size, vnode::size, timespec::tv_nsec, timespec::tv_sec, minix_inode::uid, vnode::uid, minix::vcache, vcache_find(), vcache_insert(), and minix_inode::zones.

Referenced by minix_inode_build(), minix_load(), minix_vget(), and minix_vmknod().

◆ minix_inode_sync()

int minix_inode_sync ( struct vnode * inode)

Writes a vnode's attributes back to its inode on the disk.

Parameters
inodethe vnode
Returns
0, or an I/O error

Definition at line 87 of file minix.c.

References minix_inode::gid, vnode::gid, vnode::ino, minix_inode_read(), minix_inode_sync(), minix_inode_write(), minix_inode::mode, vnode::mode, minix_inode::mtime, vnode::mtime, vnode::nlink, minix_inode::nlinks, vnode::p, minix_inode::size, vnode::size, timespec::tv_sec, minix_inode::uid, and vnode::uid.

Referenced by minix_inode_sync(), and minix_trunc().

◆ minix_load()

int minix_load ( struct vnode * dev,
struct vnode ** super )
static

◆ minix_mount()

int minix_mount ( struct vnode * dir,
int flags,
void * _args )
static

Mounts the minix filesystem of a device (the dev argument) on a directory.

Definition at line 236 of file minix.c.

References fs::load, minix_mount(), minixfs, NULL, vfs_bind(), and vfs_lookup().

Referenced by minix_mount().

Variable Documentation

◆ minixfs

struct fs minixfs
Initial value:
= {
.name = "minix",
.init = minix_init,
.load = minix_load,
.mount = minix_mount,
.vops = {
.read = minix_read,
.write = minix_write,
.readdir = minix_readdir,
.finddir = minix_finddir,
.trunc = minix_trunc,
.vmknod = minix_vmknod,
.vget = minix_vget,
},
.fops = {
.open = posix_file_open,
.read = posix_file_read,
.write = posix_file_write,
.readdir = posix_file_readdir,
.lseek = posix_file_lseek,
.trunc = posix_file_trunc,
}
}
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.
Definition helpers.c:17
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),...
Definition lseek.c:22
static int minix_mount(struct vnode *dir, int flags, void *_args)
Mounts the minix filesystem of a device (the dev argument) on a directory.
Definition minix.c:236
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...
Definition minix.c:119
static int minix_init()
Installs the minix filesystem at boot.
Definition minix.c:110
ssize_t minix_read(struct vnode *inode, off_t offset, struct iobuf *io)
Reads from a file.
Definition vops.c:21
int minix_vget(struct vnode *super, ino_t ino, struct vnode **ref)
Gets the vnode of an inode, by its number.
Definition vops.c:363
int minix_finddir(struct vnode *dir, const char *fn, struct dirent *dirent)
Finds the entry of a directory that has a name.
Definition vops.c:324
int minix_trunc(struct vnode *inode, off_t len)
Changes a file's length.
Definition vops.c:380
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.
Definition vops.c:151
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.
Definition vops.c:216
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.
Definition vops.c:75
int posix_file_open(struct file *file)
Finishes opening a file: with O_TRUNC, a regular file is truncated to 0 bytes.
Definition open.c:17
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.
Definition read.c:29
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.
Definition readdir.c:22
int posix_file_trunc(struct file *file, off_t len)
Truncates (or extends) an open file to a new length.
Definition trunc.c:16
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.
Definition write.c:25

Definition at line 265 of file minix.c.

Referenced by minix_init(), minix_inode_build(), and minix_mount().