RTEMS
5.0.0
|
Internal IO library API and implementation. More...
Files | |
file | __usrenv.c |
RTEMS File System Location Support. | |
file | clonenode.c |
Clones a Node. | |
file | freenode.c |
Releases all Resources of a Location. | |
file | libio.c |
File Descriptor Routines. | |
file | sup_fs_check_permissions.c |
RTEMS File System Permissions Check Support. | |
file | sup_fs_eval_path.c |
RTEMS File Sysyem Path Eval Support. | |
file | sup_fs_eval_path_generic.c |
RTEMS File System Eval Generic Path. | |
file | sup_fs_exist_in_same_instance.c |
Checks that the Locations Exist in the Same File System Instance. | |
file | sup_fs_location.c |
RTEMS File System Location Support. | |
file | sup_fs_next_token.c |
RTEMS File System Eval Eat Delimiter Path. | |
Data Structures | |
struct | rtems_filesystem_eval_path_generic_config |
Macros | |
#define | RTEMS_FILESYSTEM_SYMLOOP_MAX 32 |
#define | F_DUP2FD 20 |
#define | rtems_libio_iop_to_descriptor(_iop) ((_iop) - &rtems_libio_iops[0]) |
#define | rtems_libio_check_is_open(_iop) |
#define | LIBIO_GET_IOP(_fd, _iop) |
Macro to get the iop for the specified file descriptor. More... | |
#define | LIBIO_GET_IOP_WITH_ACCESS(_fd, _iop, _access_flags, _access_error) |
Macro to get the iop for the specified file descriptor with access flags and error. More... | |
#define | rtems_libio_check_buffer(_buffer) |
#define | rtems_libio_check_count(_count) |
#define | rtems_filesystem_mt_entry_declare_lock_context(ctx) rtems_interrupt_lock_context ctx |
#define | rtems_filesystem_mt_entry_lock(ctx) rtems_interrupt_lock_acquire( &rtems_filesystem_mt_entry_lock_control, &ctx ) |
#define | rtems_filesystem_mt_entry_unlock(ctx) rtems_interrupt_lock_release( &rtems_filesystem_mt_entry_lock_control, &ctx ) |
Typedefs | |
typedef bool(* | rtems_filesystem_eval_path_is_directory) (rtems_filesystem_eval_path_context_t *ctx, void *arg) |
Tests if the current location is a directory. More... | |
typedef rtems_filesystem_eval_path_generic_status(* | rtems_filesystem_eval_path_eval_token) (rtems_filesystem_eval_path_context_t *ctx, void *arg, const char *token, size_t tokenlen) |
Evaluates a token. More... | |
typedef ssize_t(* | rtems_libio_iovec_adapter) (rtems_libio_t *iop, const struct iovec *iov, int iovcnt, ssize_t total) |
Enumerations | |
enum | rtems_filesystem_eval_path_generic_status { RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_CONTINUE, RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_DONE, RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_NO_ENTRY } |
Functions | |
void | rtems_filesystem_location_clone (rtems_filesystem_location_info_t *clone, const rtems_filesystem_location_info_t *master) |
Clones a node. More... | |
void | rtems_filesystem_location_free (rtems_filesystem_location_info_t *loc) |
Releases all resources of a location. More... | |
void | rtems_libio_free_user_env (void *env) |
void | rtems_libio_lock (void) |
void | rtems_libio_unlock (void) |
rtems_libio_t * | rtems_libio_allocate (void) |
unsigned int | rtems_libio_fcntl_flags (int fcntl_flags) |
int | rtems_libio_to_fcntl_flags (unsigned int flags) |
void | rtems_libio_free (rtems_libio_t *iop) |
rtems_filesystem_location_info_t * | rtems_filesystem_eval_path_start (rtems_filesystem_eval_path_context_t *ctx, const char *path, int eval_flags) |
rtems_filesystem_location_info_t * | rtems_filesystem_eval_path_start_with_parent (rtems_filesystem_eval_path_context_t *ctx, const char *path, int eval_flags, rtems_filesystem_location_info_t *parentloc, int parent_eval_flags) |
rtems_filesystem_location_info_t * | rtems_filesystem_eval_path_start_with_root_and_current (rtems_filesystem_eval_path_context_t *ctx, const char *path, size_t pathlen, int eval_flags, rtems_filesystem_global_location_t *const *global_root_ptr, rtems_filesystem_global_location_t *const *global_current_ptr) |
void | rtems_filesystem_eval_path_continue (rtems_filesystem_eval_path_context_t *ctx) |
void | rtems_filesystem_eval_path_cleanup (rtems_filesystem_eval_path_context_t *ctx) |
void | rtems_filesystem_eval_path_recursive (rtems_filesystem_eval_path_context_t *ctx, const char *path, size_t pathlen) |
void | rtems_filesystem_eval_path_cleanup_with_parent (rtems_filesystem_eval_path_context_t *ctx, rtems_filesystem_location_info_t *parentloc) |
void | rtems_filesystem_eval_path_restart (rtems_filesystem_eval_path_context_t *ctx, rtems_filesystem_global_location_t **newstartloc_ptr) |
Requests a path evaluation restart. More... | |
void | rtems_filesystem_eval_path_generic (rtems_filesystem_eval_path_context_t *ctx, void *arg, const rtems_filesystem_eval_path_generic_config *config) |
void | rtems_filesystem_initialize (void) |
Base File System Initialization. More... | |
rtems_filesystem_location_info_t * | rtems_filesystem_location_copy (rtems_filesystem_location_info_t *dst, const rtems_filesystem_location_info_t *src) |
Copies a location. More... | |
rtems_filesystem_global_location_t * | rtems_filesystem_location_transform_to_global (rtems_filesystem_location_info_t *loc) |
void | rtems_filesystem_global_location_assign (rtems_filesystem_global_location_t **lhs_global_loc_ptr, rtems_filesystem_global_location_t *rhs_global_loc) |
Assigns a global file system location. More... | |
rtems_filesystem_global_location_t * | rtems_filesystem_global_location_obtain (rtems_filesystem_global_location_t *const *global_loc_ptr) |
Obtains a global file system location. More... | |
void | rtems_filesystem_global_location_release (rtems_filesystem_global_location_t *global_loc, bool deferred) |
Releases a global file system location. More... | |
void | rtems_filesystem_location_detach (rtems_filesystem_location_info_t *detach) |
void | rtems_filesystem_location_copy_and_detach (rtems_filesystem_location_info_t *copy, rtems_filesystem_location_info_t *detach) |
int | rtems_filesystem_mknod (const rtems_filesystem_location_info_t *parentloc, const char *name, size_t namelen, mode_t mode, dev_t dev) |
int | rtems_filesystem_chdir (rtems_filesystem_location_info_t *loc) |
int | rtems_filesystem_chmod (const rtems_filesystem_location_info_t *loc, mode_t mode) |
int | rtems_filesystem_chown (const rtems_filesystem_location_info_t *loc, uid_t owner, gid_t group) |
void | rtems_filesystem_location_remove_from_mt_entry (rtems_filesystem_location_info_t *loc) |
void | rtems_filesystem_do_unmount (rtems_filesystem_mount_table_entry_t *mt_entry) |
void | rtems_filesystem_eval_path_eat_delimiter (rtems_filesystem_eval_path_context_t *ctx) |
void | rtems_filesystem_eval_path_next_token (rtems_filesystem_eval_path_context_t *ctx) |
void | rtems_filesystem_eval_path_error (rtems_filesystem_eval_path_context_t *ctx, int eno) |
int | rtems_filesystem_location_exists_in_same_instance_as (const rtems_filesystem_location_info_t *a, const rtems_filesystem_location_info_t *b) |
Checks that the locations exist in the same file system instance. More... | |
bool | rtems_filesystem_check_access (int flags, mode_t object_mode, uid_t object_uid, gid_t object_gid) |
Checks if access to an object is allowed for the current user. More... | |
bool | rtems_filesystem_eval_path_check_access (rtems_filesystem_eval_path_context_t *ctx, int eval_flags, mode_t node_mode, uid_t node_uid, gid_t node_gid) |
Variables | |
const uint32_t | rtems_libio_number_iops |
rtems_libio_t | rtems_libio_iops [] |
void * | rtems_libio_iop_free_head |
void ** | rtems_libio_iop_free_tail |
const rtems_filesystem_file_handlers_r | rtems_filesystem_null_handlers |
rtems_filesystem_mount_table_entry_t | rtems_filesystem_null_mt_entry |
rtems_filesystem_global_location_t | rtems_filesystem_global_location_null |
The global null location. More... | |
pthread_key_t | rtems_current_user_env_key |
rtems_interrupt_lock | rtems_filesystem_mt_entry_lock_control |
Internal IO library API and implementation.
#define LIBIO_GET_IOP | ( | _fd, | |
_iop | |||
) |
Macro to get the iop for the specified file descriptor.
Checks that the file descriptor is in the valid range and open.
#define LIBIO_GET_IOP_WITH_ACCESS | ( | _fd, | |
_iop, | |||
_access_flags, | |||
_access_error | |||
) |
Macro to get the iop for the specified file descriptor with access flags and error.
Checks that the file descriptor is in the valid range and open.
#define rtems_libio_check_buffer | ( | _buffer | ) |
#define rtems_libio_check_count | ( | _count | ) |
#define rtems_libio_check_is_open | ( | _iop | ) |
typedef rtems_filesystem_eval_path_generic_status(* rtems_filesystem_eval_path_eval_token) (rtems_filesystem_eval_path_context_t *ctx, void *arg, const char *token, size_t tokenlen) |
Evaluates a token.
[in,out] | ctx | The path evaluation context. |
[in,out] | arg | The handler argument. |
[in] | token | The token contents. |
[in] | tokenlen | The token length in characters. |
status | The generic path evaluation status. |
typedef bool(* rtems_filesystem_eval_path_is_directory) (rtems_filesystem_eval_path_context_t *ctx, void *arg) |
Tests if the current location is a directory.
[in,out] | ctx | The path evaluation context. |
[in,out] | arg | The handler argument. |
true | The current location is a directory. |
false | Otherwise. |
bool rtems_filesystem_check_access | ( | int | flags, |
mode_t | object_mode, | ||
uid_t | object_uid, | ||
gid_t | object_gid | ||
) |
Checks if access to an object is allowed for the current user.
If the effective UID is zero or equals the UID of the object, then the user permission flags of the object will be used. Otherwise if the effective GID is zero or equals the GID of the object or one of the supplementary group IDs is equal to the GID of the object, then the group permission flags of the object will be used. Otherwise the other permission flags of the object will be used.
[in] | flags | The flags determining the access type. It can be RTEMS_FS_PERMS_READ, RTEMS_FS_PERMS_WRITE or RTEMS_FS_PERMS_EXEC. |
[in] | object_mode | The mode of the object specifying the permission flags. |
[in] | object_uid | The UID of the object. |
[in] | object_gid | The GID of the object. |
true | Access is allowed. |
false | Otherwise. |
void rtems_filesystem_eval_path_restart | ( | rtems_filesystem_eval_path_context_t * | ctx, |
rtems_filesystem_global_location_t ** | newstartloc_ptr | ||
) |
Requests a path evaluation restart.
Sets the start and current location to the new start location. The caller must terminate its current evaluation process. The path evaluation continues in the next loop iteration within rtems_filesystem_eval_path_continue(). This avoids recursive invocations. The function obtains the new start location and clones it to set the new current location. The previous start and current locations are released.
[in,out] | ctx | The path evaluation context. |
[in,out] | newstartloc_ptr | Pointer to the new start location. |
void rtems_filesystem_global_location_assign | ( | rtems_filesystem_global_location_t ** | lhs_global_loc_ptr, |
rtems_filesystem_global_location_t * | rhs_global_loc | ||
) |
Assigns a global file system location.
[in,out] | lhs_global_loc_ptr | Pointer to the global left hand side file system location. The current left hand side location will be released. |
[in] | rhs_global_loc | The global right hand side file system location. |
rtems_filesystem_global_location_t* rtems_filesystem_global_location_obtain | ( | rtems_filesystem_global_location_t *const * | global_loc_ptr | ) |
Obtains a global file system location.
Deferred releases will be processed in this function.
This function must be called from normal thread context and may block on a mutex. Thread dispatching is disabled to protect some critical sections.
[in] | global_loc_ptr | Pointer to the global file system location. |
void rtems_filesystem_global_location_release | ( | rtems_filesystem_global_location_t * | global_loc, |
bool | deferred | ||
) |
Releases a global file system location.
In case the reference count reaches zero, all associated resources will be released. This may include the complete unmount of the corresponding file system instance.
This function may block on a mutex. It may be called within critical sections of the operating system. In this case the release will be deferred. The next obtain call will do the actual release.
[in] | global_loc | The global file system location. It must not be NULL. |
[in] | deferred | If true, then do a deferred release, otherwise release it immediately. |
void rtems_filesystem_initialize | ( | void | ) |
Base File System Initialization.
Initialize the foundation of the file system. This is specified by the structure rtems_filesystem_mount_table. The usual configuration is a single instantiation of the IMFS or miniIMFS with a single "/dev" directory in it.
void rtems_filesystem_location_clone | ( | rtems_filesystem_location_info_t * | clone, |
const rtems_filesystem_location_info_t * | master | ||
) |
Clones a node.
The caller must hold the file system instance lock.
[out] | clone | The cloned location. |
[in] | master | The master location. |
rtems_filesystem_location_info_t* rtems_filesystem_location_copy | ( | rtems_filesystem_location_info_t * | dst, |
const rtems_filesystem_location_info_t * | src | ||
) |
Copies a location.
A bitwise copy is performed. The destination location will be added to the corresponding mount entry.
[out] | dst | The destination location. |
[in] | src | The source location. |
dst | The destination location. |
int rtems_filesystem_location_exists_in_same_instance_as | ( | const rtems_filesystem_location_info_t * | a, |
const rtems_filesystem_location_info_t * | b | ||
) |
Checks that the locations exist in the same file system instance.
0 | The locations exist and are in the same file system instance. |
-1 | An error occurred. The errno indicates the error. |
void rtems_filesystem_location_free | ( | rtems_filesystem_location_info_t * | loc | ) |
Releases all resources of a location.
This function may block on a mutex and may complete an unmount process.
[in] | loc | The location to free. |
rtems_libio_t* rtems_libio_allocate | ( | void | ) |
This routine searches the IOP Table for an unused entry. If it finds one, it returns it. Otherwise, it returns NULL.
unsigned int rtems_libio_fcntl_flags | ( | int | fcntl_flags | ) |
Convert UNIX fnctl(2) flags to ones that RTEMS drivers understand
void rtems_libio_free | ( | rtems_libio_t * | iop | ) |
This routine frees the resources associated with an IOP (file descriptor) and clears the slot in the IOP Table.
int rtems_libio_to_fcntl_flags | ( | unsigned int | flags | ) |
Convert RTEMS internal flags to UNIX fnctl(2) flags
rtems_filesystem_global_location_t rtems_filesystem_global_location_null |
The global null location.
Every operation and the open and fstat handlers of this location returns an error status. The errno is not touched by these operations and handlers. The purpose of this location is to deliver the error return status for a previous error condition which must set the errno accordingly.
The usage of this null location instead of the NULL pointer eliminates a lot of branches.
The user environment root and current directory are statically initialized with the null location. Due to that all file system services are in a defined state even if no root file system was mounted.