mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-22 02:45:38 +08:00
cpukit/libfs: Clean up the libfs mount handlers
- Remove the `fsmount_me_t` handler moving its signature to `mount_t`. - The `mount_t` signature with the `data` lets file systems handle options and that means the shell `mount` command can mount more file systems. - Clean up the `mount` call's handling of the `mount_t` and `fsmount_me_t` structures.
This commit is contained in:
@@ -855,7 +855,8 @@ extern int IMFS_make_generic_node(
|
||||
* @brief Mount an IMFS.
|
||||
*/
|
||||
extern int IMFS_mount(
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry /* IN */
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry, /* IN */
|
||||
const void *data
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -278,22 +278,6 @@ typedef void (*rtems_filesystem_freenode_t)(
|
||||
* @see rtems_filesystem_default_mount().
|
||||
*/
|
||||
typedef int (*rtems_filesystem_mount_t) (
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Initializes a file system instance.
|
||||
*
|
||||
* This function must initialize the file system root node in the mount table
|
||||
* entry.
|
||||
*
|
||||
* @param[in] mt_entry The mount table entry.
|
||||
* @param[in] data The data provided by the user.
|
||||
*
|
||||
* @retval 0 Successful operation.
|
||||
* @retval -1 An error occurred. The errno is set to indicate the error.
|
||||
*/
|
||||
typedef int (*rtems_filesystem_fsmount_me_t)(
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
const void *data
|
||||
);
|
||||
@@ -637,7 +621,8 @@ void rtems_filesystem_default_freenode(
|
||||
* @see rtems_filesystem_mount_t.
|
||||
*/
|
||||
int rtems_filesystem_default_mount (
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry /* IN */
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry, /* IN */
|
||||
const void *data
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1295,7 +1280,7 @@ typedef off_t rtems_off64_t __attribute__((deprecated));
|
||||
* @return The file system mount handler associated with the @a type, or
|
||||
* @c NULL if no such association exists.
|
||||
*/
|
||||
rtems_filesystem_fsmount_me_t
|
||||
rtems_filesystem_mount_t
|
||||
rtems_filesystem_get_mount_handler(
|
||||
const char *type
|
||||
);
|
||||
@@ -1673,8 +1658,8 @@ typedef enum {
|
||||
* @brief File system table entry.
|
||||
*/
|
||||
typedef struct rtems_filesystem_table_t {
|
||||
const char *type;
|
||||
rtems_filesystem_fsmount_me_t mount_h;
|
||||
const char *type;
|
||||
rtems_filesystem_mount_t mount_h;
|
||||
} rtems_filesystem_table_t;
|
||||
|
||||
/**
|
||||
@@ -1695,8 +1680,8 @@ extern rtems_chain_control rtems_filesystem_mount_table;
|
||||
* @retval -1 An error occurred. The @c errno indicates the error.
|
||||
*/
|
||||
int rtems_filesystem_register(
|
||||
const char *type,
|
||||
rtems_filesystem_fsmount_me_t mount_h
|
||||
const char *type,
|
||||
rtems_filesystem_mount_t mount_h
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -143,7 +143,8 @@ static int null_op_clonenode(
|
||||
}
|
||||
|
||||
static int null_op_mount(
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||
const void *data
|
||||
)
|
||||
{
|
||||
return -1;
|
||||
|
||||
@@ -89,7 +89,7 @@ bool rtems_filesystem_iterate(
|
||||
|
||||
typedef struct {
|
||||
const char *type;
|
||||
rtems_filesystem_fsmount_me_t mount_h;
|
||||
rtems_filesystem_mount_t mount_h;
|
||||
} find_arg;
|
||||
|
||||
static bool find_handler(const rtems_filesystem_table_t *entry, void *arg)
|
||||
@@ -105,7 +105,7 @@ static bool find_handler(const rtems_filesystem_table_t *entry, void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
rtems_filesystem_fsmount_me_t
|
||||
rtems_filesystem_mount_t
|
||||
rtems_filesystem_get_mount_handler(
|
||||
const char *type
|
||||
)
|
||||
@@ -124,8 +124,8 @@ rtems_filesystem_get_mount_handler(
|
||||
|
||||
int
|
||||
rtems_filesystem_register(
|
||||
const char *type,
|
||||
rtems_filesystem_fsmount_me_t mount_h
|
||||
const char *type,
|
||||
rtems_filesystem_mount_t mount_h
|
||||
)
|
||||
{
|
||||
rtems_chain_control *chain = &filesystem_chain;
|
||||
|
||||
@@ -136,7 +136,7 @@ static int register_subordinate_file_system(
|
||||
rtems_filesystem_eval_path_extract_currentloc( &ctx, &targetloc );
|
||||
mt_point_node = rtems_filesystem_location_transform_to_global( &targetloc );
|
||||
mt_entry->mt_point_node = mt_point_node;
|
||||
rv = (*mt_point_node->location.mt_entry->ops->mount_h)( mt_entry );
|
||||
rv = (*mt_point_node->location.mt_entry->ops->mount_h)( mt_entry, target );
|
||||
if ( rv == 0 ) {
|
||||
rtems_filesystem_mt_lock();
|
||||
rtems_chain_append_unprotected(
|
||||
@@ -208,10 +208,10 @@ int mount(
|
||||
options == RTEMS_FILESYSTEM_READ_ONLY
|
||||
|| options == RTEMS_FILESYSTEM_READ_WRITE
|
||||
) {
|
||||
rtems_filesystem_fsmount_me_t fsmount_me_h =
|
||||
rtems_filesystem_mount_t mount_h =
|
||||
rtems_filesystem_get_mount_handler( filesystemtype );
|
||||
|
||||
if ( fsmount_me_h != NULL ) {
|
||||
if ( mount_h != NULL ) {
|
||||
size_t target_length = 0;
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry = alloc_mount_table_entry(
|
||||
source,
|
||||
@@ -223,7 +223,7 @@ int mount(
|
||||
if ( mt_entry != NULL ) {
|
||||
mt_entry->writeable = options == RTEMS_FILESYSTEM_READ_WRITE;
|
||||
|
||||
rv = (*fsmount_me_h)( mt_entry, data );
|
||||
rv = (*mount_h)( mt_entry, data );
|
||||
if ( rv == 0 ) {
|
||||
if ( target != NULL ) {
|
||||
rv = register_subordinate_file_system( mt_entry, target );
|
||||
|
||||
@@ -39,7 +39,8 @@
|
||||
#include <rtems/seterr.h>
|
||||
|
||||
int rtems_filesystem_default_mount (
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry /* IN */
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry, /* IN */
|
||||
const void *data
|
||||
)
|
||||
{
|
||||
rtems_set_errno_and_return_minus_one( ENOTSUP );
|
||||
|
||||
@@ -63,7 +63,7 @@ const rtems_filesystem_operations_table msdos_ops = {
|
||||
.chown_h = rtems_filesystem_default_chown,
|
||||
.clonenod_h = msdos_clone_node_info,
|
||||
.freenod_h = msdos_free_node_info,
|
||||
.mount_h = rtems_filesystem_default_mount,
|
||||
.mount_h = rtems_dosfs_initialize,
|
||||
.unmount_h = rtems_filesystem_default_unmount,
|
||||
.fsunmount_me_h = msdos_shut_down,
|
||||
.utimens_h = msdos_utimens,
|
||||
|
||||
@@ -43,11 +43,13 @@
|
||||
|
||||
#include <rtems/imfs.h>
|
||||
|
||||
int IMFS_mount( rtems_filesystem_mount_table_entry_t *mt_entry )
|
||||
int IMFS_mount( rtems_filesystem_mount_table_entry_t *mt_entry, const void *data )
|
||||
{
|
||||
int rv = 0;
|
||||
IMFS_jnode_t *node = mt_entry->mt_point_node->location.node_access;
|
||||
|
||||
(void) data; /* runtime options checks can be added here */
|
||||
|
||||
if ( IMFS_is_directory( node ) ) {
|
||||
IMFS_directory_t *dir = (IMFS_directory_t *) node;
|
||||
|
||||
|
||||
@@ -749,7 +749,7 @@ const rtems_filesystem_operations_table rtems_rfs_ops =
|
||||
.chown_h = rtems_rfs_rtems_chown,
|
||||
.clonenod_h = rtems_filesystem_default_clonenode,
|
||||
.freenod_h = rtems_filesystem_default_freenode,
|
||||
.mount_h = rtems_filesystem_default_mount,
|
||||
.mount_h = rtems_rfs_rtems_initialise,
|
||||
.unmount_h = rtems_filesystem_default_unmount,
|
||||
.fsunmount_me_h = rtems_rfs_rtems_shutdown,
|
||||
.utimens_h = rtems_rfs_rtems_utimens,
|
||||
|
||||
Reference in New Issue
Block a user