<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>change log for rtems (2010-07-01)</title>
</head>
<body text='#000000' bgcolor='#ffffff'>
<a name='cs1'></a>
<table border='0' cellspacing='0' cellpadding='5' width='100%' bgcolor='#eeeeee'>
<tr><td colspan='3' bgcolor='#dddddd'>
<font color='#bb2222'><strong>sh</strong></font>
<font color='#225522'><em>(on branch rtems-4-10-branch)</em></font>
</td></tr>
<tr><td colspan='3' bgcolor='#dddddd'><pre>2010-06-07 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libcsupport/include/rtems/libio_.h: Declare
rtems_filesystem_mount_table_control.
* libcsupport/include/rtems/libio.h: Removed
rtems_filesystem_table_first(), rtems_filesystem_table_next() and
rtems_filesystem_table_node_t declarations. Declare
rtems_per_filesystem_routine, rtems_filesystem_iterate() and
rtems_filesystem_get_mount_handler().
* libcsupport/src/mount.c: Added rtems_filesystem_mounts_first() and
rtems_filesystem_mounts_next(). Simplify mount(). Removed
rtems_filesystem_mount_table_control_init. Use
rtems_filesystem_get_mount_handler().
* libcsupport/src/mount-mgr.c: Removed rtems_filesystem_mounts_first() and
rtems_filesystem_mounts_next(). Added rtems_filesystem_iterate() and
rtems_filesystem_get_mount_handler(). Use rtems_libio_lock() and
rtems_libio_unlock();
* sapi/include/confdefs.h, libmisc/shell/main_mount.c: Update for
mount API changes.
2010-06-07 Bharath Suri <bharath.s.jois@gmail.com>
* libcsupport/include/rtems/libio_.h: Removed macros
rtems_filesystem_is_separator
rtems_filesystem_get_start_loc
rtems_filesystem_get_sym_start_loc
and added them as files under libcsupport/src/
* libcsupport/src/: Added new files
libcsupport/src/sup_fs_get_start_loc.c
libcsupport/src/sup_fs_get_sym_start_loc.c
libcsupport/src/sup_fs_is_separator.c
* libcsupport/Makefile.am: Changes to accommodate new
files under libcsupport/src/
</pre></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/ChangeLog.diff?r1=text&tr1=1.2346.2.49&r2=text&tr2=1.2346.2.50&diff_format=h">M</a></td><td width='1%'>1.2346.2.50</td><td width='100%'>cpukit/ChangeLog</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libcsupport/Makefile.am.diff?r1=text&tr1=1.118&r2=text&tr2=1.118.2.1&diff_format=h">M</a></td><td width='1%'>1.118.2.1</td><td width='100%'>cpukit/libcsupport/Makefile.am</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libcsupport/include/rtems/libio.h.diff?r1=text&tr1=1.65&r2=text&tr2=1.65.2.1&diff_format=h">M</a></td><td width='1%'>1.65.2.1</td><td width='100%'>cpukit/libcsupport/include/rtems/libio.h</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libcsupport/include/rtems/libio_.h.diff?r1=text&tr1=1.34&r2=text&tr2=1.34.2.1&diff_format=h">M</a></td><td width='1%'>1.34.2.1</td><td width='100%'>cpukit/libcsupport/include/rtems/libio_.h</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libcsupport/src/mount-mgr.c.diff?r1=text&tr1=1.2&r2=text&tr2=1.2.2.1&diff_format=h">M</a></td><td width='1%'>1.2.2.1</td><td width='100%'>cpukit/libcsupport/src/mount-mgr.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libcsupport/src/mount.c.diff?r1=text&tr1=1.33&r2=text&tr2=1.33.2.1&diff_format=h">M</a></td><td width='1%'>1.33.2.1</td><td width='100%'>cpukit/libcsupport/src/mount.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libcsupport/src/sup_fs_get_start_loc.c.diff?r1=text&tr1=1.1.2.1&r2=text&tr2=1.1.2.2&diff_format=h">M</a></td><td width='1%'>1.1.2.2</td><td width='100%'>cpukit/libcsupport/src/sup_fs_get_start_loc.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libcsupport/src/sup_fs_get_sym_start_loc.c.diff?r1=text&tr1=1.1.2.1&r2=text&tr2=1.1.2.2&diff_format=h">M</a></td><td width='1%'>1.1.2.2</td><td width='100%'>cpukit/libcsupport/src/sup_fs_get_sym_start_loc.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libcsupport/src/sup_fs_is_separator.c.diff?r1=text&tr1=1.1.2.1&r2=text&tr2=1.1.2.2&diff_format=h">M</a></td><td width='1%'>1.1.2.2</td><td width='100%'>cpukit/libcsupport/src/sup_fs_is_separator.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libmisc/shell/main_mount.c.diff?r1=text&tr1=1.8&r2=text&tr2=1.8.2.1&diff_format=h">M</a></td><td width='1%'>1.8.2.1</td><td width='100%'>cpukit/libmisc/shell/main_mount.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/sapi/include/confdefs.h.diff?r1=text&tr1=1.135.2.2&r2=text&tr2=1.135.2.3&diff_format=h">M</a></td><td width='1%'>1.135.2.3</td><td width='100%'>cpukit/sapi/include/confdefs.h</td></tr>
</table>
<pre>
<font color='#006600'>diff -u rtems/cpukit/ChangeLog:1.2346.2.49 rtems/cpukit/ChangeLog:1.2346.2.50
--- rtems/cpukit/ChangeLog:1.2346.2.49 Thu Jun 24 14:57:59 2010
+++ rtems/cpukit/ChangeLog Thu Jul 1 09:10:47 2010
</font><font color='#997700'>@@ -207,6 +207,42 @@
</font> * configure.ac: Remove c4x (dead port).
* score/cpu/Makefile.am: Remove c4x (dead port).
<font color='#000088'>+2010-06-07 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
+ * libcsupport/include/rtems/libio_.h: Declare
+ rtems_filesystem_mount_table_control.
+ * libcsupport/include/rtems/libio.h: Removed
+ rtems_filesystem_table_first(), rtems_filesystem_table_next() and
+ rtems_filesystem_table_node_t declarations. Declare
+ rtems_per_filesystem_routine, rtems_filesystem_iterate() and
+ rtems_filesystem_get_mount_handler().
+ * libcsupport/src/mount.c: Added rtems_filesystem_mounts_first() and
+ rtems_filesystem_mounts_next(). Simplify mount(). Removed
+ rtems_filesystem_mount_table_control_init. Use
+ rtems_filesystem_get_mount_handler().
+ * libcsupport/src/mount-mgr.c: Removed rtems_filesystem_mounts_first() and
+ rtems_filesystem_mounts_next(). Added rtems_filesystem_iterate() and
+ rtems_filesystem_get_mount_handler(). Use rtems_libio_lock() and
+ rtems_libio_unlock();
+ * sapi/include/confdefs.h, libmisc/shell/main_mount.c: Update for
+ mount API changes.
+
+2010-06-07 Bharath Suri <bharath.s.jois@gmail.com>
+
+ * libcsupport/include/rtems/libio_.h: Removed macros
+ rtems_filesystem_is_separator
+ rtems_filesystem_get_start_loc
+ rtems_filesystem_get_sym_start_loc
+ and added them as files under libcsupport/src/
+
+ * libcsupport/src/: Added new files
+ libcsupport/src/sup_fs_get_start_loc.c
+ libcsupport/src/sup_fs_get_sym_start_loc.c
+ libcsupport/src/sup_fs_is_separator.c
+
+ * libcsupport/Makefile.am: Changes to accommodate new
+ files under libcsupport/src/
+
</font> 2010-06-03 Chris Johns <chrisj@rtems.org>
* sapi/include/confdefs.h: PR 1543. Make default file system when
<font color='#006600'>diff -u rtems/cpukit/libcsupport/Makefile.am:1.118 rtems/cpukit/libcsupport/Makefile.am:1.118.2.1
--- rtems/cpukit/libcsupport/Makefile.am:1.118 Mon May 31 08:56:36 2010
+++ rtems/cpukit/libcsupport/Makefile.am Thu Jul 1 09:10:50 2010
</font><font color='#997700'>@@ -110,6 +110,8 @@
</font>
libcsupport_a_SOURCES = src/gxx_wrappers.c src/getchark.c src/printk.c \
src/printk_plugin.c src/putk.c src/vprintk.c \
<font color='#000088'>+ src/sup_fs_is_separator.c src/sup_fs_get_start_loc.c \
+ src/sup_fs_get_sym_start_loc.c \
</font> $(BSD_LIBC_C_FILES) $(BASE_FS_C_FILES) $(MALLOC_C_FILES) \
$(ERROR_C_FILES) $(ASSOCIATION_C_FILES)
<font color='#006600'>diff -u rtems/cpukit/libcsupport/include/rtems/libio.h:1.65 rtems/cpukit/libcsupport/include/rtems/libio.h:1.65.2.1
--- rtems/cpukit/libcsupport/include/rtems/libio.h:1.65 Tue Jun 1 19:43:13 2010
+++ rtems/cpukit/libcsupport/include/rtems/libio.h Thu Jul 1 09:10:51 2010
</font><font color='#997700'>@@ -289,32 +289,51 @@
</font> rtems_filesystem_statvfs_t statvfs_h;
};
<font color='#880000'>-/*
- * File system table used by mount to manage file systems.
</font><font color='#000088'>+/**
+ * @brief File system table entry.
</font> */
typedef struct rtems_filesystem_table_t {
const char *type;
rtems_filesystem_fsmount_me_t mount_h;
} rtems_filesystem_table_t;
<font color='#880000'>-/*
- * File system table runtime loaded nodes.
</font><font color='#000088'>+/**
+ * @brief Static table of file systems.
+ *
+ * Externally defined by confdefs.h or the user.
</font> */
<font color='#880000'>-typedef struct rtems_filesystem_table_node_t {
- rtems_chain_node node;
- rtems_filesystem_table_t entry;
-} rtems_filesystem_table_node_t;
</font><font color='#000088'>+extern const rtems_filesystem_table_t rtems_filesystem_table [];
</font>
<font color='#880000'>-/*
- * Get the first entry in the filesystem table.
</font><font color='#000088'>+/**
+ * @brief Per file system table entry routine type.
+ *
+ * Return @c true to continue the iteration, and @c false to stop.
</font> */
<font color='#880000'>-const rtems_filesystem_table_t* rtems_filesystem_table_first( void );
</font><font color='#000088'>+typedef bool (*rtems_per_filesystem_routine)(
+ const rtems_filesystem_table_t *entry,
+ void *arg
+);
</font>
<font color='#880000'>-/*
- * Get the next entry in the file system table.
</font><font color='#000088'>+/**
+ * @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 Returns the file system mount handler associated with the @a type, or
+ * @c NULL if no such association exists.
</font> */
<font color='#880000'>-const rtems_filesystem_table_t*<span style="background-color: #FF0000"> </span>
-rtems_filesystem_table_next( const rtems_filesystem_table_t *entry );
</font><font color='#000088'>+rtems_filesystem_fsmount_me_t
+rtems_filesystem_get_mount_handler(
+ const char *type
+);
</font>
/*
* Get the first entry in the mount table.
<font color='#006600'>diff -u rtems/cpukit/libcsupport/include/rtems/libio_.h:1.34 rtems/cpukit/libcsupport/include/rtems/libio_.h:1.34.2.1
--- rtems/cpukit/libcsupport/include/rtems/libio_.h:1.34 Mon May 31 08:56:36 2010
+++ rtems/cpukit/libcsupport/include/rtems/libio_.h Thu Jul 1 09:10:51 2010
</font><font color='#997700'>@@ -1,4 +1,4 @@
</font><font color='#880000'>-/**
</font><font color='#000088'>+/*
</font> * @file rtems/libio_.h
*/
<font color='#997700'>@@ -40,6 +40,11 @@
</font> extern const rtems_filesystem_file_handlers_r rtems_filesystem_null_handlers;
/*
<font color='#000088'>+ * Mount table list.
+ */
+extern rtems_chain_control rtems_filesystem_mount_table_control;
+
+/*
</font> * File descriptor Table Information
*/
<font color='#997700'>@@ -90,7 +95,7 @@
</font>
#define rtems_libio_check_fd(_fd) \
do { \
<font color='#880000'>- if ((uint32_t) (_fd) >= rtems_libio_number_iops) { \
</font><font color='#000088'>+ if ((uint32_t) (_fd) >= rtems_libio_number_iops) { \
</font> errno = EBADF; \
return -1; \
} \
<font color='#997700'>@@ -129,12 +134,12 @@
</font> * Macro to check if a file descriptor is open for this operation.
*/
<font color='#880000'>-#define rtems_libio_check_permissions(_iop, _flag) \
- do { \
- if (((_iop)->flags & (_flag)) == 0) { \
</font><font color='#000088'>+#define rtems_libio_check_permissions(_iop, _flag) \
+ do { \
+ if (((_iop)->flags & (_flag)) == 0) { \
</font> rtems_set_errno_and_return_minus_one( EINVAL ); \
<font color='#880000'>- return -1; \
- } \
</font><font color='#000088'>+ return -1; \
+ } \
</font> } while (0)
/*
<font color='#997700'>@@ -150,44 +155,6 @@
</font> (*(_node)->ops->freenod_h)( (_node) ); \
} while (0)
<font color='#880000'>-/*
- * rtems_filesystem_is_separator
- *
- * Macro to determine if a character is a path name separator.
- *
- * NOTE: This macro handles MS-DOS and UNIX style names.
- */
-
-#define rtems_filesystem_is_separator( _ch ) \
- ( ((_ch) == '/') || ((_ch) == '\\') || ((_ch) == '\0'))
-
-/*
- * rtems_filesystem_get_start_loc
- *
- * Macro to determine if path is absolute or relative.
- */
-
-#define rtems_filesystem_get_start_loc( _path, _index, _loc ) \
- do { \
- if ( rtems_filesystem_is_separator( (_path)[ 0 ] ) ) { \
- *(_loc) = rtems_filesystem_root; \
- *(_index) = 1; \
- } else { \
- *(_loc) = rtems_filesystem_current; \
- *(_index) = 0; \
- } \
- } while (0)
-
-#define rtems_filesystem_get_sym_start_loc( _path, _index, _loc ) \
- do { \
- if ( rtems_filesystem_is_separator( (_path)[ 0 ] ) ) { \
- *(_loc) = rtems_filesystem_root; \
- *(_index) = 1; \
- } else { \
- *(_index) = 0; \
- } \
- } while (0)
-
</font>
/*
* External structures
<font color='#997700'>@@ -271,6 +238,18 @@
</font>
void rtems_filesystem_initialize(void);
<font color='#000088'>+int init_fs_mount_table(void);
+
+int rtems_filesystem_is_separator(char ch);
+
+void rtems_filesystem_get_start_loc(const char *path,
+ int *index,
+ rtems_filesystem_location_info_t *loc);
+
+void rtems_filesystem_get_sym_start_loc(const char *path,
+ int *index,
+ rtems_filesystem_location_info_t *loc);
+
</font> #ifdef __cplusplus
}
#endif
<font color='#006600'>diff -u rtems/cpukit/libcsupport/src/mount-mgr.c:1.2 rtems/cpukit/libcsupport/src/mount-mgr.c:1.2.2.1
--- rtems/cpukit/libcsupport/src/mount-mgr.c:1.2 Tue Jun 1 05:42:52 2010
+++ rtems/cpukit/libcsupport/src/mount-mgr.c Thu Jul 1 09:10:51 2010
</font><font color='#997700'>@@ -6,6 +6,8 @@
</font> *
* COPYRIGHT (c) Chris Johns <chrisj@rtems.org> 2010.
*
<font color='#000088'>+ * Copyright (c) 2010 embedded brains GmbH.
+ *
</font> * 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.
<font color='#997700'>@@ -30,158 +32,139 @@
</font>
#include <rtems/libio_.h>
<font color='#880000'>-/*
- * External defined by confdefs.h or the user.
- */
-extern const rtems_filesystem_table_t configuration_filesystem_table[];
</font><font color='#000088'>+typedef struct {
+ rtems_chain_node node;
+ rtems_filesystem_table_t entry;
+} filesystem_node;
</font>
<font color='#880000'>-/*
- * Points to a list of filesystems added at runtime.
- */
-extern rtems_chain_control *rtems_filesystem_table;
-
-/*
- * Mount table list.
- */
-extern rtems_chain_control rtems_filesystem_mount_table_control;
-extern bool rtems_filesystem_mount_table_control_init;
</font><font color='#000088'>+RTEMS_CHAIN_DEFINE_EMPTY(filesystem_chain);
</font>
<font color='#880000'>-/*
- * Get the first entry in the filesystem table.
- */
-const rtems_filesystem_table_t*
-rtems_filesystem_table_first(
- void
</font><font color='#000088'>+void
+rtems_filesystem_iterate(
+ rtems_per_filesystem_routine routine,
+ void *routine_arg
</font> )
{
<font color='#880000'>- /*
- * We can assume this because it is the root file system.
- */
- return &configuration_filesystem_table[0];
-}
</font><font color='#000088'>+ const rtems_filesystem_table_t *table_entry = &rtems_filesystem_table [0];
+ rtems_chain_node *node = NULL;
</font>
<font color='#880000'>-/*
- * Get the next entry in the file system table.
- */
-const rtems_filesystem_table_t*
-rtems_filesystem_table_next(
- const rtems_filesystem_table_t *entry
-)
-{
- const rtems_filesystem_table_t* fs;
</font><font color='#000088'>+ while ( table_entry->type ) {
+ if ( !(*routine)( table_entry, routine_arg ) ) {
+ break;
+ }
+
+ ++table_entry;
+ }
</font>
<font color='#880000'>- fs = rtems_filesystem_table_first( );
-<span style="background-color: #FF0000"> </span>
- while ( fs->type && ( fs != entry ) )
- ++fs;
-<span style="background-color: #FF0000"> </span>
- if ( fs->type ) {
- ++fs;
- if ( fs->type )
- return fs;
- }
-
- if ( rtems_filesystem_table ) {
- rtems_chain_node* node;
- for (node = rtems_chain_first( rtems_filesystem_table );
- !rtems_chain_is_tail( rtems_filesystem_table, node);
- node = rtems_chain_next( node )) {
- rtems_filesystem_table_node_t* tnode;
- tnode = (rtems_filesystem_table_node_t*) node;
- if ( entry == &tnode->entry ) {
- node = rtems_chain_next( node );
- if ( !rtems_chain_is_tail( rtems_filesystem_table, node ) ) {
- tnode = (rtems_filesystem_table_node_t*) node;
- return &tnode->entry;
- }
- }
</font><font color='#000088'>+ 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 ( !(*routine)( &fsn->entry, routine_arg ) ) {
+ break;
</font> }
}
<font color='#880000'>-<span style="background-color: #FF0000"> </span>
- return NULL;
</font><font color='#000088'>+ rtems_libio_unlock();
</font> }
<font color='#880000'>-/*
- * Get the first entry in the mount table.
- */
-rtems_filesystem_mount_table_entry_t*
-rtems_filesystem_mounts_first(
- void
-)
</font><font color='#000088'>+typedef struct {
+ const char *type;
+ rtems_filesystem_fsmount_me_t mount_h;
+} find_arg;
+
+static bool find_handler(const rtems_filesystem_table_t *entry, void *arg)
</font> {
<font color='#880000'>- rtems_filesystem_mount_table_entry_t* entry = NULL;
- if ( rtems_filesystem_mount_table_control_init ) {
- 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 );
</font><font color='#000088'>+ find_arg *fa = arg;
+
+ if ( strcmp( entry->type, fa->type ) != 0 ) {
+ return true;
+ } else {
+ fa->mount_h = entry->mount_h;
+
+ return true;
</font> }
<font color='#880000'>- return entry;
</font> }
<font color='#880000'>-/*
- * 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
</font><font color='#000088'>+rtems_filesystem_fsmount_me_t
+rtems_filesystem_get_mount_handler(
+ const char *type
</font> )
{
<font color='#880000'>- if ( !rtems_filesystem_mount_table_control_init || !entry )
- return NULL;
- return (rtems_filesystem_mount_table_entry_t*) rtems_chain_next( &entry->Node );
</font><font color='#000088'>+ find_arg fa = {
+ .type = type,
+ .mount_h = NULL
+ };
+
+ if ( type != NULL ) {
+ rtems_filesystem_iterate( find_handler, &fa );
+ }
+
+ return fa.mount_h;
</font> }
<font color='#880000'>-/*
- * Register a file system.
- */
</font> int
rtems_filesystem_register(
const char *type,
rtems_filesystem_fsmount_me_t mount_h
)
{
<font color='#880000'>- rtems_filesystem_table_node_t *fs;
- if ( !rtems_filesystem_table ) {
- rtems_filesystem_table = malloc( sizeof( rtems_chain_control ) );
- if ( !rtems_filesystem_table )
- rtems_set_errno_and_return_minus_one( ENOMEM );
- rtems_chain_initialize_empty ( rtems_filesystem_table );
- }
- fs = malloc( sizeof( rtems_filesystem_table_node_t ) );
- if ( !fs )
- rtems_set_errno_and_return_minus_one( ENOMEM );
- fs->entry.type = strdup( type );
- if ( !fs->entry.type ) {
- free( fs );
</font><font color='#000088'>+ size_t fsn_size = sizeof( filesystem_node ) + strlen(type) + 1;
+ filesystem_node *fsn = malloc( fsn_size );
+ char *type_storage = (char *) fsn + sizeof( filesystem_node );
+
+ if ( fsn == NULL )
</font> rtems_set_errno_and_return_minus_one( ENOMEM );
<font color='#880000'>- }<span style="background-color: #FF0000"> </span>
- fs->entry.mount_h = mount_h;
- rtems_chain_append( rtems_filesystem_table, &fs->node );
</font><font color='#000088'>+
+ strcpy(type_storage, type);
+ fsn->entry.type = type_storage;
+ fsn->entry.mount_h = mount_h;
+
+ rtems_libio_lock();
+ if ( rtems_filesystem_get_mount_handler( type ) == NULL ) {
+ rtems_chain_append( &filesystem_chain, &fsn->node );
+ } else {
+ rtems_libio_unlock();
+ free( fsn );
+
+ rtems_set_errno_and_return_minus_one( EINVAL );
+ }
+ rtems_libio_unlock();
+
</font> return 0;
}
<font color='#880000'>-/*
- * Unregister a file system.
- */
</font> int
rtems_filesystem_unregister(
const char *type
)
{
<font color='#880000'>- if ( rtems_filesystem_table ) {
- rtems_chain_node *node;
- for (node = rtems_chain_first( rtems_filesystem_table );
- !rtems_chain_is_tail( rtems_filesystem_table, node );
- node = rtems_chain_next( node ) ) {
- rtems_filesystem_table_node_t *fs;
- fs = (rtems_filesystem_table_node_t*) node;
- if ( strcmp( fs->entry.type, type ) == 0 ) {
- rtems_chain_extract( node );
- free( (void*) fs->entry.type );
- free( fs );
- return 0;
- }
</font><font color='#000088'>+ rtems_chain_node *node = NULL;
+
+ if ( type == NULL ) {
+ rtems_set_errno_and_return_minus_one( EINVAL );
+ }
+
+ rtems_libio_lock();
+ for (
+ node = rtems_chain_first( &filesystem_chain );
+ !rtems_chain_is_tail( &filesystem_chain, node );
+ node = rtems_chain_next( node )
+ ) {
+ filesystem_node *fsn = (filesystem_node *) node;
+
+ if ( strcmp( fsn->entry.type, type ) == 0 ) {
+ rtems_chain_extract( node );
+ free( fsn );
+ rtems_libio_unlock();
+
+ return 0;
</font> }
}
<font color='#000088'>+ rtems_libio_unlock();
+
</font> rtems_set_errno_and_return_minus_one( ENOENT );
}
<font color='#006600'>diff -u rtems/cpukit/libcsupport/src/mount.c:1.33 rtems/cpukit/libcsupport/src/mount.c:1.33.2.1
--- rtems/cpukit/libcsupport/src/mount.c:1.33 Mon May 31 08:56:36 2010
+++ rtems/cpukit/libcsupport/src/mount.c Thu Jul 1 09:10:52 2010
</font><font color='#997700'>@@ -10,6 +10,8 @@
</font> * COPYRIGHT (c) 1989-1999.
* On-Line Applications Research Corporation (OAR).
*
<font color='#000088'>+ * Copyright (c) 2010 embedded brains GmbH.
+ *
</font> * 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.
<font color='#997700'>@@ -24,6 +26,7 @@
</font> #include <sys/types.h>
#include <sys/stat.h>
#include <rtems/chain.h>
<font color='#000088'>+#include <rtems/seterr.h>
</font> #include <fcntl.h>
#include <unistd.h>
#include <errno.h>
<font color='#997700'>@@ -34,20 +37,9 @@
</font> #include <rtems/libio_.h>
/*
<font color='#880000'>- * External defined by confdefs.h or the user.
- */
-extern const rtems_filesystem_table_t configuration_filesystem_table[];
-
-/*
- * Points to a list of filesystems added at runtime.
- */
-rtems_chain_control *rtems_filesystem_table;
-
-/*
</font> * Mount table list.
*/
<font color='#880000'>-rtems_chain_control rtems_filesystem_mount_table_control;
-bool rtems_filesystem_mount_table_control_init;
</font><font color='#000088'>+RTEMS_CHAIN_DEFINE_EMPTY(rtems_filesystem_mount_table_control);
</font>
/*
* Default pathconfs.
<font color='#997700'>@@ -79,27 +71,64 @@
</font> */
static bool Is_node_fs_root(
<font color='#880000'>- rtems_filesystem_location_info_t *loc
</font><font color='#000088'>+ rtems_filesystem_location_info_t *loc
</font> )
{
<font color='#880000'>- rtems_chain_node *the_node;
- rtems_filesystem_mount_table_entry_t *the_mount_entry;
</font><font color='#000088'>+ rtems_chain_node *node = NULL;
</font>
/*
* For each mount table entry
*/
<font color='#880000'>- if ( rtems_filesystem_mount_table_control_init ) {
- for ( the_node = rtems_chain_first( &rtems_filesystem_mount_table_control );
- !rtems_chain_is_tail( &rtems_filesystem_mount_table_control, the_node );
- the_node = rtems_chain_next( the_node ) ) {
- the_mount_entry = (rtems_filesystem_mount_table_entry_t *) the_node;
- if ( the_mount_entry->mt_fs_root.node_access == loc->node_access )
- return true;
- }
</font><font color='#000088'>+ 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;
</font> }
<font color='#000088'>+
</font> return false;
}
<font color='#000088'>+static rtems_filesystem_mount_table_entry_t *alloc_mount_table_entry(
+ const char *source,
+ const char *target,
+ const char *filesystemtype,
+ size_t *target_length_ptr
+)
+{
+ const char *target_str = target ? target : "/";
+ 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 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 ) {
+ char *str = (char *) mt_entry + sizeof( *mt_entry );
+
+ mt_entry->type = str;
+ strcpy( str, filesystemtype );
+
+ if ( source ) {
+ str += filesystemtype_size;
+ mt_entry->dev = str;
+ strcpy( str, source );
+ }
+
+ str += source_size;
+ mt_entry->target = str;
+ strcpy( str, target );
+ }
+
+ *target_length_ptr = target_length;
+
+ return mt_entry;
+}
+
</font> /*
* mount
*
<font color='#997700'>@@ -121,114 +150,54 @@
</font> const char *filesystemtype,
rtems_filesystem_options_t options,
const void *data
<font color='#880000'>- )
</font><font color='#000088'>+)
</font> {
<font color='#880000'>- const rtems_filesystem_table_t *entry;
</font><font color='#000088'>+ rtems_filesystem_fsmount_me_t mount_h = NULL;
</font> rtems_filesystem_location_info_t loc;
rtems_filesystem_mount_table_entry_t *mt_entry = NULL;
rtems_filesystem_location_info_t *loc_to_free = NULL;
<font color='#880000'>- size_t size;
-
- /*
- * If mount is ever called we allocate the mount table control structure.
- */
- if ( !rtems_filesystem_mount_table_control_init ) {
- rtems_filesystem_mount_table_control_init = true;
- rtems_chain_initialize_empty ( &rtems_filesystem_mount_table_control );
- }
</font><font color='#000088'>+ bool has_target = target != NULL;
+ size_t target_length = 0;
</font>
/*
* Are the file system options valid?
*/
if ( options != RTEMS_FILESYSTEM_READ_ONLY &&
<font color='#880000'>- options != RTEMS_FILESYSTEM_READ_WRITE ) {
- errno = EINVAL;
- return -1;
- }
-
- /*
- * Check the type.
- */
- if (!filesystemtype) {
- errno = EINVAL;
- return -1;
- }
</font><font color='#000088'>+ options != RTEMS_FILESYSTEM_READ_WRITE )
+ rtems_set_errno_and_return_minus_one( EINVAL );
</font>
<font color='#880000'>- if (strlen(filesystemtype) >= 128) {
- errno = EINVAL;
- return -1;
- }
-<span style="background-color: #FF0000"> </span>
</font> /*
<font color='#880000'>- * Check the configuration table filesystems then check any runtime added
- * file systems.
</font><font color='#000088'>+ * Get mount handler
</font> */
<font color='#880000'>- entry = &configuration_filesystem_table[0];
- while (entry->type) {
- if (strcmp (filesystemtype, entry->type) == 0)
- break;
- ++entry;
- }
-<span style="background-color: #FF0000"> </span>
- if (!entry->type) {
- entry = NULL;
- if (rtems_filesystem_table) {
- rtems_chain_node *the_node;
- for (the_node = rtems_chain_first(rtems_filesystem_table);
- !rtems_chain_is_tail(rtems_filesystem_table, the_node);
- the_node = rtems_chain_next(the_node)) {
- entry = &(((rtems_filesystem_table_node_t*) the_node)->entry);
- if (strcmp (filesystemtype, entry->type) == 0)
- break;
- entry = NULL;
- }
- }
- }
</font><font color='#000088'>+ mount_h = rtems_filesystem_get_mount_handler( filesystemtype );
+ if ( !mount_h )
+ rtems_set_errno_and_return_minus_one( EINVAL );
</font>
<font color='#880000'>- if (!entry)
- {
- errno = EINVAL;
- return -1;
- }
-<span style="background-color: #FF0000"> </span>
</font> /*
* Allocate a mount table entry
*/
<font color='#000088'>+ mt_entry = alloc_mount_table_entry(
+ source,
+ target,
+ filesystemtype,
+ &target_length
+ );
+ if ( !mt_entry )
+ rtems_set_errno_and_return_minus_one( ENOMEM );
</font>
<font color='#880000'>- size = sizeof(rtems_filesystem_mount_table_entry_t);
- if ( source )
- size += strlen( source ) + 1;
-<span style="background-color: #FF0000"> </span>
- mt_entry = malloc( size );
- if ( !mt_entry ) {
- errno = ENOMEM;
- return -1;
- }
-
- memset( mt_entry, 0, size );
-<span style="background-color: #FF0000"> </span>
</font> mt_entry->mt_fs_root.mt_entry = mt_entry;
<font color='#880000'>- mt_entry->type = entry->type;
</font> mt_entry->options = options;
mt_entry->pathconf_limits_and_options = rtems_filesystem_default_pathconf;
<font color='#880000'>-<span style="background-color: #FF0000"> </span>
- if ( source ) {
- mt_entry->dev =
- (char *)mt_entry + sizeof( rtems_filesystem_mount_table_entry_t );
- strcpy( mt_entry->dev, source );
- } else
- mt_entry->dev = 0;
</font>
/*
* The mount_point should be a directory with read/write/execute
* permissions in the existing tree.
*/
<font color='#880000'>- if ( target ) {
-
</font><font color='#000088'>+ if ( has_target ) {
</font> if ( rtems_filesystem_evaluate_path(
<font color='#880000'>- target, strlen( target ), RTEMS_LIBIO_PERMS_RWX, &loc, true ) == -1 )
</font><font color='#000088'>+ target, target_length, RTEMS_LIBIO_PERMS_RWX, &loc, true ) == -1 )
</font> goto cleanup_and_bail;
loc_to_free = &loc;
<font color='#997700'>@@ -272,7 +241,7 @@
</font> mt_entry->mt_point_node.handlers = loc.handlers;
mt_entry->mt_point_node.ops = loc.ops;
mt_entry->mt_point_node.mt_entry = loc.mt_entry;
<font color='#880000'>-<span style="background-color: #FF0000"> </span>
</font><font color='#000088'>+
</font> /*
* This link to the parent is only done when we are dealing with system
* below the base file system
<font color='#997700'>@@ -286,10 +255,7 @@
</font> if ( loc.ops->mount_h( mt_entry ) ) {
goto cleanup_and_bail;
}
<font color='#880000'>-
- mt_entry->target = strdup( target );
</font> } else {
<font color='#880000'>-
</font> /*
* Do we already have a base file system ?
*/
<font color='#997700'>@@ -297,26 +263,15 @@
</font> errno = EINVAL;
goto cleanup_and_bail;
}
<font color='#880000'>-<span style="background-color: #FF0000"> </span>
</font><font color='#000088'>+
</font> /*
* This is a mount of the base file system --> The
<font color='#880000'>- * mt_point_node.node_access will be set to null to indicate that this
</font><font color='#000088'>+ * mt_point_node.node_access will be left to null to indicate that this
</font> * is the root of the entire file system.
*/
<font color='#880000'>-
- mt_entry->mt_fs_root.node_access = NULL;
- mt_entry->mt_fs_root.handlers = NULL;
- mt_entry->mt_fs_root.ops = NULL;
-
- mt_entry->mt_point_node.node_access = NULL;
- mt_entry->mt_point_node.handlers = NULL;
- mt_entry->mt_point_node.ops = NULL;
- mt_entry->mt_point_node.mt_entry = NULL;
-
- mt_entry->target = "/";
</font> }
<font color='#880000'>- if ( entry->mount_h( mt_entry, data ) ) {
</font><font color='#000088'>+ if ( (*mount_h)( mt_entry, data ) ) {
</font> /*
* Try to undo the mount operation
*/
<font color='#997700'>@@ -332,14 +287,13 @@
</font> rtems_chain_append( &rtems_filesystem_mount_table_control,
&mt_entry->Node );
<font color='#880000'>- if ( !target )
</font><font color='#000088'>+ if ( !has_target )
</font> rtems_filesystem_root = mt_entry->mt_fs_root;
return 0;
cleanup_and_bail:
<font color='#880000'>- free( (void*) mt_entry->target );
</font> free( mt_entry );
if ( loc_to_free )
<font color='#997700'>@@ -348,3 +302,33 @@
</font> return -1;
}
<font color='#000088'>+/*
+ * Get the first entry in the mount table.
+ */
+rtems_filesystem_mount_table_entry_t *
+rtems_filesystem_mounts_first(
+ void
+)
+{
+ 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 );
+
+ return entry;
+}
+
+/*
+ * 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 );
+}
</font>
<font color='#006600'>diff -u /dev/null rtems/cpukit/libcsupport/src/sup_fs_get_start_loc.c:1.1.2.2
--- /dev/null Thu Jul 1 09:18:31 2010
+++ rtems/cpukit/libcsupport/src/sup_fs_get_start_loc.c Thu Jul 1 09:10:52 2010
</font><font color='#997700'>@@ -0,0 +1,48 @@
</font><font color='#000088'>+ /**
+ * @file src/sup_fs_get_start_loc.c
+ */
+
+/*
+ *
+ * COPYRIGHT (c) 1989-1999.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * 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.
+ *
+ * $Id$
+ */
+
+/*
+ * rtems_filesystem_get_start_loc
+ *
+ * Function to determine if path is absolute or relative
+ *
+ * Parameters:
+ *
+ * path : IN - path to be checked
+ * index: OUT - 0, if relative, 1 if absolute
+ * loc : OUT - location info of root fs if absolute
+ * location info of current fs if relative
+ *
+ * Returns: void
+ */
+
+/* Includes */
+
+#include "rtems/libio_.h"
+
+void rtems_filesystem_get_start_loc(const char *path,
+ int *index,
+ rtems_filesystem_location_info_t *loc)
+{
+ if (rtems_filesystem_is_separator(path[0])) {
+ *loc = rtems_filesystem_root;
+ *index = 1;
+ }
+ else {
+ *loc = rtems_filesystem_current;
+ *index = 0;
+ }
+}
</font>
<font color='#006600'>diff -u /dev/null rtems/cpukit/libcsupport/src/sup_fs_get_sym_start_loc.c:1.1.2.2
--- /dev/null Thu Jul 1 09:18:31 2010
+++ rtems/cpukit/libcsupport/src/sup_fs_get_sym_start_loc.c Thu Jul 1 09:10:52 2010
</font><font color='#997700'>@@ -0,0 +1,47 @@
</font><font color='#000088'>+ /**
+ * @file src/sup_fs_get_sym_start_loc.c
+ */
+
+/*
+ *
+ * COPYRIGHT (c) 1989-1999.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * 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.
+ *
+ * $Id$
+ */
+
+/*
+ * rtems_filesystem_get_sym_start_loc
+ *
+ * Function to determine if path is absolute or relative
+ *
+ * Parameters:
+ *
+ * path : IN - path to be checked
+ * index: OUT - 0, if relative, 1 if absolute
+ * loc : OUT - location info of root fs if absolute
+ * location info of current fs if relative
+ *
+ * Returns: void
+ */
+
+/* Includes */
+
+#include "rtems/libio_.h"
+<span style="background-color: #FF0000"> </span>
+void rtems_filesystem_get_sym_start_loc(const char *path,
+ int *index,
+ rtems_filesystem_location_info_t *loc)
+{
+ if (rtems_filesystem_is_separator(path[0])) {
+ *loc = rtems_filesystem_root;
+ *index = 1;
+ }
+ else {
+ *index = 0;
+ }
+}
</font>
<font color='#006600'>diff -u /dev/null rtems/cpukit/libcsupport/src/sup_fs_is_separator.c:1.1.2.2
--- /dev/null Thu Jul 1 09:18:32 2010
+++ rtems/cpukit/libcsupport/src/sup_fs_is_separator.c Thu Jul 1 09:10:53 2010
</font><font color='#997700'>@@ -0,0 +1,30 @@
</font><font color='#000088'>+/**
+ * @file src/sup_fs_is_separator.c
+ */
+
+/*
+ *
+ * COPYRIGHT (c) 1989-1999.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * 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.
+ *
+ * $Id$
+ */
+
+
+/*
+ * rtems_filesystem_is_separator
+ *
+ * Function to determine if a character is a path name separator.
+ * This was originally a macro in libio_.h
+ *
+ * NOTE: This function handles MS-DOS and UNIX style names.
+ */
+
+int rtems_filesystem_is_separator(char ch)
+{
+ return ((ch == '/') || (ch == '\\') || (ch == '\0'));
+}
</font>
<font color='#006600'>diff -u rtems/cpukit/libmisc/shell/main_mount.c:1.8 rtems/cpukit/libmisc/shell/main_mount.c:1.8.2.1
--- rtems/cpukit/libmisc/shell/main_mount.c:1.8 Mon May 31 08:56:37 2010
+++ rtems/cpukit/libmisc/shell/main_mount.c Thu Jul 1 09:10:53 2010
</font><font color='#997700'>@@ -27,6 +27,13 @@
</font> #include <rtems/libio.h>
#include "internal.h"
<font color='#000088'>+static bool print_filesystem(const rtems_filesystem_table_t *entry, void *arg)
+{
+ printf("%s ", entry->type);
+
+ return true;
+}
+
</font> int rtems_shell_main_mount(
int argc,
char *argv[]
<font color='#997700'>@@ -55,13 +62,8 @@
</font> } else if (argv[arg][1] == 'r') {
options = RTEMS_FILESYSTEM_READ_ONLY;
} else if (argv[arg][1] == 'L') {
<font color='#880000'>- const rtems_filesystem_table_t* fs;
- fs = rtems_filesystem_table_first();
</font> printf ("File systems: ");
<font color='#880000'>- while (fs) {
- printf ("%s ", fs->type);
- fs = rtems_filesystem_table_next(fs);
- }
</font><font color='#000088'>+ rtems_filesystem_iterate(print_filesystem, NULL);
</font> printf ("\n");
return 0;
} else if (argv[arg][1] == 'o') {
<font color='#006600'>diff -u rtems/cpukit/sapi/include/confdefs.h:1.135.2.2 rtems/cpukit/sapi/include/confdefs.h:1.135.2.3
--- rtems/cpukit/sapi/include/confdefs.h:1.135.2.2 Mon Jun 21 16:13:30 2010
+++ rtems/cpukit/sapi/include/confdefs.h Thu Jul 1 09:10:54 2010
</font><font color='#997700'>@@ -384,12 +384,9 @@
</font> /**
* The default file system table. Must be terminated with the NULL entry if
* you provide your own.
<font color='#880000'>- *
- * The extern is needed to stop the table being removed by the optimizer.
</font> */
<font color='#880000'>- extern const rtems_filesystem_table_t configuration_filesystem_table[];
</font> #ifndef CONFIGURE_HAS_OWN_FILESYSTEM_TABLE
<font color='#880000'>- const rtems_filesystem_table_t configuration_filesystem_table[] = {
</font><font color='#000088'>+ const rtems_filesystem_table_t rtems_filesystem_table[] = {
</font> #if defined(CONFIGURE_FILESYSTEM_miniIMFS) && \
defined(CONFIGURE_FILESYSTEM_ENTRY_miniIMFS)
CONFIGURE_FILESYSTEM_ENTRY_miniIMFS,
</pre>
<p> </p>
<p>--<br />
<small>Generated by <a href="http://www.codewiz.org/projects/index.html#loginfo">Deluxe Loginfo</a> 2.122 by Bernardo Innocenti <bernie@develer.com></small></p>
</body>
</html>