* libfs/src/imfs/fifoimfs_init.c: New file.
	* libfs/Makefile.am: Reflect change above.
	* libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_eval.c,
	libfs/src/imfs/imfs_init.c, libfs/src/imfs/imfs_initsupp.c,
	libfs/src/imfs/miniimfs_init.c, libfs/src/pipe/fifo.c,
	libfs/src/pipe/pipe.c, libfs/src/pipe/pipe.h: Pipe support is now
	link-time optional.
	* sapi/include/confdefs.h: Reflect changes above.
This commit is contained in:
Sebastian Huber
2010-06-08 10:25:46 +00:00
parent 5b5772ae31
commit 241f4c9637
12 changed files with 229 additions and 168 deletions

View File

@@ -1,3 +1,14 @@
2010-06-08 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libfs/src/imfs/fifoimfs_init.c: New file.
* libfs/Makefile.am: Reflect change above.
* libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_eval.c,
libfs/src/imfs/imfs_init.c, libfs/src/imfs/imfs_initsupp.c,
libfs/src/imfs/miniimfs_init.c, libfs/src/pipe/fifo.c,
libfs/src/pipe/pipe.c, libfs/src/pipe/pipe.h: Pipe support is now
link-time optional.
* sapi/include/confdefs.h: Reflect changes above.
2010-06-08 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_rmnod.c: Added and use

View File

@@ -31,7 +31,7 @@ libimfs_a_SOURCES += src/imfs/imfs_chown.c src/imfs/imfs_config.c \
src/imfs/imfs_debug.c src/imfs/imfs_rmnod.c src/imfs/imfs_symlink.c \
src/imfs/imfs_readlink.c src/imfs/imfs_fdatasync.c src/imfs/imfs_fcntl.c \
src/imfs/ioman.c src/imfs/miniimfs_init.c src/imfs/imfs_load_tar.c \
src/imfs/imfs_rename.c src/imfs/imfs.h \
src/imfs/imfs_rename.c src/imfs/fifoimfs_init.c src/imfs/imfs.h \
src/imfs/deviceerrno.c \
src/devfs/devfs_init.c src/devfs/devfs_eval.c src/devfs/devfs_mknod.c \
src/devfs/devfs_show.c src/devfs/devfs_node_type.c \

View File

@@ -0,0 +1,61 @@
/**
* @file
*
* @ingroup LibFSIMFS
*
* @brief IMFS without fifo support initialization.
*/
/*
* 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 "imfs.h"
static const rtems_filesystem_operations_table fifoIMFS_ops = {
.evalpath_h = IMFS_eval_path,
.evalformake_h = IMFS_evaluate_for_make,
.link_h = IMFS_link,
.unlink_h = IMFS_unlink,
.node_type_h = IMFS_node_type,
.mknod_h = IMFS_mknod,
.chown_h = IMFS_chown,
.freenod_h = IMFS_freenodinfo,
.mount_h = IMFS_mount,
.fsmount_me_h = fifoIMFS_initialize,
.unmount_h = IMFS_unmount,
.fsunmount_me_h = IMFS_fsunmount,
.utime_h = IMFS_utime,
.eval_link_h = IMFS_evaluate_link,
.symlink_h = IMFS_symlink,
.readlink_h = IMFS_readlink,
.rename_h = IMFS_rename,
.statvfs_h = NULL
};
int fifoIMFS_initialize(
rtems_filesystem_mount_table_entry_t *mt_entry,
const void *data
)
{
return IMFS_initialize_support(
mt_entry,
&fifoIMFS_ops,
&IMFS_memfile_handlers,
&IMFS_directory_handlers,
&IMFS_fifo_handlers
);
}

View File

@@ -223,6 +223,7 @@ typedef struct {
ino_t ino_count;
const rtems_filesystem_file_handlers_r *memfile_handlers;
const rtems_filesystem_file_handlers_r *directory_handlers;
const rtems_filesystem_file_handlers_r *fifo_handlers;
} IMFS_fs_info_t;
/*
@@ -247,7 +248,6 @@ extern const rtems_filesystem_file_handlers_r IMFS_link_handlers;
extern const rtems_filesystem_file_handlers_r IMFS_memfile_handlers;
extern const rtems_filesystem_file_handlers_r IMFS_fifo_handlers;
extern const rtems_filesystem_operations_table IMFS_ops;
extern const rtems_filesystem_operations_table miniIMFS_ops;
extern const rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS;
/*
@@ -259,6 +259,11 @@ extern int IMFS_initialize(
const void *data
);
extern int fifoIMFS_initialize(
rtems_filesystem_mount_table_entry_t *mt_entry,
const void *data
);
extern int miniIMFS_initialize(
rtems_filesystem_mount_table_entry_t *mt_entry,
const void *data
@@ -268,7 +273,8 @@ extern int IMFS_initialize_support(
rtems_filesystem_mount_table_entry_t *mt_entry,
const rtems_filesystem_operations_table *op_table,
const rtems_filesystem_file_handlers_r *memfile_handlers,
const rtems_filesystem_file_handlers_r *directory_handlers
const rtems_filesystem_file_handlers_r *directory_handlers,
const rtems_filesystem_file_handlers_r *fifo_handlers
);
extern int IMFS_fsunmount(

View File

@@ -58,7 +58,7 @@ int IMFS_Set_handlers(
loc->handlers = fs_info->memfile_handlers;
break;
case IMFS_FIFO:
loc->handlers = &IMFS_fifo_handlers;
loc->handlers = fs_info->fifo_handlers;
break;
}

View File

@@ -1,6 +1,12 @@
/*
* IMFS Initialization
/**
* @file
*
* @ingroup LibFSIMFS
*
* @brief IMFS initialization.
*/
/*
* COPYRIGHT (c) 1989-1999.
* On-Line Applications Research Corporation (OAR).
*
@@ -15,58 +21,41 @@
#include "config.h"
#endif
#include <sys/types.h> /* for mkdir */
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <assert.h>
#include "imfs.h"
#include <rtems/libio_.h>
#if defined(IMFS_DEBUG)
#include <stdio.h>
#endif
/*
* IMFS file system operations table
*/
#include "imfs.h"
const rtems_filesystem_operations_table IMFS_ops = {
IMFS_eval_path,
IMFS_evaluate_for_make,
IMFS_link,
IMFS_unlink,
IMFS_node_type,
IMFS_mknod,
IMFS_chown,
IMFS_freenodinfo,
IMFS_mount,
IMFS_initialize,
IMFS_unmount,
IMFS_fsunmount,
IMFS_utime,
IMFS_evaluate_link,
IMFS_symlink,
IMFS_readlink,
IMFS_rename,
NULL
.evalpath_h = IMFS_eval_path,
.evalformake_h = IMFS_evaluate_for_make,
.link_h = IMFS_link,
.unlink_h = IMFS_unlink,
.node_type_h = IMFS_node_type,
.mknod_h = IMFS_mknod,
.chown_h = IMFS_chown,
.freenod_h = IMFS_freenodinfo,
.mount_h = IMFS_mount,
.fsmount_me_h = IMFS_initialize,
.unmount_h = IMFS_unmount,
.fsunmount_me_h = IMFS_fsunmount,
.utime_h = IMFS_utime,
.eval_link_h = IMFS_evaluate_link,
.symlink_h = IMFS_symlink,
.readlink_h = IMFS_readlink,
.rename_h = IMFS_rename,
.statvfs_h = NULL
};
/*
* IMFS_initialize
*/
int IMFS_initialize(
rtems_filesystem_mount_table_entry_t *temp_mt_entry,
rtems_filesystem_mount_table_entry_t *mt_entry,
const void *data
)
{
return IMFS_initialize_support(
temp_mt_entry,
mt_entry,
&IMFS_ops,
&IMFS_memfile_handlers,
&IMFS_directory_handlers
&IMFS_directory_handlers,
&rtems_filesystem_null_handlers /* for fifos */
);
}

View File

@@ -66,7 +66,8 @@ int IMFS_initialize_support(
rtems_filesystem_mount_table_entry_t *temp_mt_entry,
const rtems_filesystem_operations_table *op_table,
const rtems_filesystem_file_handlers_r *memfile_handlers,
const rtems_filesystem_file_handlers_r *directory_handlers
const rtems_filesystem_file_handlers_r *directory_handlers,
const rtems_filesystem_file_handlers_r *fifo_handlers
)
{
static int imfs_instance;
@@ -108,12 +109,10 @@ int IMFS_initialize_support(
fs_info->ino_count = 1;
fs_info->memfile_handlers = memfile_handlers;
fs_info->directory_handlers = directory_handlers;
fs_info->fifo_handlers = fifo_handlers;
jnode = temp_mt_entry->mt_fs_root.node_access;
jnode->st_ino = fs_info->ino_count;
/* Initialize POSIX FIFO/pipe module */
rtems_pipe_initialize();
return 0;
}

View File

@@ -1,6 +1,12 @@
/*
* Mini-IMFS Initialization
/**
* @file
*
* @ingroup LibFSIMFS
*
* @brief Mini-IMFS initialization.
*/
/*
* COPYRIGHT (c) 1989-1999.
* On-Line Applications Research Corporation (OAR).
*
@@ -15,58 +21,41 @@
#include "config.h"
#endif
#include <sys/types.h> /* for mkdir */
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <assert.h>
#include "imfs.h"
#include <rtems/libio_.h>
#if defined(IMFS_DEBUG)
#include <stdio.h>
#endif
#include "imfs.h"
/*
* miniIMFS file system operations table
*/
const rtems_filesystem_operations_table miniIMFS_ops = {
IMFS_eval_path,
IMFS_evaluate_for_make,
NULL, /* XXX IMFS_link, */
NULL, /* XXX IMFS_unlink, */
IMFS_node_type,
IMFS_mknod,
NULL, /* XXX IMFS_chown, */
NULL, /* XXX IMFS_freenodinfo, */
NULL, /* XXX IMFS_mount, */
miniIMFS_initialize,
NULL, /* XXX IMFS_unmount, */
NULL, /* XXX IMFS_fsunmount, */
NULL, /* XXX IMFS_utime, */
NULL, /* XXX IMFS_evaluate_link, */
NULL, /* XXX IMFS_symlink, */
NULL, /* XXX IMFS_readlink */
NULL, /* XXX IMFS_rename */
NULL /* XXX IMFS_statvfs */
static const rtems_filesystem_operations_table miniIMFS_ops = {
.evalpath_h = IMFS_eval_path,
.evalformake_h = IMFS_evaluate_for_make,
.link_h = NULL,
.unlink_h = NULL,
.node_type_h = IMFS_node_type,
.mknod_h = IMFS_mknod,
.chown_h = NULL,
.freenod_h = NULL,
.mount_h = IMFS_mount,
.fsmount_me_h = miniIMFS_initialize,
.unmount_h = NULL,
.fsunmount_me_h = NULL,
.utime_h = NULL,
.eval_link_h = NULL,
.symlink_h = NULL,
.readlink_h = NULL,
.rename_h = NULL,
.statvfs_h = NULL
};
/*
* miniIMFS_initialize
*/
int miniIMFS_initialize(
rtems_filesystem_mount_table_entry_t *temp_mt_entry,
rtems_filesystem_mount_table_entry_t *mt_entry,
const void *data
)
{
return IMFS_initialize_support(
temp_mt_entry,
mt_entry,
&miniIMFS_ops,
&rtems_filesystem_null_handlers, /* for memfiles */
&rtems_filesystem_null_handlers /* for directories */
&rtems_filesystem_null_handlers, /* for directories */
&rtems_filesystem_null_handlers /* for fifos */
);
}

View File

@@ -21,6 +21,10 @@
#include <errno.h>
#include <stdlib.h>
#include <rtems.h>
#include <rtems/libio_.h>
#include "pipe.h"
@@ -29,9 +33,7 @@
#define LIBIO_ACCMODE(_iop) ((_iop)->flags & LIBIO_FLAGS_READ_WRITE)
#define LIBIO_NODELAY(_iop) ((_iop)->flags & LIBIO_FLAGS_NO_DELAY)
extern uint16_t rtems_pipe_no;
static rtems_id rtems_pipe_semaphore = 0;
extern bool rtems_pipe_configured;
static rtems_id pipe_semaphore = RTEMS_ID_NONE;
#define PIPE_EMPTY(_pipe) (_pipe->Length == 0)
@@ -82,7 +84,7 @@ static void pipe_interruptible(pipe_control_t *pipe)
/*
* Alloc pipe control structure, buffer, and resources.
* Called with rtems_pipe_semaphore held.
* Called with pipe_semaphore held.
*/
static int pipe_alloc(
pipe_control_t **pipep
@@ -139,7 +141,7 @@ err_buf:
return err;
}
/* Called with rtems_pipe_semaphore held. */
/* Called with pipe_semaphore held. */
static inline void pipe_free(
pipe_control_t *pipe
)
@@ -151,6 +153,48 @@ static inline void pipe_free(
free(pipe);
}
static rtems_status_code pipe_lock(void)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
if (pipe_semaphore == RTEMS_ID_NONE) {
rtems_libio_lock();
if (pipe_semaphore == RTEMS_ID_NONE) {
sc = rtems_semaphore_create(
rtems_build_name('P', 'I', 'P', 'E'),
1,
RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY,
RTEMS_NO_PRIORITY,
&pipe_semaphore
);
}
rtems_libio_unlock();
}
if (sc == RTEMS_SUCCESSFUL) {
sc = rtems_semaphore_obtain(pipe_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
}
if (sc == RTEMS_SUCCESSFUL) {
return 0;
} else {
return -EINTR;
}
}
static void pipe_unlock(void)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
sc = rtems_semaphore_release(pipe_semaphore);
if (sc != RTEMS_SUCCESSFUL) {
/* FIXME */
rtems_fatal_error_occurred(0xdeadbeef);
}
}
/*
* If called with *pipep = NULL, pipe_new will call pipe_alloc to allocate a
* pipe control structure and set *pipep to its address.
@@ -163,9 +207,9 @@ static int pipe_new(
pipe_control_t *pipe;
int err = 0;
if (rtems_semaphore_obtain(rtems_pipe_semaphore,
RTEMS_WAIT, RTEMS_NO_TIMEOUT) != RTEMS_SUCCESSFUL)
return -EINTR;
err = pipe_lock();
if (err)
return err;
pipe = *pipep;
if (pipe == NULL) {
@@ -185,7 +229,7 @@ static int pipe_new(
}
out:
rtems_semaphore_release(rtems_pipe_semaphore);
pipe_unlock();
return err;
}
@@ -204,11 +248,16 @@ int pipe_release(
uint32_t mode;
rtems_status_code sc;
sc = rtems_semaphore_obtain(pipe->Semaphore,
RTEMS_WAIT, RTEMS_NO_TIMEOUT);
if (pipe_lock())
/* WARN pipe not freed and pipep not set to NULL! */
/* FIXME */
rtems_fatal_error_occurred(0xdeadbeef);
if (!PIPE_LOCK(pipe))
/* WARN pipe not released! */
if(sc != RTEMS_SUCCESSFUL)
rtems_fatal_error_occurred(sc);
/* FIXME */
rtems_fatal_error_occurred(0xdeadbeef);
mode = LIBIO_ACCMODE(iop);
if (mode & LIBIO_FLAGS_READ)
@@ -216,12 +265,6 @@ int pipe_release(
if (mode & LIBIO_FLAGS_WRITE)
pipe->Writers --;
sc = rtems_semaphore_obtain(rtems_pipe_semaphore,
RTEMS_WAIT, RTEMS_NO_TIMEOUT);
/* WARN pipe not freed and pipep not set to NULL! */
if(sc != RTEMS_SUCCESSFUL)
rtems_fatal_error_occurred(sc);
PIPE_UNLOCK(pipe);
if (pipe->Readers == 0 && pipe->Writers == 0) {
@@ -239,7 +282,7 @@ int pipe_release(
else if (pipe->Writers == 0 && mode != LIBIO_FLAGS_READ)
PIPE_WAKEUPREADERS(pipe);
rtems_semaphore_release(rtems_pipe_semaphore);
pipe_unlock();
#if 0
if (! delfile)
@@ -539,27 +582,3 @@ int pipe_lseek(
/* Seek on pipe is not supported */
return -ESPIPE;
}
/*
* Initialization of FIFO/pipe module.
*/
void rtems_pipe_initialize (void)
{
if (!rtems_pipe_configured)
return;
if (rtems_pipe_semaphore)
return;
rtems_status_code sc;
sc = rtems_semaphore_create(
rtems_build_name ('P', 'I', 'P', 'E'), 1,
RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY,
RTEMS_NO_PRIORITY, &rtems_pipe_semaphore);
if (sc != RTEMS_SUCCESSFUL)
rtems_fatal_error_occurred (sc);
rtems_interval now;
now = rtems_clock_get_ticks_since_boot();
rtems_pipe_no = now;
}

View File

@@ -20,7 +20,8 @@
#include <rtems/seterr.h>
/* Incremental number added to names of anonymous pipe files */
uint16_t rtems_pipe_no = 0;
/* FIXME: This approach is questionable */
static uint16_t rtems_pipe_no = 0;
/*
* Called by pipe() to create an anonymous pipe.
@@ -33,6 +34,7 @@ int pipe_create(
rtems_libio_t *iop;
int err = 0;
/* Create /tmp if not exists */
/* FIXME: We should use a general mkdir function for this */
if (rtems_filesystem_evaluate_path("/tmp", 3, RTEMS_LIBIO_PERMS_RWX, &loc, TRUE)
!= 0) {
if (errno != ENOENT)

View File

@@ -109,11 +109,6 @@ extern int pipe_lseek(
rtems_libio_t *iop
);
/*
* Initialization of FIFO/pipe module.
*/
extern void rtems_pipe_initialize (void);
#ifdef __cplusplus
}
#endif

View File

@@ -293,8 +293,12 @@ rtems_fs_init_functions_t rtems_fs_init_helper =
*/
#if !defined(CONFIGURE_FILESYSTEM_ENTRY_IMFS) && \
defined(CONFIGURE_FILESYSTEM_IMFS)
#if defined(CONFIGURE_PIPES_ENABLED)
#define CONFIGURE_FILESYSTEM_ENTRY_IMFS { "imfs", fifoIMFS_initialize }
#else
#define CONFIGURE_FILESYSTEM_ENTRY_IMFS { "imfs", IMFS_initialize }
#endif
#endif
/**
* DEVFS
@@ -428,20 +432,6 @@ rtems_fs_init_functions_t rtems_fs_init_helper =
};
#endif
/**
* This disables the inclusion of pipe support in the full IMFS.
*
* NOTE: When building for coverage, we need this variable all the time.
*/
#if !defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) || \
defined(RTEMS_COVERAGE)
#if defined(CONFIGURE_PIPES_ENABLED)
bool rtems_pipe_configured = true;
#else
bool rtems_pipe_configured = false;
#endif
#endif
#ifndef CONFIGURE_HAS_OWN_MOUNT_TABLE
const rtems_filesystem_mount_table_t configuration_mount_table = {
#if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM)