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

Reading a directory's entries, and finding one by name. More...

#include <core/system.h>
#include <fs/vfs.h>

Go to the source code of this file.

Functions

ssize_t vfs_readdir (struct vnode *dir, off_t off, struct dirent *dirent)
 Reads a directory's entry at an offset.
int vfs_finddir (struct vnode *dir, const char *name, struct dirent *dirent)
 Finds the entry of a directory that has a name.
int vfs_dir_empty (struct vnode *dir)
 Says whether a directory is empty, so that it can be removed.

Detailed Description

Reading a directory's entries, and finding one by name.

Definition in file readdir.c.

Function Documentation

◆ vfs_dir_empty()

int vfs_dir_empty ( struct vnode * dir)

Says whether a directory is empty, so that it can be removed.

An empty directory has no entries besides . and ...

Parameters
dirthe directory
Returns
1 if it's empty, 0 if it isn't or it couldn't be read

Definition at line 69 of file readdir.c.

References vfs_dir_empty(), and vfs_readdir().

Referenced by vfs_dir_empty(), vfs_remove(), and vfs_rename().

◆ vfs_finddir()

int vfs_finddir ( struct vnode * dir,
const char * name,
struct dirent * dirent )

Finds the entry of a directory that has a name.

Parameters
dirthe directory
namethe name
direntthe entry, filled in
Returns
0, -ENOENT if there is no such entry, -ENOTDIR if dir isn't a directory, or another negative errno

Definition at line 46 of file readdir.c.

References vops::finddir, vnode::fs, LOG_DEBUG, vnode::mode, vfs_finddir(), and fs::vops.

Referenced by entry_get(), entry_name(), lookup_name(), vfs_finddir(), vfs_lookup_parent(), vfs_parent(), and vfs_remove().

◆ vfs_readdir()

ssize_t vfs_readdir ( struct vnode * dir,
off_t off,
struct dirent * dirent )

Reads a directory's entry at an offset.

Offsets count entries, starting at 0.

Parameters
dirthe directory
offwhich entry
direntthe entry, filled in
Returns
1 if an entry was read (the offset to add to get the next one), 0 past the last entry, -ENOTDIR if dir isn't a directory, or another negative errno

Definition at line 19 of file readdir.c.

References vnode::fs, LOG_DEBUG, vnode::mode, vops::readdir, vfs_readdir(), and fs::vops.

Referenced by entry_name(), posix_file_readdir(), vfs_dir_empty(), and vfs_readdir().