The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
devfs.c File Reference

read-only pseudo-filesystem backing the device registry. More...

#include "devfs.h"
#include "kernel/errno.h"
#include "common/string.h"
#include "kernel/device/device.h"
#include "kernel/vfs/stat.h"
#include "common/memory.h"
#include "kernel/tty/pty.h"

Macros

#define PTS_PREFIX   "pts/"
#define PTS_PREFIX_LENGTH   4

Functions

kerr_t devfs_mount (fs_mount_t *mount)
 initialize a mount to be backed by devfs.
struct device * devfs_device (const fs_file_t *file)
 the device of an open devfs node.

Detailed Description

read-only pseudo-filesystem backing the device registry.

implements the fs_ops_t vtable so the generic fs_* layer can dispatch to it exactly like ext2. paths arriving here are already mount-relative (the VFS strips the "/dev" prefix, see vfs_resolve_mount_path): the directory root is "/", and a device node is "/name" (e.g. "/fb0").

state lives in the generic fs_file fields added for non-ext2 filesystems:

  • fs_data: the target device_t* for an open node (NULL for the root dir)
  • fs_pos: the next registry index to yield from read_entry (root dir)

Macro Definition Documentation

◆ PTS_PREFIX

#define PTS_PREFIX   "pts/"

◆ PTS_PREFIX_LENGTH

#define PTS_PREFIX_LENGTH   4

Function Documentation

◆ devfs_mount()

kerr_t devfs_mount ( fs_mount_t * mount)

initialize a mount to be backed by devfs.

unlike fs_mount(), devfs has no block device to probe: it reads the live device registry on demand. after this returns KERR_OK, hand mount to vfs_mount("/dev", mount).

Parameters
mountfilesystem mount object to initialize.
Returns
KERR_OK on success.

◆ devfs_device()

struct device * devfs_device ( const fs_file_t * file)

the device of an open devfs node.

Parameters
filean open file of any filesystem.
Returns
the device, or NULL if the file is not a devfs device node.