GVM User Suite
User tools for the GVM open source project.
Functions
device.h File Reference
#include <stdint.h>
Include dependency graph for device.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

uint8_t device_exists (const char *device_name)
 Does a device file exist? More...
 
int32_t get_major (const char *device)
 Gets the device major id from /proc/devices. More...
 
int32_t get_param (const char *filename, const char *parameter)
 Gets a parameter from a driver param file. More...
 

Function Documentation

◆ device_exists()

uint8_t device_exists ( const char *  device_name)

Does a device file exist?

This function provides us information regarding if a device exists on the system, it automatically prepends the /dev/ prefix if the prefix is not found in the string.

Side Effect:
File System Side Effect: This checks the file system, specifically the device tree.
Parameters
device_name- The name of the device that we are checking if it exists or not in the /dev/ filesystem.
Returns
Returns a 0 if the device does not exist, and a 1 if it does.
Possible Failures:
Invalid File - The only way this function can fail is by not having the file in question exist.

Definition at line 30 of file device.c.

Here is the caller graph for this function:

◆ get_major()

int32_t get_major ( const char *  device)

Gets the device major id from /proc/devices.

This function is used to provide us information regarding what is the major number for a particular for a device.

Side Effect:
File System Side Effect: Checks the major number of a device.

Example

get_major("nvidia-frontend") == 195
int32_t get_major(const char *device)
Gets the device major id from /proc/devices.
Definition: device.c:42
Parameters
device- Device we want to create.
Returns
Returns the major number related to the device, or -1 in failure.
Possible Failures:

Invalid Device - In the case of an invalid device being passed it will return -1.

Device List Not Found - Device list is not found, this can occur on unsupported operating systems.

Definition at line 42 of file device.c.

Here is the caller graph for this function:

◆ get_param()

int32_t get_param ( const char *  filename,
const char *  parameter 
)

Gets a parameter from a driver param file.

This function is designed to give us several parameters by which we can determine how to create the necessary character devices.

Side Effect:
File System Side Effect: Checks the device parameter file for a value.
Restriction:
This function will only work for integer parameters.

Example

get_param("/proc/driver/nvidia/params", "DeviceFileUID") == 0
get_param("/proc/driver/nvidia/params", "DeviceFileGID") == 0
get_param("/proc/driver/nvidia/params", "ResmanDebugLevel") == 4294967295
int32_t get_param(const char *filename, const char *parameter)
Gets a parameter from a driver param file.
Definition: device.c:71
Parameters
filename- File name for the parameter file.
parameter- Driver parameter to search for.
Returns
Returns the integer parameter for the driver parameter we searched for, or -1 if not found.
Possible Failures:
Param File Not Found - Check if the device driver is loaded correctly.

Definition at line 71 of file device.c.

Here is the caller graph for this function: