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

Removing a name by its path: unlink() and rmdir(). More...

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

Go to the source code of this file.

Functions

static int vfs_remove (const char *path, struct uio *uio, int rmdir)
 Removes the entry at a path, which must be an empty directory if rmdir is set, and anything but a directory otherwise.
int vfs_unlink (const char *path, struct uio *uio)
 Removes the name of a file (not a directory) at a path.
int vfs_rmdir (const char *path, struct uio *uio)
 Removes an empty directory at a path.

Detailed Description

Removing a name by its path: unlink() and rmdir().

Definition in file unlink.c.

Function Documentation

◆ vfs_remove()

int vfs_remove ( const char * path,
struct uio * uio,
int rmdir )
static

Removes the entry at a path, which must be an empty directory if rmdir is set, and anything but a directory otherwise.

The caller needs write and search permission on the directory it's in.

Definition at line 11 of file unlink.c.

References kfree(), vnode::mode, NULL, vfs_access(), vfs_close(), vfs_dir_empty(), vfs_finddir(), vfs_lookup_parent(), vfs_remove(), vfs_vget(), vfs_vunlink(), VFS_W, and VFS_X.

Referenced by vfs_remove(), vfs_rmdir(), and vfs_unlink().

◆ vfs_rmdir()

int vfs_rmdir ( const char * path,
struct uio * uio )

Removes an empty directory at a path.

Parameters
paththe path
uiowho is asking
Returns
0, -ENOTDIR, -ENOTEMPTY, or another negative errno

Definition at line 74 of file unlink.c.

References vfs_remove(), and vfs_rmdir().

Referenced by do_unlinkat(), and vfs_rmdir().

◆ vfs_unlink()

int vfs_unlink ( const char * path,
struct uio * uio )

Removes the name of a file (not a directory) at a path.

The file goes when its last name is removed and nothing has it open.

Parameters
paththe path
uiowho is asking
Returns
0, -EISDIR for a directory, or another negative errno

Definition at line 62 of file unlink.c.

References vfs_remove(), and vfs_unlink().

Referenced by do_unlinkat(), socket_unix_bind(), vfs_symlink(), and vfs_unlink().