Helpers to implement ctl (control) file operations.
More...
Helpers to implement ctl (control) file operations.
A ctl file is a special file that takes in commands as text input and performs actions based on those commands.
◆ CTL_STANDARD_OPS_DEFINE
| #define CTL_STANDARD_OPS_DEFINE |
( |
|
name, |
|
|
|
... |
|
) |
| |
Value:
};
#define CTL_STANDARD_WRITE_DEFINE(name,...)
Helper macro to define a standard ctl write function.
uint64_t write(fd_t fd, const void *buffer, uint64_t count)
System call for writing to files.
File operations structure.
uint64_t(* write)(file_t *file, const void *buffer, uint64_t count, uint64_t *offset)
Helper macro to define a standard ctl file operations structure.
This macro defines a file operations structure with all standard ctl operations implemented.
- Parameters
-
| name | The name of the ctl file operations structure. |
| ... | The ctl array to dispatch commands to. |
Definition at line 41 of file ctl.h.
◆ CTL_STANDARD_WRITE_DEFINE
| #define CTL_STANDARD_WRITE_DEFINE |
( |
|
name, |
|
|
|
... |
|
) |
| |
Value: static ctl_t name##ctls[] = __VA_ARGS__; \
{ \
(void)offset; \
}
uint64_t ctl_dispatch(ctl_array_t ctls, file_t *file, const void *buffer, uint64_t count)
Dispatch a ctl command.
EFI_PHYSICAL_ADDRESS buffer
Structure defining a ctl command.
Helper macro to define a standard ctl write function.
This macro defines a write function that dispatches commands to a given array of ctl_t structures.
- Parameters
-
| name | The name of the ctl write function. |
| ... | The ctl array to dispatch commands to. |
Definition at line 25 of file ctl.h.
◆ ctl_array_t
| typedef ctl_t ctl_array_t[] |
Type definition for an array of ctl commands.
Definition at line 72 of file ctl.h.
◆ ctl_func_t
Type definition for a ctl function.
- Parameters
-
| file | The file the ctl command was sent to. |
| argc | The number of arguments. |
| argv | The arguments. |
- Returns
- On success,
0. On failure, ERR and errno is set.
Definition at line 55 of file ctl.h.
◆ ctl_dispatch()
Dispatch a ctl command.
- Parameters
-
| ctls | The array of ctl commands to dispatch to. |
| file | The file the ctl command was sent to. |
| buffer | The buffer containing the command and its arguments. |
| count | The number of bytes in the buffer. |
- Returns
- On success, the number of bytes processed (count). On failure,
ERR and errno is set.
Definition at line 9 of file ctl.c.
References ctl_t::argcMax, argsplit_buf(), buffer, count, E2BIG, EINVAL, ENOENT, ERR, errno, EUNKNOWNCTL, file, ctl_t::func, MAX_PATH, ctl_t::name, NULL, and strcmp().