summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-01-28 18:25:49 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-01-28 18:25:49 +0100
commit29fa2419bfff57811453b081d0ac771e9158e469 (patch)
tree4451541dfb3b297019fdd85ce649f167a2b43136
parentcf36b70e8dd8755e7dac6eb516169f586e78566d (diff)
downloadrtems-29fa2419bfff57811453b081d0ac771e9158e469.tar.bz2
IMFS: Aggregate link support in dedicated modules
-rw-r--r--cpukit/libfs/Makefile.am4
-rw-r--r--cpukit/libfs/src/imfs/imfs_handlers_link.c137
-rw-r--r--cpukit/libfs/src/imfs/imfs_link.c74
-rw-r--r--cpukit/libfs/src/imfs/imfs_readlink.c38
-rw-r--r--cpukit/libfs/src/imfs/imfs_symlink.c76
5 files changed, 152 insertions, 177 deletions
diff --git a/cpukit/libfs/Makefile.am b/cpukit/libfs/Makefile.am
index 6427d693f5..a5af577f94 100644
--- a/cpukit/libfs/Makefile.am
+++ b/cpukit/libfs/Makefile.am
@@ -48,11 +48,11 @@ libimfs_a_SOURCES += src/imfs/deviceio.c \
src/imfs/imfs_make_generic_node.c \
src/imfs/imfs_fsunmount.c \
src/imfs/imfs_handlers_device.c \
- src/imfs/imfs_handlers_directory.c src/imfs/imfs_handlers_link.c \
+ src/imfs/imfs_handlers_directory.c \
src/imfs/imfs_handlers_memfile.c src/imfs/imfs_init.c \
src/imfs/imfs_initsupp.c src/imfs/imfs_link.c src/imfs/imfs_load_tar.c \
src/imfs/imfs_mknod.c src/imfs/imfs_mount.c \
- src/imfs/imfs_readlink.c src/imfs/imfs_rename.c src/imfs/imfs_rmnod.c \
+ src/imfs/imfs_rename.c src/imfs/imfs_rmnod.c \
src/imfs/imfs_stat.c src/imfs/imfs_symlink.c \
src/imfs/imfs_unmount.c src/imfs/imfs_utime.c src/imfs/ioman.c \
src/imfs/memfile.c src/imfs/miniimfs_init.c src/imfs/imfs.h
diff --git a/cpukit/libfs/src/imfs/imfs_handlers_link.c b/cpukit/libfs/src/imfs/imfs_handlers_link.c
deleted file mode 100644
index 25848bea93..0000000000
--- a/cpukit/libfs/src/imfs/imfs_handlers_link.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- * @file
- *
- * @brief Link Operations Table for the IMFS
- * @ingroup IMFS
- */
-
-/*
- * 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.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
- #include "config.h"
-#endif
-
-#include "imfs.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-static int IMFS_stat_link(
- const rtems_filesystem_location_info_t *loc,
- struct stat *buf
-)
-{
- const IMFS_jnode_t *node = loc->node_access;
-
- if ( !IMFS_is_hard_link( node->st_mode ) ) {
- const IMFS_sym_link_t *sym_link = (const IMFS_sym_link_t *) node;
-
- buf->st_size = strlen( sym_link->name );
-
- return IMFS_stat( loc, buf );
- } else {
- const IMFS_link_t *hard_link = (const IMFS_link_t *) node;
- rtems_filesystem_location_info_t targetloc = *loc;
-
- targetloc.node_access = hard_link->link_node;
- IMFS_Set_handlers( &targetloc );
-
- return (targetloc.handlers->fstat_h)( &targetloc, buf );
- }
-}
-
-static const rtems_filesystem_file_handlers_r IMFS_link_handlers = {
- .open_h = rtems_filesystem_default_open,
- .close_h = rtems_filesystem_default_close,
- .read_h = rtems_filesystem_default_read,
- .write_h = rtems_filesystem_default_write,
- .ioctl_h = rtems_filesystem_default_ioctl,
- .lseek_h = rtems_filesystem_default_lseek,
- .fstat_h = IMFS_stat_link,
- .ftruncate_h = rtems_filesystem_default_ftruncate,
- .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
- .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
- .fcntl_h = rtems_filesystem_default_fcntl,
- .kqfilter_h = rtems_filesystem_default_kqfilter,
- .poll_h = rtems_filesystem_default_poll,
- .readv_h = rtems_filesystem_default_readv,
- .writev_h = rtems_filesystem_default_writev
-};
-
-static IMFS_jnode_t *IMFS_node_initialize_hard_link(
- IMFS_jnode_t *node,
- void *arg
-)
-{
- IMFS_link_t *hard_link = (IMFS_link_t *) node;
-
- hard_link->link_node = arg;
-
- return node;
-}
-
-static IMFS_jnode_t *IMFS_node_remove_hard_link(
- IMFS_jnode_t *node
-)
-{
- IMFS_link_t *hard_link = (IMFS_link_t *) node;
- IMFS_jnode_t *target = hard_link->link_node;
-
- _Assert( target != NULL );
-
- if ( target->st_nlink == 1) {
- target = (*target->control->node_remove)( target );
- if ( target == NULL ) {
- node = NULL;
- }
- } else {
- --target->st_nlink;
- IMFS_update_ctime( target );
- }
-
- return node;
-}
-
-const IMFS_node_control IMFS_node_control_hard_link = {
- .handlers = &IMFS_link_handlers,
- .node_size = sizeof(IMFS_link_t),
- .node_initialize = IMFS_node_initialize_hard_link,
- .node_remove = IMFS_node_remove_hard_link,
- .node_destroy = IMFS_node_destroy_default
-};
-
-static IMFS_jnode_t *IMFS_node_initialize_sym_link(
- IMFS_jnode_t *node,
- void *arg
-)
-{
- IMFS_sym_link_t *sym_link = (IMFS_sym_link_t *) node;
-
- sym_link->name = arg;
-
- return node;
-}
-
-static void IMFS_node_destroy_sym_link( IMFS_jnode_t *node )
-{
- IMFS_sym_link_t *sym_link = (IMFS_sym_link_t *) node;
-
- free( sym_link->name );
-
- IMFS_node_destroy_default( node );
-}
-
-const IMFS_node_control IMFS_node_control_sym_link = {
- .handlers = &IMFS_link_handlers,
- .node_size = sizeof(IMFS_sym_link_t),
- .node_initialize = IMFS_node_initialize_sym_link,
- .node_remove = IMFS_node_remove_default,
- .node_destroy = IMFS_node_destroy_sym_link
-};
diff --git a/cpukit/libfs/src/imfs/imfs_link.c b/cpukit/libfs/src/imfs/imfs_link.c
index 61b9f43e96..9e25f044c4 100644
--- a/cpukit/libfs/src/imfs/imfs_link.c
+++ b/cpukit/libfs/src/imfs/imfs_link.c
@@ -62,3 +62,77 @@ int IMFS_link(
return 0;
}
+
+static int IMFS_stat_hard_link(
+ const rtems_filesystem_location_info_t *loc,
+ struct stat *buf
+)
+{
+ const IMFS_link_t *hard_link = loc->node_access;
+ rtems_filesystem_location_info_t targetloc = *loc;
+
+ targetloc.node_access = hard_link->link_node;
+ IMFS_Set_handlers( &targetloc );
+
+ return (targetloc.handlers->fstat_h)( &targetloc, buf );
+}
+
+static const rtems_filesystem_file_handlers_r IMFS_link_handlers = {
+ .open_h = rtems_filesystem_default_open,
+ .close_h = rtems_filesystem_default_close,
+ .read_h = rtems_filesystem_default_read,
+ .write_h = rtems_filesystem_default_write,
+ .ioctl_h = rtems_filesystem_default_ioctl,
+ .lseek_h = rtems_filesystem_default_lseek,
+ .fstat_h = IMFS_stat_hard_link,
+ .ftruncate_h = rtems_filesystem_default_ftruncate,
+ .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
+ .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
+ .fcntl_h = rtems_filesystem_default_fcntl,
+ .kqfilter_h = rtems_filesystem_default_kqfilter,
+ .poll_h = rtems_filesystem_default_poll,
+ .readv_h = rtems_filesystem_default_readv,
+ .writev_h = rtems_filesystem_default_writev
+};
+
+static IMFS_jnode_t *IMFS_node_initialize_hard_link(
+ IMFS_jnode_t *node,
+ void *arg
+)
+{
+ IMFS_link_t *hard_link = (IMFS_link_t *) node;
+
+ hard_link->link_node = arg;
+
+ return node;
+}
+
+static IMFS_jnode_t *IMFS_node_remove_hard_link(
+ IMFS_jnode_t *node
+)
+{
+ IMFS_link_t *hard_link = (IMFS_link_t *) node;
+ IMFS_jnode_t *target = hard_link->link_node;
+
+ _Assert( target != NULL );
+
+ if ( target->st_nlink == 1) {
+ target = (*target->control->node_remove)( target );
+ if ( target == NULL ) {
+ node = NULL;
+ }
+ } else {
+ --target->st_nlink;
+ IMFS_update_ctime( target );
+ }
+
+ return node;
+}
+
+const IMFS_node_control IMFS_node_control_hard_link = {
+ .handlers = &IMFS_link_handlers,
+ .node_size = sizeof(IMFS_link_t),
+ .node_initialize = IMFS_node_initialize_hard_link,
+ .node_remove = IMFS_node_remove_hard_link,
+ .node_destroy = IMFS_node_destroy_default
+};
diff --git a/cpukit/libfs/src/imfs/imfs_readlink.c b/cpukit/libfs/src/imfs/imfs_readlink.c
deleted file mode 100644
index 2c26954c6a..0000000000
--- a/cpukit/libfs/src/imfs/imfs_readlink.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * @file
- *
- * @brief IMFS Put Symbolic Link into Buffer
- * @ingroup IMFS
- */
-
-/*
- * 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.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
- #include "config.h"
-#endif
-
-#include "imfs.h"
-
-ssize_t IMFS_readlink(
- const rtems_filesystem_location_info_t *loc,
- char *buf,
- size_t bufsize
-)
-{
- IMFS_sym_link_t *sym_link;
- ssize_t i;
-
- sym_link = loc->node_access;
-
- for( i=0; ((i<bufsize) && (sym_link->name[i] != '\0')); i++ )
- buf[i] = sym_link->name[i];
-
- return i;
-}
diff --git a/cpukit/libfs/src/imfs/imfs_symlink.c b/cpukit/libfs/src/imfs/imfs_symlink.c
index 963cefcd77..eaed80b75d 100644
--- a/cpukit/libfs/src/imfs/imfs_symlink.c
+++ b/cpukit/libfs/src/imfs/imfs_symlink.c
@@ -60,3 +60,79 @@ int IMFS_symlink(
return 0;
}
+
+ssize_t IMFS_readlink(
+ const rtems_filesystem_location_info_t *loc,
+ char *buf,
+ size_t bufsize
+)
+{
+ IMFS_sym_link_t *sym_link;
+ ssize_t i;
+
+ sym_link = loc->node_access;
+
+ for( i=0; ((i<bufsize) && (sym_link->name[i] != '\0')); i++ )
+ buf[i] = sym_link->name[i];
+
+ return i;
+}
+
+static int IMFS_stat_sym_link(
+ const rtems_filesystem_location_info_t *loc,
+ struct stat *buf
+)
+{
+ const IMFS_sym_link_t *sym_link = loc->node_access;
+
+ buf->st_size = strlen( sym_link->name );
+
+ return IMFS_stat( loc, buf );
+}
+
+static const rtems_filesystem_file_handlers_r IMFS_link_handlers = {
+ .open_h = rtems_filesystem_default_open,
+ .close_h = rtems_filesystem_default_close,
+ .read_h = rtems_filesystem_default_read,
+ .write_h = rtems_filesystem_default_write,
+ .ioctl_h = rtems_filesystem_default_ioctl,
+ .lseek_h = rtems_filesystem_default_lseek,
+ .fstat_h = IMFS_stat_sym_link,
+ .ftruncate_h = rtems_filesystem_default_ftruncate,
+ .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
+ .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
+ .fcntl_h = rtems_filesystem_default_fcntl,
+ .kqfilter_h = rtems_filesystem_default_kqfilter,
+ .poll_h = rtems_filesystem_default_poll,
+ .readv_h = rtems_filesystem_default_readv,
+ .writev_h = rtems_filesystem_default_writev
+};
+
+static IMFS_jnode_t *IMFS_node_initialize_sym_link(
+ IMFS_jnode_t *node,
+ void *arg
+)
+{
+ IMFS_sym_link_t *sym_link = (IMFS_sym_link_t *) node;
+
+ sym_link->name = arg;
+
+ return node;
+}
+
+static void IMFS_node_destroy_sym_link( IMFS_jnode_t *node )
+{
+ IMFS_sym_link_t *sym_link = (IMFS_sym_link_t *) node;
+
+ free( sym_link->name );
+
+ IMFS_node_destroy_default( node );
+}
+
+const IMFS_node_control IMFS_node_control_sym_link = {
+ .handlers = &IMFS_link_handlers,
+ .node_size = sizeof(IMFS_sym_link_t),
+ .node_initialize = IMFS_node_initialize_sym_link,
+ .node_remove = IMFS_node_remove_default,
+ .node_destroy = IMFS_node_destroy_sym_link
+};