# devfs.c File Reference

`#include <devfs/devfs.h>`
`#include <vfs/vfs.h>`
`#include <sys/device.h>`
`#include <ubixos/types.h>`
`#include <ubixos/spinlock.h>`
`#include <ubixos/kpanic.h>`
`#include <lib/kmalloc.h>`
`#include <lib/string.h>`
`#include <lib/kprintf.h>`

Include dependency graph for devfs.c:

Go to the source code of this file.

## Functions

int | devfs_init ()
static void | devfs_initialize (struct vfs_mountPoint *mp)
int | devfs_makeNode (char *name, uInt8 type, uInt16 major, uInt16 minor)
static int | devfs_open (char *file, fileDescriptor *fd)
static int | devfs_read (fileDescriptor *fd, char *data, long offset, long size)
static int | devfs_write (fileDescriptor *fd, char *data, long offset, long size)

## Variables

static int | devfs_len = 0x0
static spinLock_t | devfsSpinLock = SPIN_LOCK_INITIALIZER

## Function Documentation

int devfs_init | ( |  | ) |

Definition at line 215 of file devfs.c.

References devfs_initialize(), devfs_open(), devfs_read(), devfs_write(), NULL, vfs_mount(), vfsRegisterFS(), and x1.

Here is the call graph for this function:

static void devfs_initialize | ( | struct vfs_mountPoint * | mp | ) | `[static]`

This is the initialized called by the vfs system when enabling devfs basically it allocates memory for the devfs module

Definition at line 50 of file devfs.c.

References devfs_info::deviceList, vfs_mountPoint::fsInfo, K_PANIC, and kmalloc().

Referenced by devfs_init().

Here is the call graph for this function:

int devfs_makeNode | ( | char * | name,
|  | uInt8 | type,
|  | uInt16 | major,
|  | uInt16 | minor |
| ) |  |  |

Definition at line 178 of file devfs.c.

References devfs_len, devfsSpinLock, devfs_info::deviceList, devfs_devices::devMajor, devfs_devices::devMinor, devfs_devices::devName, devfs_devices::devType, vfs_mountPoint::fsInfo, kmalloc(), kprintf(), devfs_devices::next, devfs_devices::prev, spinLock(), spinUnlock(), sprintf(), strlen, and vfs_findMount().

Referenced by fdc_init(), and initHardDisk().

Here is the call graph for this function:

static int devfs_open | ( | char * | file,
|  | fileDescriptor * | fd |
| ) |  |  | `[static]`

This is the open routine called by the vfs when a fopen or open is called within the user or kernel space file - this is the file node fd - this is the file descriptor

This format will be changing down the road

Definition at line 71 of file devfs.c.

References devfs_len, devfsSpinLock, device_find(), devfs_info::deviceList, device_node::devInfo, devfs_devices::devMajor, devfs_devices::devMinor, devfs_devices::devName, vfs_mountPoint::fsInfo, kprintf(), fileDescriptorStruct::mode, fileDescriptorStruct::mp, devfs_devices::next, device_interface::size, fileDescriptorStruct::size, spinLock(), spinUnlock(), fileDescriptorStruct::start, strcmp(), and x1.

Referenced by devfs_init().

Here is the call graph for this function:

static int devfs_read | ( | fileDescriptor * | fd,
|  | char * | data,
|  | long | offset,
|  | long | size |
| ) |  |  | `[static]`

Function: int readDevFS(fileDescriptor *fd,char *data,long offset,long size) Description: Read File Into Data Notes:

Definition at line 114 of file devfs.c.

References fileDescriptorStruct::buffer, device_find(), device_node::devInfo, devfs_devices::devMajor, devfs_devices::devMinor, device_interface::info, kprintf(), device_interface::read, and fileDescriptorStruct::start.

Referenced by devfs_init().

Here is the call graph for this function:

static int devfs_write | ( | fileDescriptor * | fd,
|  | char * | data,
|  | long | offset,
|  | long | size |
| ) |  |  | `[static]`

Definition at line 160 of file devfs.c.

References fileDescriptorStruct::buffer, device_find(), device_node::devInfo, devfs_devices::devMajor, devfs_devices::devMinor, device_interface::info, device_interface::read, fileDescriptorStruct::start, and device_interface::write.

Referenced by devfs_init().

Here is the call graph for this function:

## Variable Documentation

int devfs_len = 0x0`[static]`

Definition at line 44 of file devfs.c.

Referenced by devfs_makeNode(), and devfs_open().

spinLock_t devfsSpinLock = SPIN_LOCK_INITIALIZER`[static]`

Definition at line 41 of file devfs.c.

Referenced by devfs_makeNode(), and devfs_open().