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

Making a filesystem node by its path: a file, a directory, a device node, a FIFO or a symbolic link. More...

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

Go to the source code of this file.

Functions

int vfs_mknod (const char *path, mode_t mode, dev_t dev, struct uio *uio, struct vnode **ref)
 Makes a node at a path.
int vfs_mkdir (const char *path, mode_t mode, struct uio *uio, struct vnode **ref)
 Makes a directory at a path.
int vfs_creat (const char *path, mode_t mode, struct uio *uio, struct vnode **ref)
 Makes a regular file at a path.

Detailed Description

Making a filesystem node by its path: a file, a directory, a device node, a FIFO or a symbolic link.

Definition in file mknod.c.

Function Documentation

◆ vfs_creat()

int vfs_creat ( const char * path,
mode_t mode,
struct uio * uio,
struct vnode ** ref )

Makes a regular file at a path.

Parameters
paththe new file's path
modeits permissions
uiowho is asking
refif not NULL, set to the new vnode (the caller closes it)
Returns
0, or a negative errno

Definition at line 69 of file mknod.c.

References vnode::mode, vnode::ref, vfs_creat(), and vfs_mknod().

Referenced by do_openat(), and vfs_creat().

◆ vfs_mkdir()

int vfs_mkdir ( const char * path,
mode_t mode,
struct uio * uio,
struct vnode ** ref )

Makes a directory at a path.

Parameters
paththe new directory's path
modeits permissions
uiowho is asking
refif not NULL, set to the new vnode (the caller closes it)
Returns
0, or a negative errno

Definition at line 55 of file mknod.c.

References vnode::mode, vnode::ref, vfs_mkdir(), and vfs_mknod().

Referenced by vfs_mkdir().

◆ vfs_mknod()

int vfs_mknod ( const char * path,
mode_t mode,
dev_t dev,
struct uio * uio,
struct vnode ** ref )

Makes a node at a path.

The caller's umask applies to the mode (but not for a symbolic link), and it needs write and search permission on the directory.

Parameters
paththe new node's path
modeits type (S_IF*) and permissions
devits device number, for a device node
uiowho is asking (for permissions and the umask)
refif not NULL, set to the new vnode (the caller closes it)
Returns
0, -EEXIST if something is there already, or a negative errno

Definition at line 21 of file mknod.c.

References kfree(), uio::mask, vnode::mode, NULL, vnode::ref, vfs_access(), vfs_close(), vfs_lookup_parent(), vfs_mknod(), vfs_vmknod(), VFS_W, and VFS_X.

Referenced by do_mknodat(), kmain(), socket_unix_bind(), vfs_creat(), vfs_mkdir(), vfs_mknod(), and vfs_symlink().