diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2010-07-01 14:39:39 +0000 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2010-07-01 14:39:39 +0000 |
commit | 3d3a18e619ce62485d3508a6b7dd1467c912bbad (patch) | |
tree | eeb9b9d70190c395460d0511c0c048efc883d5c0 /cpukit/libcsupport | |
parent | 2010-06-08 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff) | |
download | rtems-3d3a18e619ce62485d3508a6b7dd1467c912bbad.tar.bz2 |
2010-06-10 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libcsupport/src/unmount.c: Removed obsolete declarations. Fixed
invalid memory free.
2010-06-10 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libnetworking/rtems/ftpfs.h, libnetworking/lib/ftpfs.c: Removed
rtems_ftpfs_mount().
2010-06-10 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libcsupport/src/mount-mktgt.c: New file.
* libcsupport/Makefile.am: Reflect change above.
* libcsupport/include/rtems/libio.h: Declare
mount_and_make_target_path().
2010-06-09 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libnetworking/rtems/ftpfs.h, libnetworking/lib/ftpfs.c: Added
rtems_ftpfs_mount() again. Documentation.
2010-06-09 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libcsupport/include/rtems/libio.h, sapi/include/confdefs.h: Added
and use defines for file system types.
2010-06-09 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libcsupport/src/mount.c: Fixed NULL pointer access.
Diffstat (limited to 'cpukit/libcsupport')
-rw-r--r-- | cpukit/libcsupport/Makefile.am | 2 | ||||
-rw-r--r-- | cpukit/libcsupport/include/rtems/libio.h | 40 | ||||
-rw-r--r-- | cpukit/libcsupport/src/mount-mktgt.c | 56 | ||||
-rw-r--r-- | cpukit/libcsupport/src/mount.c | 17 | ||||
-rw-r--r-- | cpukit/libcsupport/src/unmount.c | 11 |
5 files changed, 104 insertions, 22 deletions
diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am index 3e80056408..368833b60b 100644 --- a/cpukit/libcsupport/Makefile.am +++ b/cpukit/libcsupport/Makefile.am @@ -44,7 +44,7 @@ ASSOCIATION_C_FILES = src/assoclocalbyname.c \ src/assocremotebylocal.c src/assocremotebyname.c BASE_FS_C_FILES = src/base_fs.c src/mount.c src/unmount.c src/libio.c \ - src/mount-mgr.c src/libio_init.c \ + src/mount-mgr.c src/mount-mktgt.c src/libio_init.c \ src/libio_sockets.c src/eval.c src/fs_null_handlers.c src/privateenv.c \ src/open_dev_console.c src/__usrenv.c src/rtems_mkdir.c diff --git a/cpukit/libcsupport/include/rtems/libio.h b/cpukit/libcsupport/include/rtems/libio.h index 3e020ee2e4..d705228c4b 100644 --- a/cpukit/libcsupport/include/rtems/libio.h +++ b/cpukit/libcsupport/include/rtems/libio.h @@ -56,7 +56,7 @@ extern "C" { typedef _off64_t rtems_off64_t; /** - * @name File system node types. + * @name File System Node Types * * @{ */ @@ -669,6 +669,23 @@ static inline rtems_device_minor_number rtems_filesystem_dev_minor_t( #define rtems_libio_is_valid_perms( _perm ) \ (~ ((~RTEMS_LIBIO_PERMS_RWX) & _perm )) +/** + * @name File System Types + * + * @{ + */ + +#define RTEMS_FILESYSTEM_TYPE_IMFS "imfs" +#define RTEMS_FILESYSTEM_TYPE_MINIIMFS "mimfs" +#define RTEMS_FILESYSTEM_TYPE_DEVFS "devfs" +#define RTEMS_FILESYSTEM_TYPE_FTPFS "ftpfs" +#define RTEMS_FILESYSTEM_TYPE_TFTPFS "tftpfs" +#define RTEMS_FILESYSTEM_TYPE_NFS "nfs" +#define RTEMS_FILESYSTEM_TYPE_DOSFS "dosfs" +#define RTEMS_FILESYSTEM_TYPE_RFS "rfs" + +/** @} */ + /* * Prototypes for filesystem */ @@ -687,6 +704,25 @@ int mount( const void *data ); +/** + * @brief Mounts a file system and makes the @a target path. + * + * The @a target path will be created with rtems_mkdir() and must not be + * @c NULL. + * + * @see mount(). + * + * @retval 0 Successful operation. + * @retval -1 An error occured. The @c errno indicates the error. + */ +int mount_and_make_target_path( + const char *source, + const char *target, + const char *filesystemtype, + rtems_filesystem_options_t options, + const void *data +); + /* * Boot Time Mount Table Structure */ @@ -719,7 +755,7 @@ extern rtems_fs_init_functions_t rtems_fs_init_helper; * The @a mode value selects the access permissions of the directory. * * @retval 0 Successful operation. - * @retval -1 An error occured. @c errno indicates the error. + * @retval -1 An error occured. The @c errno indicates the error. */ extern int rtems_mkdir(const char *path, mode_t mode); diff --git a/cpukit/libcsupport/src/mount-mktgt.c b/cpukit/libcsupport/src/mount-mktgt.c new file mode 100644 index 0000000000..3b4d50aded --- /dev/null +++ b/cpukit/libcsupport/src/mount-mktgt.c @@ -0,0 +1,56 @@ +/** + * @file + * + * @ingroup LibIO + * + * @brief mount_and_make_target_path() implementation. + */ + +/* + * Copyright (c) 2010 + * embedded brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <errno.h> + +#include <rtems/libio.h> + +int mount_and_make_target_path( + const char *source, + const char *target, + const char *filesystemtype, + rtems_filesystem_options_t options, + const void *data +) +{ + int rv = -1; + + if (target != NULL) { + rv = rtems_mkdir(target, S_IRWXU | S_IRWXG | S_IRWXO); + if (rv == 0) { + rv = mount( + source, + target, + filesystemtype, + options, + data + ); + } + } else { + errno = EINVAL; + } + + return rv; +} diff --git a/cpukit/libcsupport/src/mount.c b/cpukit/libcsupport/src/mount.c index 07f41f2ee4..c73ce89e35 100644 --- a/cpukit/libcsupport/src/mount.c +++ b/cpukit/libcsupport/src/mount.c @@ -93,30 +93,31 @@ static bool Is_node_fs_root( } static rtems_filesystem_mount_table_entry_t *alloc_mount_table_entry( - const char *source, - const char *target, + const char *source_or_null, + const char *target_or_null, const char *filesystemtype, size_t *target_length_ptr ) { - const char *target_str = target ? target : "/"; + const char *target = target_or_null != NULL ? target_or_null : "/"; size_t filesystemtype_size = strlen( filesystemtype ) + 1; - size_t source_size = source ? strlen( source ) + 1 : 0; - size_t target_length = strlen( target_str ); + size_t source_size = source_or_null != NULL ? + strlen( source_or_null ) + 1 : 0; + size_t target_length = strlen( target ); size_t size = sizeof( rtems_filesystem_mount_table_entry_t ) + filesystemtype_size + source_size + target_length + 1; rtems_filesystem_mount_table_entry_t *mt_entry = calloc( 1, size ); - if ( mt_entry ) { + if ( mt_entry != NULL ) { char *str = (char *) mt_entry + sizeof( *mt_entry ); mt_entry->type = str; strcpy( str, filesystemtype ); - if ( source ) { + if ( source_or_null != NULL ) { str += filesystemtype_size; mt_entry->dev = str; - strcpy( str, source ); + strcpy( str, source_or_null ); } str += source_size; diff --git a/cpukit/libcsupport/src/unmount.c b/cpukit/libcsupport/src/unmount.c index 164cf6ef69..b535ea9b53 100644 --- a/cpukit/libcsupport/src/unmount.c +++ b/cpukit/libcsupport/src/unmount.c @@ -33,16 +33,6 @@ #include <rtems/libio_.h> #include <rtems/seterr.h> -/* - * Data structures and routines private to mount/unmount pair. - */ - -extern rtems_chain_control rtems_filesystem_mount_table_control; - -int search_mt_for_mount_point( - rtems_filesystem_location_info_t *location_of_mount_point -); - bool rtems_filesystem_nodes_equal( const rtems_filesystem_location_info_t *loc1, const rtems_filesystem_location_info_t *loc2 @@ -213,7 +203,6 @@ int unmount( */ rtems_filesystem_freenode( fs_mount_loc ); - free( (void*) mt_entry->target ); free( mt_entry ); return 0; |