The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
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
*/
30
kerr_t
devfs_mount
(
fs_mount_t
*mount);
31
32
struct
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
*/
39
struct
device
*
devfs_device
(
const
fs_file_t
*
file
);
devfs_device
struct device * devfs_device(const fs_file_t *file)
the device of an open devfs node.
Definition
devfs.c:364
devfs_mount
kerr_t devfs_mount(fs_mount_t *mount)
initialize a mount to be backed by devfs.
Definition
devfs.c:349
error.h
kerr_t
kerr_t
unified kernel error codes.
Definition
error.h:14
fs_mount_t
struct fs_mount fs_mount_t
filesystem operations vtable.
Definition
ext2_ops.h:7
fs.h
fs_file_t
struct fs_file fs_file_t
Definition
fs.h:35
device
a registered device.
Definition
device.h:114
file
an open-file description.
Definition
file.h:64
src
kernel
fs
devfs.h
Generated by
1.18.0