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

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

#include <core/panic.h>
#include <core/module.h>
#include <fs/vfs.h>
#include <fs/posix.h>
#include <fs/vcache.h>
#include <aquila/errno.h>
#include <ds/bitmap.h>
#include <ext2.h>

Go to the source code of this file.

Functions

int ext2_inode_build (struct ext2 *desc, ino_t ino, struct vnode **ref_inode)
 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 ext2_inode_sync (struct vnode *inode)
 Writes a vnode's attributes back to its inode on the disk.
int ext2_init ()
 Installs the ext2 filesystem at boot.
int ext2_load (struct vnode *dev, struct vnode **super)
 Loads an ext2 filesystem from a device: its superblock, its block group descriptors, and its root directory's vnode.
int ext2_mount (struct vnode *dir, int flags, void *_args)
 Mounts the ext2 filesystem of a device on a directory.

Variables

struct fs ext2fs

Detailed Description

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

The block group descriptors are kept in memory, and the vnodes in use in a cache by inode number. See ext2.h for the disk's format.

Definition in file ext2.c.

Function Documentation

◆ ext2_init()

int ext2_init ( )

Installs the ext2 filesystem at boot.

Returns
0, or -ENOMEM

Definition at line 130 of file ext2.c.

References ext2_init(), ext2fs, and vfs_install().

Referenced by ext2_init().

◆ ext2_inode_build()

int ext2_inode_build ( struct ext2 * desc,
ino_t ino,
struct vnode ** ref_inode )

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
ref_inodeif not NULL, set to the vnode
Returns
0, -ENOMEM, or an I/O error

Definition at line 29 of file ext2.c.

References ext2_inode::atime, vnode::atime, ext2_inode::ctime, vnode::ctime, DEV, ext2_inode::direct_pointer, ext2_inode_build(), ext2_inode_read(), ext2fs, vnode::fs, ext2_inode::gid, vnode::gid, vnode::ino, kmalloc(), LOG_DEBUG, M_ZERO, ext2_inode::mode, vnode::mode, ext2_inode::mtime, vnode::mtime, ext2_inode::nlink, vnode::nlink, NULL, vnode::p, vnode::rdev, ext2_inode::size, vnode::size, timespec::tv_nsec, timespec::tv_sec, ext2_inode::uid, vnode::uid, ext2::vcache, vcache_find(), and vcache_insert().

Referenced by ext2_inode_build(), ext2_load(), ext2_vget(), ext2_vmknod(), ext2_vrename(), and ext2_vunlink().

◆ ext2_inode_sync()

◆ ext2_load()

int ext2_load ( struct vnode * dev,
struct vnode ** super )

Loads an ext2 filesystem from a device: its superblock, its block group descriptors, and its root directory's vnode.

Parameters
devthe device
superif not NULL, set to the root directory's vnode
Returns
0, -EINVAL if the device doesn't have an ext2 filesystem that AquilaOS can use, or a negative errno

Definition at line 144 of file ext2.c.

References ext2_superblock::block_size, ext2::bs, EXT2_GOOD_OLD_INODE_SIZE, EXT2_INCOMPAT_FILETYPE, EXT2_INCOMPAT_SUPPORTED, ext2_inode_build(), ext2_load(), EXT2_RO_COMPAT_SUPPORTED, EXT2_SIGNATURE, ext2_superblock::ext2_signature, ext2_superblock::feature_incompat, ext2_superblock::feature_ro_compat, ext2::filetype, ext2_superblock::gblocks, ext2::groups, vcache::hashmap, ext2::inode_size, ext2_superblock::inode_size, kfree(), kmalloc(), M_ZERO, ext2_superblock::major_version, ext2_superblock::nblocks, ext2::ngroups, NULL, printk(), ext2::superblock, ext2::supernode, ext2::vcache, vcache_init(), and vfs_read().

Referenced by ext2_load().

◆ ext2_mount()

int ext2_mount ( struct vnode * dir,
int flags,
void * _args )

Mounts the ext2 filesystem of a device on a directory.

Parameters
dirthe directory
flagsnot used
_argsthe arguments, whose dev is the device's path
Returns
0, -EINVAL, or a negative errno

Definition at line 253 of file ext2.c.

References ext2_mount(), ext2fs, fs::load, NULL, vfs_bind(), and vfs_lookup().

Referenced by ext2_mount().

Variable Documentation

◆ ext2fs

struct fs ext2fs

Definition at line 282 of file ext2.c.

Referenced by ext2_init(), ext2_inode_build(), and ext2_mount().