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

ext2: directory entries. More...

#include <ext2.h>

Go to the source code of this file.

Functions

int ext2_dentry_find (struct ext2 *desc, struct ext2_inode *inode, const char *name, ino_t *ino)
 Finds the inode number of a name in a directory.
static uint8_t ext2_dentry_type (mode_t mode)
 Returns the directory entry type of a file's mode.
int ext2_dentry_create (struct vnode *dir, const char *name, ino_t ino, mode_t mode)
 Adds an entry to a directory.

Detailed Description

ext2: directory entries.

A directory's blocks hold entries of different sizes, each saying where the next one is (its size); an entry with no inode is unused, and a new entry takes an unused one, the room left at the end of another, or a new block.

Definition in file dentry.c.

Function Documentation

◆ ext2_dentry_create()

int ext2_dentry_create ( struct vnode * dir,
const char * name,
ino_t ino,
mode_t mode )

Adds an entry to a directory.

It takes an unused entry big enough, or splits an entry that has room after its name, or else gets a new block at the end of the directory.

Parameters
dirthe directory
namethe new entry's name
inoits inode number
modeits file's mode (for the entry's type)
Returns
0, -ENOTDIR, -ENOMEM, or an I/O error

Definition at line 87 of file dentry.c.

References ext2::bs, ext2_dentry_create(), ext2_dentry_type(), ext2_inode_block_read(), ext2_inode_block_write(), ext2_inode_read(), ext2_inode_write(), ext2::filetype, ext2_dentry::ino, vnode::ino, kfree(), kmalloc(), ext2_dentry::length, memcpy(), memset(), vnode::mode, ext2_dentry::name, NULL, vnode::p, ext2_dentry::size, ext2_inode::size, vnode::size, and ext2_dentry::type.

Referenced by ext2_dentry_create(), ext2_vlink(), ext2_vmknod(), and ext2_vrename().

◆ ext2_dentry_find()

int ext2_dentry_find ( struct ext2 * desc,
struct ext2_inode * inode,
const char * name,
ino_t * ino )

Finds the inode number of a name in a directory.

Parameters
descthe mounted filesystem
inodethe directory's inode
namethe name
inoset to the inode number
Returns
0, -ENOENT if there's no such name, -ENOTDIR, -ENOMEM, or an I/O error

Definition at line 20 of file dentry.c.

References ext2::bs, ext2_dentry_find(), ext2_inode_block_read(), ext2_dentry::ino, kfree(), kmalloc(), ext2_dentry::length, memcmp(), ext2_inode::mode, ext2_dentry::name, ext2_dentry::size, and ext2_inode::size.

Referenced by ext2_dentry_find(), ext2_finddir(), ext2_vlink(), ext2_vmknod(), and ext2_vrename().

◆ ext2_dentry_type()

uint8_t ext2_dentry_type ( mode_t mode)
inlinestatic