The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
devfs.h
Go to the documentation of this file.
1#pragma once
2
3/**
4 * @file devfs.h
5 * @brief a small read-only pseudo-filesystem that surfaces the device registry.
6 *
7 * devfs has no backing block device: its "files" are the devices registered in
8 * the kernel device model (see src/kernel/device/device.h). mounting it at
9 * "/dev" makes `ls /dev` enumerate registered devices (fb0, tty0, hda, ...) and
10 * lets a program open a device node like "/dev/fb0" by name.
11 *
12 * it is deliberately minimal for now: the directory listing and opening a node
13 * by name work; byte read/write and ioctl/mmap on a node are added per device
14 * family (the Linux-style /dev/fb0 fbdev is the first, see framebuffer-plan.md).
15 * the namespace is flat (no sub-directories) and read-only (no create/remove).
16 */
17
18#include "common/error.h"
19#include "kernel/fs/fs.h"
20
21/**
22 * initialize a mount to be backed by devfs.
23 *
24 * unlike fs_mount(), devfs has no block device to probe: it reads the live
25 * device registry on demand. after this returns KERR_OK, hand @p mount to
26 * vfs_mount("/dev", mount).
27 * @param mount filesystem mount object to initialize.
28 * @return KERR_OK on success.
29 */
31
32struct device;
33
34/**
35 * the device of an open devfs node.
36 * @param file an open file of any filesystem.
37 * @return the device, or NULL if the file is not a devfs device node.
38 */
39struct device *devfs_device(const fs_file_t *file);
struct device * devfs_device(const fs_file_t *file)
the device of an open devfs node.
Definition devfs.c:364
kerr_t devfs_mount(fs_mount_t *mount)
initialize a mount to be backed by devfs.
Definition devfs.c:349
kerr_t
unified kernel error codes.
Definition error.h:14
struct fs_mount fs_mount_t
filesystem operations vtable.
Definition ext2_ops.h:7
struct fs_file fs_file_t
Definition fs.h:35
a registered device.
Definition device.h:114
an open-file description.
Definition file.h:64