diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2010-07-01 15:18:06 +0000 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2010-07-01 15:18:06 +0000 |
commit | 955a34b566dbd7076084dff82ec5468b9c6d8336 (patch) | |
tree | 1395933adfd0fcbeb17d6cbd0e9ce69afd72d242 /cpukit | |
parent | 2010-06-29 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff) | |
download | rtems-955a34b566dbd7076084dff82ec5468b9c6d8336.tar.bz2 |
2010-07-01 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libcsupport/include/rtems/libio_.h: Removed
rtems_filesystem_mount_table_control.
* libcsupport/include/rtems/libio.h, libcsupport/src/mount-mgr.c,
libcsupport/src/mount.c libcsupport/src/statvfs.c,
libcsupport/src/unmount.c, libmisc/shell/main_mount.c: Documentation.
Removed rtems_filesystem_mounts_first() and
rtems_filesystem_mounts_next(). Added
rtems_filesystem_mount_iterate(). Changed return type of
rtems_filesystem_iterate(). Removed rtems_filesystem_nodes_equal().
2010-07-01 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libfs/src/nfsclient/src/nfs.c, libfs/src/nfsclient/src/nfs.c,
libfs/src/nfsclient/src/librtemsNfs.h: Renamed
rtems_nfsfs_initialize() in rtems_nfs_initialize().
* sapi/include/confdefs.h: Reflect changes above. Renamed
*_miniIMFS in *_MINIIMFS. Renamed *_NFSFS in *_NFS.
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/ChangeLog | 20 | ||||
-rw-r--r-- | cpukit/libcsupport/include/rtems/libio.h | 389 | ||||
-rw-r--r-- | cpukit/libcsupport/include/rtems/libio_.h | 5 | ||||
-rw-r--r-- | cpukit/libcsupport/src/mount-mgr.c | 37 | ||||
-rw-r--r-- | cpukit/libcsupport/src/mount.c | 90 | ||||
-rw-r--r-- | cpukit/libcsupport/src/statvfs.c | 5 | ||||
-rw-r--r-- | cpukit/libcsupport/src/unmount.c | 57 | ||||
-rw-r--r-- | cpukit/libfs/src/nfsclient/src/librtemsNfs.h | 4 | ||||
-rw-r--r-- | cpukit/libfs/src/nfsclient/src/nfs.c | 6 | ||||
-rw-r--r-- | cpukit/libmisc/shell/main_mount.c | 2 | ||||
-rw-r--r-- | cpukit/sapi/include/confdefs.h | 36 |
11 files changed, 344 insertions, 307 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index 2da818c276..be45203b42 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,3 +1,23 @@ +2010-07-01 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * libcsupport/include/rtems/libio_.h: Removed + rtems_filesystem_mount_table_control. + * libcsupport/include/rtems/libio.h, libcsupport/src/mount-mgr.c, + libcsupport/src/mount.c libcsupport/src/statvfs.c, + libcsupport/src/unmount.c, libmisc/shell/main_mount.c: Documentation. + Removed rtems_filesystem_mounts_first() and + rtems_filesystem_mounts_next(). Added + rtems_filesystem_mount_iterate(). Changed return type of + rtems_filesystem_iterate(). Removed rtems_filesystem_nodes_equal(). + +2010-07-01 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * libfs/src/nfsclient/src/nfs.c, libfs/src/nfsclient/src/nfs.c, + libfs/src/nfsclient/src/librtemsNfs.h: Renamed + rtems_nfsfs_initialize() in rtems_nfs_initialize(). + * sapi/include/confdefs.h: Reflect changes above. Renamed + *_miniIMFS in *_MINIIMFS. Renamed *_NFSFS in *_NFS. + 2010-06-29 Sebastian Huber <sebastian.huber@embedded-brains.de> * libnetworking/lib/tftpDriver.c: rtems_tftp_ops and diff --git a/cpukit/libcsupport/include/rtems/libio.h b/cpukit/libcsupport/include/rtems/libio.h index d705228c4b..7db9524ef7 100644 --- a/cpukit/libcsupport/include/rtems/libio.h +++ b/cpukit/libcsupport/include/rtems/libio.h @@ -314,46 +314,6 @@ struct _rtems_filesystem_operations_table { }; /** - * @brief File system table entry. - */ -typedef struct rtems_filesystem_table_t { - const char *type; - rtems_filesystem_fsmount_me_t mount_h; -} rtems_filesystem_table_t; - -/** - * @brief Static table of file systems. - * - * Externally defined by confdefs.h or the user. - */ -extern const rtems_filesystem_table_t rtems_filesystem_table []; - -/** - * @brief Per file system table entry routine type. - * - * @see rtems_filesystem_iterate(). - * - * @retval true Continue the iteration. - * @retval false Stop the iteration. - */ -typedef bool (*rtems_per_filesystem_routine)( - const rtems_filesystem_table_t *entry, - void *arg -); - -/** - * @brief Iterates over the file system table. - * - * For each file system table entry the @a routine will be called with the - * table entry and the @a routine_arg parameter. - */ -void -rtems_filesystem_iterate( - rtems_per_filesystem_routine routine, - void *routine_arg -); - -/** * @brief Gets the mount handler for the file system @a type. * * @return The file system mount handler associated with the @a type, or @@ -364,35 +324,6 @@ rtems_filesystem_get_mount_handler( const char *type ); -/* - * Get the first entry in the mount table. - */ -rtems_filesystem_mount_table_entry_t* -rtems_filesystem_mounts_first( void ); - -/* - * Get the next entry in the mount table. - */ -rtems_filesystem_mount_table_entry_t* -rtems_filesystem_mounts_next( rtems_filesystem_mount_table_entry_t *entry ); - -/* - * Register a file system. - */ -int -rtems_filesystem_register( - const char *type, - rtems_filesystem_fsmount_me_t mount_h -); - -/* - * Unregister a file system. - */ -int -rtems_filesystem_unregister( - const char *type -); - /** * @brief Contain file system specific information which is required to support * fpathconf(). @@ -420,67 +351,6 @@ typedef struct { extern const rtems_filesystem_limits_and_options_t rtems_filesystem_default_pathconf; /** - * @brief Mount table entry. - */ -struct rtems_filesystem_mount_table_entry_tt { - rtems_chain_node Node; - rtems_filesystem_location_info_t mt_point_node; - rtems_filesystem_location_info_t mt_fs_root; - int options; - void *fs_info; - - rtems_filesystem_limits_and_options_t pathconf_limits_and_options; - - /* - * The target or mount point of the file system. - */ - const char *target; - - /* - * The type of filesystem or the name of the filesystem. - */ - const char *type; - - /* - * When someone adds a mounted filesystem on a real device, - * this will need to be used. - * - * The lower layers can manage how this is managed. Leave as a - * string. - */ - char *dev; -}; - -/** - * @brief The pathconf setting for a file system. - */ -#define rtems_filesystem_pathconf(_mte) ((_mte)->pathconf_limits_and_options) - -/** - * @brief The type of file system. Its name. - */ -#define rtems_filesystem_type(_mte) ((_mte)->type) - -/** - * @brief The mount point of a file system. - */ -#define rtems_filesystem_mount_point(_mte) ((_mte)->target) - -/** - * @brief The device entry of a file system. - */ -#define rtems_filesystem_mount_device(_mte) ((_mte)->dev) - -/** - * @brief File systems options. - */ -typedef enum { - RTEMS_FILESYSTEM_READ_ONLY, - RTEMS_FILESYSTEM_READ_WRITE, - RTEMS_FILESYSTEM_BAD_OPTIONS -} rtems_filesystem_options_t; - -/** * @brief An open file data structure. * * It will be indexed by 'fd'. @@ -669,6 +539,46 @@ static inline rtems_device_minor_number rtems_filesystem_dev_minor_t( #define rtems_libio_is_valid_perms( _perm ) \ (~ ((~RTEMS_LIBIO_PERMS_RWX) & _perm )) +/* + * Prototypes for filesystem + */ + +void rtems_filesystem_initialize( void ); + +typedef void (*rtems_libio_init_functions_t)(void); +extern rtems_libio_init_functions_t rtems_libio_init_helper; + +void open_dev_console(void); + +typedef void (*rtems_libio_supp_functions_t)(void); +extern rtems_libio_supp_functions_t rtems_libio_supp_helper; + +typedef void (*rtems_fs_init_functions_t)(void); +extern rtems_fs_init_functions_t rtems_fs_init_helper; + +/** + * @brief Creates a directory and all its parent directories according to + * @a path. + * + * The @a mode value selects the access permissions of the directory. + * + * @retval 0 Successful operation. + * @retval -1 An error occured. The @c errno indicates the error. + */ +extern int rtems_mkdir(const char *path, mode_t mode); + +/** @} */ + +/** + * @defgroup FileSystemTypesAndMount File System Types and Mount + * + * @ingroup LibIO + * + * @brief File system types and mount. + * + * @{ + */ + /** * @name File System Types * @@ -686,16 +596,132 @@ static inline rtems_device_minor_number rtems_filesystem_dev_minor_t( /** @} */ -/* - * Prototypes for filesystem +/** + * @brief Mount table entry. */ +struct rtems_filesystem_mount_table_entry_tt { + rtems_chain_node Node; + rtems_filesystem_location_info_t mt_point_node; + rtems_filesystem_location_info_t mt_fs_root; + int options; + void *fs_info; -void rtems_filesystem_initialize( void ); + rtems_filesystem_limits_and_options_t pathconf_limits_and_options; + + /* + * The target or mount point of the file system. + */ + const char *target; + + /* + * The type of filesystem or the name of the filesystem. + */ + const char *type; + + /* + * When someone adds a mounted filesystem on a real device, + * this will need to be used. + * + * The lower layers can manage how this is managed. Leave as a + * string. + */ + char *dev; +}; +/** + * @brief File system options. + */ +typedef enum { + RTEMS_FILESYSTEM_READ_ONLY, + RTEMS_FILESYSTEM_READ_WRITE, + RTEMS_FILESYSTEM_BAD_OPTIONS +} rtems_filesystem_options_t; + +/** + * @brief File system table entry. + */ +typedef struct rtems_filesystem_table_t { + const char *type; + rtems_filesystem_fsmount_me_t mount_h; +} rtems_filesystem_table_t; + +/** + * @brief Static table of file systems. + * + * Externally defined by confdefs.h or the user. + */ +extern const rtems_filesystem_table_t rtems_filesystem_table []; + +/** + * @brief Registers a file system @a type. + * + * The @a mount_h handler will be used to mount a file system of this @a type. + * + * @retval 0 Successful operation. + * @retval -1 An error occured. The @c errno indicates the error. + */ +int rtems_filesystem_register( + const char *type, + rtems_filesystem_fsmount_me_t mount_h +); + +/** + * @brief Unregisters a file system @a type. + * + * @retval 0 Successful operation. + * @retval -1 An error occured. The @c errno indicates the error. + */ +int rtems_filesystem_unregister( + const char *type +); + +/** + * @brief Unmounts the file system at @a mount_path. + * + * @todo Due to file system implementation shortcomings it is possible to + * unmount file systems in use. This likely leads to heap corruption. Unmount + * only file systems which are not in use by the application. + * + * @retval 0 Successful operation. + * @retval -1 An error occured. The @c errno indicates the error. + */ int unmount( const char *mount_path ); +/** + * @brief Mounts a file system at @a target. + * + * The @a source may be a path to the corresponding device file, or @c NULL. + * The @a target path must lead to an existing directory, or @c NULL. In case + * @a target is @c NULL, the root file system will be mounted. The @a data + * parameter will be forwarded to the file system initialization handler. The + * file system type is selected by @a filesystemtype and may be one of + * - RTEMS_FILESYSTEM_TYPE_DEVFS, + * - RTEMS_FILESYSTEM_TYPE_DOSFS, + * - RTEMS_FILESYSTEM_TYPE_FTPFS, + * - RTEMS_FILESYSTEM_TYPE_IMFS, + * - RTEMS_FILESYSTEM_TYPE_MINIIMFS, + * - RTEMS_FILESYSTEM_TYPE_NFS, + * - RTEMS_FILESYSTEM_TYPE_RFS, or + * - RTEMS_FILESYSTEM_TYPE_TFTPFS. + * + * Only configured or registered file system types are available. You can add + * file system types to your application configuration with + * - CONFIGURE_FILESYSTEM_DEVFS, + * - CONFIGURE_FILESYSTEM_DOSFS, + * - CONFIGURE_FILESYSTEM_FTPFS, + * - CONFIGURE_FILESYSTEM_IMFS, + * - CONFIGURE_FILESYSTEM_MINIIMFS, + * - CONFIGURE_FILESYSTEM_NFS, + * - CONFIGURE_FILESYSTEM_RFS, and + * - CONFIGURE_FILESYSTEM_TFTPFS. + * + * @see rtems_filesystem_register() and mount_and_make_target_path(). + * + * @retval 0 Successful operation. + * @retval -1 An error occured. The @c errno indicates the error. + */ int mount( const char *source, const char *target, @@ -723,10 +749,72 @@ int mount_and_make_target_path( const void *data ); -/* - * Boot Time Mount Table Structure +/** + * @brief Per file system type routine. + * + * @see rtems_filesystem_iterate(). + * + * @retval true Stop the iteration. + * @retval false Continue the iteration. + */ +typedef bool (*rtems_per_filesystem_routine)( + const rtems_filesystem_table_t *fs_entry, + void *arg +); + +/** + * @brief Iterates over all file system types. + * + * For each file system type the @a routine will be called with the entry and + * the @a routine_arg parameter. + * + * Do not register or unregister file system types in @a routine. + * + * The iteration is protected by the IO library mutex. + * + * @retval true Iteration stopped due to @a routine return status. + * @retval false Iteration through all entries. + */ +bool rtems_filesystem_iterate( + rtems_per_filesystem_routine routine, + void *routine_arg +); + +/** + * @brief Per file system mount routine. + * + * @see rtems_filesystem_mount_iterate(). + * + * @retval true Stop the iteration. + * @retval false Continue the iteration. + */ +typedef bool (*rtems_per_filesystem_mount_routine)( + const rtems_filesystem_mount_table_entry_t *mt_entry, + void *arg +); + +/** + * @brief Iterates over all file system mounts. + * + * For each file system mount the @a routine will be called with the entry and + * the @a routine_arg parameter. + * + * Do not mount or unmount file systems in @a routine. + * + * The iteration is protected by the IO library mutex. + * + * @retval true Iteration stopped due to @a routine return status. + * @retval false Iteration through all entries. */ +bool +rtems_filesystem_mount_iterate( + rtems_per_filesystem_mount_routine routine, + void *routine_arg +); +/** + * @brief Boot time mount table entry. + */ typedef struct { const char *type; rtems_filesystem_options_t fsoptions; @@ -737,17 +825,6 @@ typedef struct { extern const rtems_filesystem_mount_table_t *rtems_filesystem_mount_table; extern const int rtems_filesystem_mount_table_size; -typedef void (*rtems_libio_init_functions_t)(void); -extern rtems_libio_init_functions_t rtems_libio_init_helper; - -void open_dev_console(void); - -typedef void (*rtems_libio_supp_functions_t)(void); -extern rtems_libio_supp_functions_t rtems_libio_supp_helper; - -typedef void (*rtems_fs_init_functions_t)(void); -extern rtems_fs_init_functions_t rtems_fs_init_helper; - /** * @brief Creates a directory and all its parrent directories according to * @a path. @@ -831,6 +908,26 @@ int rtems_termios_dequeue_characters( /** @} */ +/** + * @brief The pathconf setting for a file system. + */ +#define rtems_filesystem_pathconf(_mte) ((_mte)->pathconf_limits_and_options) + +/** + * @brief The type of file system. Its name. + */ +#define rtems_filesystem_type(_mte) ((_mte)->type) + +/** + * @brief The mount point of a file system. + */ +#define rtems_filesystem_mount_point(_mte) ((_mte)->target) + +/** + * @brief The device entry of a file system. + */ +#define rtems_filesystem_mount_device(_mte) ((_mte)->dev) + #ifdef __cplusplus } #endif diff --git a/cpukit/libcsupport/include/rtems/libio_.h b/cpukit/libcsupport/include/rtems/libio_.h index 3f897885bb..ad00f8785f 100644 --- a/cpukit/libcsupport/include/rtems/libio_.h +++ b/cpukit/libcsupport/include/rtems/libio_.h @@ -40,11 +40,6 @@ extern rtems_id rtems_libio_semaphore; extern const rtems_filesystem_file_handlers_r rtems_filesystem_null_handlers; /* - * Mount table list. - */ -extern rtems_chain_control rtems_filesystem_mount_table_control; - -/* * File descriptor Table Information */ diff --git a/cpukit/libcsupport/src/mount-mgr.c b/cpukit/libcsupport/src/mount-mgr.c index 03ead45c9b..e2523978bb 100644 --- a/cpukit/libcsupport/src/mount-mgr.c +++ b/cpukit/libcsupport/src/mount-mgr.c @@ -37,38 +37,37 @@ typedef struct { rtems_filesystem_table_t entry; } filesystem_node; -RTEMS_CHAIN_DEFINE_EMPTY(filesystem_chain); +static RTEMS_CHAIN_DEFINE_EMPTY(filesystem_chain); -void -rtems_filesystem_iterate( +bool rtems_filesystem_iterate( rtems_per_filesystem_routine routine, void *routine_arg ) { const rtems_filesystem_table_t *table_entry = &rtems_filesystem_table [0]; rtems_chain_node *node = NULL; + bool stop = false; - while ( table_entry->type ) { - if ( !(*routine)( table_entry, routine_arg ) ) { - break; - } - + while ( table_entry->type && !stop ) { + stop = (*routine)( table_entry, routine_arg ); ++table_entry; } - rtems_libio_lock(); - for ( - node = rtems_chain_first( &filesystem_chain ); - !rtems_chain_is_tail( &filesystem_chain, node ); - node = rtems_chain_next( node ) - ) { - const filesystem_node *fsn = (filesystem_node *) node; + if ( !stop ) { + rtems_libio_lock(); + for ( + node = rtems_chain_first( &filesystem_chain ); + !rtems_chain_is_tail( &filesystem_chain, node ) && !stop; + node = rtems_chain_next( node ) + ) { + const filesystem_node *fsn = (filesystem_node *) node; - if ( !(*routine)( &fsn->entry, routine_arg ) ) { - break; + stop = (*routine)( &fsn->entry, routine_arg ); } + rtems_libio_unlock(); } - rtems_libio_unlock(); + + return stop; } typedef struct { @@ -81,7 +80,7 @@ static bool find_handler(const rtems_filesystem_table_t *entry, void *arg) find_arg *fa = arg; if ( strcmp( entry->type, fa->type ) != 0 ) { - return true; + return false; } else { fa->mount_h = entry->mount_h; diff --git a/cpukit/libcsupport/src/mount.c b/cpukit/libcsupport/src/mount.c index b4f3fd4d5e..979382e8a2 100644 --- a/cpukit/libcsupport/src/mount.c +++ b/cpukit/libcsupport/src/mount.c @@ -36,10 +36,7 @@ #include <rtems/libio_.h> -/* - * Mount table list. - */ -RTEMS_CHAIN_DEFINE_EMPTY(rtems_filesystem_mount_table_control); +static RTEMS_CHAIN_DEFINE_EMPTY(mount_chain); /* * Default pathconfs. @@ -59,37 +56,12 @@ const rtems_filesystem_limits_and_options_t rtems_filesystem_default_pathconf = 0 /* posix_vdisable: special char processing, 0=no, 1=yes */ }; -/* - * Is_node_fs_root - * - * This routine will run through the entries that currently exist in the - * mount table chain. For each entry in the mount table chain it will - * compare the mount tables root node to the node describing the selected - * mount point. If any match is found true is returned else false is - * returned. - * - */ - -static bool Is_node_fs_root( - rtems_filesystem_location_info_t *loc +static bool is_node_fs_root( + const rtems_filesystem_mount_table_entry_t *mt_entry, + void *arg ) { - rtems_chain_node *node = NULL; - - /* - * For each mount table entry - */ - for ( node = rtems_chain_first( &rtems_filesystem_mount_table_control ); - !rtems_chain_is_tail( &rtems_filesystem_mount_table_control, node ); - node = rtems_chain_next( node ) ) { - rtems_filesystem_mount_table_entry_t *mount_table_entry = - (rtems_filesystem_mount_table_entry_t *) node; - - if ( mount_table_entry->mt_fs_root.node_access == loc->node_access ) - return true; - } - - return false; + return arg == mt_entry->mt_fs_root.node_access; } static rtems_filesystem_mount_table_entry_t *alloc_mount_table_entry( @@ -225,7 +197,7 @@ int mount( * You can only mount one file system onto a single mount point. */ - if ( Is_node_fs_root( &loc ) ){ + if ( rtems_filesystem_mount_iterate( is_node_fs_root, loc.node_access ) ) { errno = EBUSY; goto cleanup_and_bail; } @@ -260,7 +232,7 @@ int mount( /* * Do we already have a base file system ? */ - if ( !rtems_chain_is_empty( &rtems_filesystem_mount_table_control ) ) { + if ( !rtems_chain_is_empty( &mount_chain ) ) { errno = EINVAL; goto cleanup_and_bail; } @@ -285,8 +257,9 @@ int mount( /* * Add the mount table entry to the mount table chain */ - rtems_chain_append( &rtems_filesystem_mount_table_control, - &mt_entry->Node ); + rtems_libio_lock(); + rtems_chain_append( &mount_chain, &mt_entry->Node ); + rtems_libio_unlock(); if ( !has_target ) rtems_filesystem_root = mt_entry->mt_fs_root; @@ -303,33 +276,26 @@ cleanup_and_bail: return -1; } -/* - * Get the first entry in the mount table. - */ -rtems_filesystem_mount_table_entry_t * -rtems_filesystem_mounts_first( - void +bool rtems_filesystem_mount_iterate( + rtems_per_filesystem_mount_routine routine, + void *routine_arg ) { - rtems_filesystem_mount_table_entry_t *entry = NULL; - - if ( !rtems_chain_is_empty( &rtems_filesystem_mount_table_control ) ) - entry = (rtems_filesystem_mount_table_entry_t *) - rtems_chain_first( &rtems_filesystem_mount_table_control ); + rtems_chain_node *node = NULL; + bool stop = false; + + rtems_libio_lock(); + for ( + node = rtems_chain_first( &mount_chain ); + !rtems_chain_is_tail( &mount_chain, node ) && !stop; + node = rtems_chain_next( node ) + ) { + const rtems_filesystem_mount_table_entry_t *mt_entry = + (rtems_filesystem_mount_table_entry_t *) node; - return entry; -} + stop = (*routine)( mt_entry, routine_arg ); + } + rtems_libio_unlock(); -/* - * Get the next entry in the mount table. - */ -rtems_filesystem_mount_table_entry_t * -rtems_filesystem_mounts_next( - rtems_filesystem_mount_table_entry_t *entry -) -{ - if ( !entry ) - return NULL; - return (rtems_filesystem_mount_table_entry_t *) - rtems_chain_next( &entry->Node ); + return stop; } diff --git a/cpukit/libcsupport/src/statvfs.c b/cpukit/libcsupport/src/statvfs.c index 7815118d6f..24d6415c49 100644 --- a/cpukit/libcsupport/src/statvfs.c +++ b/cpukit/libcsupport/src/statvfs.c @@ -21,11 +21,6 @@ #include <sys/statvfs.h> -/* - * Data structures and routines private to mount/unmount pair. - */ -extern rtems_chain_control rtems_filesystem_mount_table_control; - int statvfs (const char *path, struct statvfs *sb) { diff --git a/cpukit/libcsupport/src/unmount.c b/cpukit/libcsupport/src/unmount.c index b535ea9b53..12c659dd6d 100644 --- a/cpukit/libcsupport/src/unmount.c +++ b/cpukit/libcsupport/src/unmount.c @@ -22,7 +22,6 @@ #include <sys/types.h> #include <sys/stat.h> -#include <rtems/chain.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> @@ -32,51 +31,14 @@ #include <rtems/libio_.h> #include <rtems/seterr.h> +#include <rtems/chain.h> -bool rtems_filesystem_nodes_equal( - const rtems_filesystem_location_info_t *loc1, - const rtems_filesystem_location_info_t *loc2 -){ - return ( loc1->node_access == loc2->node_access ); -} - - -/* - * file_systems_below_this_mountpoint - * - * This routine will run through the entries that currently exist in the - * mount table chain. For each entry in the mount table chain it will - * compare the mount tables mt_fs_root to the new_fs_root_node. If any of the - * mount table file system root nodes matches the new file system root node - * this indicates that we are trying to mount a file system that has already - * been mounted. This is not a permitted operation. temp_loc is set to - * the root node of the file system being unmounted. - */ - -bool file_systems_below_this_mountpoint( - const char *path __attribute__((unused)), - rtems_filesystem_location_info_t *fs_root_loc, - rtems_filesystem_mount_table_entry_t *fs_to_unmount __attribute__((unused)) +static bool is_fs_below_mount_point( + const rtems_filesystem_mount_table_entry_t *mt_entry, + void *arg ) { - rtems_chain_node *the_node; - rtems_filesystem_mount_table_entry_t *the_mount_entry; - - /* - * Search the mount table for any mount entries referencing this - * mount entry. - */ - - for ( the_node = rtems_filesystem_mount_table_control.first; - !rtems_chain_is_tail( &rtems_filesystem_mount_table_control, the_node ); - the_node = the_node->next ) { - the_mount_entry = ( rtems_filesystem_mount_table_entry_t * )the_node; - if (the_mount_entry->mt_point_node.mt_entry == fs_root_loc->mt_entry ) { - return true; - } - } - - return false; + return arg == mt_entry->mt_point_node.mt_entry; } /* @@ -114,7 +76,7 @@ int unmount( * Verify this is the root node for the file system to be unmounted. */ - if ( !rtems_filesystem_nodes_equal( fs_root_loc, &loc) ){ + if ( fs_root_loc->node_access != loc.node_access ){ rtems_filesystem_freenode( &loc ); rtems_set_errno_and_return_minus_one( EACCES ); } @@ -151,7 +113,8 @@ int unmount( * Verify there are no file systems below the path specified */ - if ( file_systems_below_this_mountpoint( path, fs_root_loc, mt_entry ) != 0 ) + if ( rtems_filesystem_mount_iterate( is_fs_below_mount_point, + fs_root_loc->mt_entry ) ) rtems_set_errno_and_return_minus_one( EBUSY ); /* @@ -195,7 +158,9 @@ int unmount( * Extract the mount table entry from the chain */ - rtems_chain_extract( ( rtems_chain_node * ) mt_entry ); + rtems_libio_lock(); + rtems_chain_extract( &mt_entry->Node ); + rtems_libio_unlock(); /* * Free the memory node that was allocated in mount diff --git a/cpukit/libfs/src/nfsclient/src/librtemsNfs.h b/cpukit/libfs/src/nfsclient/src/librtemsNfs.h index 01ef9a3a76..fc17d1de7f 100644 --- a/cpukit/libfs/src/nfsclient/src/librtemsNfs.h +++ b/cpukit/libfs/src/nfsclient/src/librtemsNfs.h @@ -143,8 +143,8 @@ nfsMountsShow(FILE *f); * Filesystem mount table mount handler. Do not call, use the mount call. */ int -rtems_nfsfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry, - const void *data); +rtems_nfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry, + const void *data); /* A utility routine to find the path leading to a * rtems_filesystem_location_info_t node. diff --git a/cpukit/libfs/src/nfsclient/src/nfs.c b/cpukit/libfs/src/nfsclient/src/nfs.c index de902cbbad..8a7d41d5cb 100644 --- a/cpukit/libfs/src/nfsclient/src/nfs.c +++ b/cpukit/libfs/src/nfsclient/src/nfs.c @@ -1908,8 +1908,8 @@ struct rtems_filesystem_mount_table_entry_tt { #endif -int rtems_nfsfs_initialize( - rtems_filesystem_mount_table_entry_t *mt_entry, +int rtems_nfs_initialize( + rtems_filesystem_mount_table_entry_t *mt_entry, const void *data ) { @@ -2479,7 +2479,7 @@ struct _rtems_filesystem_operations_table nfs_fs_ops = { nfs_chown, /* OPTIONAL; may be NULL */ nfs_freenode, /* OPTIONAL; may be NULL; (release node_access) */ nfs_mount, /* OPTIONAL; may be NULL */ - rtems_nfsfs_initialize, /* OPTIONAL; may be NULL -- not used anymore */ + rtems_nfs_initialize, /* OPTIONAL; may be NULL -- not used anymore */ nfs_unmount, /* OPTIONAL; may be NULL */ nfs_fsunmount_me, /* OPTIONAL; may be NULL */ nfs_utime, /* OPTIONAL; may be NULL */ diff --git a/cpukit/libmisc/shell/main_mount.c b/cpukit/libmisc/shell/main_mount.c index 44a9c42665..b192a1668d 100644 --- a/cpukit/libmisc/shell/main_mount.c +++ b/cpukit/libmisc/shell/main_mount.c @@ -31,7 +31,7 @@ static bool print_filesystem(const rtems_filesystem_table_t *entry, void *arg) { printf("%s ", entry->type); - return true; + return false; } int rtems_shell_main_mount( diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h index 7df2851abc..9ee41435eb 100644 --- a/cpukit/sapi/include/confdefs.h +++ b/cpukit/sapi/include/confdefs.h @@ -188,12 +188,12 @@ rtems_fs_init_functions_t rtems_fs_init_helper = * Add file filesystems to the default filesystem table. * * List of available file systems. You can define as many as you like: - * CONFIGURE_FILESYSTEM_miniIMFS - MiniIMFS, use DEVFS now + * CONFIGURE_FILESYSTEM_MINIIMFS - MiniIMFS, use DEVFS now * CONFIGURE_FILESYSTEM_IMFS - In Memory File System (IMFS) * CONFIGURE_FILESYSTEM_DEVFS - Device File System (DSVFS) * CONFIGURE_FILESYSTEM_TFTPFS - TFTP File System, networking enabled * CONFIGURE_FILESYSTEM_FTPFS - FTP File System, networking enabled - * CONFIGURE_FILESYSTEM_NFSFS - Network File System, networking enabled + * CONFIGURE_FILESYSTEM_NFS - Network File System, networking enabled * CONFIGURE_FILESYSTEM_DOSFS - DOS File System, uses libblock * CONFIGURE_FILESYSTEM_RFS - RTEMS File System (RFS), uses libblock * @@ -215,12 +215,12 @@ rtems_fs_init_functions_t rtems_fs_init_helper = * been disabled. */ #ifdef CONFIGURE_FILESYSTEM_ALL - #define CONFIGURE_FILESYSTEM_miniIMFS + #define CONFIGURE_FILESYSTEM_MINIIMFS #define CONFIGURE_FILESYSTEM_IMFS #define CONFIGURE_FILESYSTEM_DEVFS #define CONFIGURE_FILESYSTEM_TFTPFS #define CONFIGURE_FILESYSTEM_FTPFS - #define CONFIGURE_FILESYSTEM_NFSFS + #define CONFIGURE_FILESYSTEM_NFS #define CONFIGURE_FILESYSTEM_DOSFS #define CONFIGURE_FILESYSTEM_RFS #endif @@ -239,12 +239,12 @@ rtems_fs_init_functions_t rtems_fs_init_helper = #elif defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) #undef CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM #endif - #undef CONFIGURE_FILESYSTEM_miniIMFS + #undef CONFIGURE_FILESYSTEM_MINIIMFS #undef CONFIGURE_FILESYSTEM_IMFS #undef CONFIGURE_FILESYSTEM_DEVFS #undef CONFIGURE_FILESYSTEM_TFTPFS #undef CONFIGURE_FILESYSTEM_FTPFS - #undef CONFIGURE_FILESYSTEM_NFSFS + #undef CONFIGURE_FILESYSTEM_NFS #undef CONFIGURE_FILESYSTEM_DOSFS #undef CONFIGURE_FILESYSTEM_RFS #endif @@ -257,7 +257,7 @@ rtems_fs_init_functions_t rtems_fs_init_helper = #if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) #define CONFIGURE_FILESYSTEM_DEVFS #elif defined(CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM) - #define CONFIGURE_FILESYSTEM_miniIMFS + #define CONFIGURE_FILESYSTEM_MINIIMFS #elif !defined(CONFIGURE_FILESYSTEM_IMFS) #define CONFIGURE_FILESYSTEM_IMFS #endif @@ -285,7 +285,7 @@ rtems_fs_init_functions_t rtems_fs_init_helper = * This defines the miniIMFS file system table entry. */ #if !defined(CONFIGURE_FILESYSTEM_ENTRY_miniIMFS) && \ - defined(CONFIGURE_FILESYSTEM_miniIMFS) + defined(CONFIGURE_FILESYSTEM_MINIIMFS) #define CONFIGURE_FILESYSTEM_ENTRY_miniIMFS \ { RTEMS_FILESYSTEM_TYPE_MINIIMFS, miniIMFS_initialize } #endif @@ -330,13 +330,13 @@ rtems_fs_init_functions_t rtems_fs_init_helper = #endif /** - * NFSFS + * NFS */ - #if !defined(CONFIGURE_FILESYSTEM_ENTRY_NFSFS) && \ - defined(CONFIGURE_FILESYSTEM_NFSFS) + #if !defined(CONFIGURE_FILESYSTEM_ENTRY_NFS) && \ + defined(CONFIGURE_FILESYSTEM_NFS) #include <librtemsNfs.h> - #define CONFIGURE_FILESYSTEM_ENTRY_NFSFS \ - { RTEMS_FILESYSTEM_TYPE_NFS, rtems_nfsfs_initialize } + #define CONFIGURE_FILESYSTEM_ENTRY_NFS \ + { RTEMS_FILESYSTEM_TYPE_NFS, rtems_nfs_initialize } #endif #endif @@ -381,7 +381,7 @@ rtems_fs_init_functions_t rtems_fs_init_helper = #endif #if defined(CONFIGURE_FILESYSTEM_IMFS) || \ - defined(CONFIGURE_FILESYSTEM_miniIMFS) + defined(CONFIGURE_FILESYSTEM_MINIIMFS) int imfs_rq_memfile_bytes_per_block = CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK; #endif @@ -396,7 +396,7 @@ rtems_fs_init_functions_t rtems_fs_init_helper = */ #ifndef CONFIGURE_HAS_OWN_FILESYSTEM_TABLE const rtems_filesystem_table_t rtems_filesystem_table[] = { - #if defined(CONFIGURE_FILESYSTEM_miniIMFS) && \ + #if defined(CONFIGURE_FILESYSTEM_MINIIMFS) && \ defined(CONFIGURE_FILESYSTEM_ENTRY_miniIMFS) CONFIGURE_FILESYSTEM_ENTRY_miniIMFS, #endif @@ -416,9 +416,9 @@ rtems_fs_init_functions_t rtems_fs_init_helper = defined(CONFIGURE_FILESYSTEM_ENTRY_FTPFS) CONFIGURE_FILESYSTEM_ENTRY_FTPFS, #endif - #if defined(CONFIGURE_FILESYSTEM_NFSFS) && \ - defined(CONFIGURE_FILESYSTEM_ENTRY_NFSFS) - CONFIGURE_FILESYSTEM_ENTRY_NFSFS, + #if defined(CONFIGURE_FILESYSTEM_NFS) && \ + defined(CONFIGURE_FILESYSTEM_ENTRY_NFS) + CONFIGURE_FILESYSTEM_ENTRY_NFS, #endif #if defined(CONFIGURE_FILESYSTEM_DOSFS) && \ defined(CONFIGURE_FILESYSTEM_ENTRY_DOSFS) |