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

a small read-only pseudo-filesystem that surfaces the device registry. More...

#include "common/error.h"
#include "kernel/fs/fs.h"

Go to the source code of this file.

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

a small read-only pseudo-filesystem that surfaces the device registry.

devfs has no backing block device: its "files" are the devices registered in the kernel device model (see src/kernel/device/device.h). mounting it at "/dev" makes ls /dev enumerate registered devices (fb0, tty0, hda, ...) and lets a program open a device node like "/dev/fb0" by name.

it is deliberately minimal for now: the directory listing and opening a node by name work; byte read/write and ioctl/mmap on a node are added per device family (the Linux-style /dev/fb0 fbdev is the first, see framebuffer-plan.md). the namespace is flat (no sub-directories) and read-only (no create/remove).

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.