forked from Imagelibrary/rtems
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.
This commit is contained in:
@@ -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>
|
2010-06-08 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
||||||
|
|
||||||
* libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_rmnod.c: Added and use
|
* libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_rmnod.c: Added and use
|
||||||
|
|||||||
@@ -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_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/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/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/imfs/deviceerrno.c \
|
||||||
src/devfs/devfs_init.c src/devfs/devfs_eval.c src/devfs/devfs_mknod.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 \
|
src/devfs/devfs_show.c src/devfs/devfs_node_type.c \
|
||||||
|
|||||||
61
cpukit/libfs/src/imfs/fifoimfs_init.c
Normal file
61
cpukit/libfs/src/imfs/fifoimfs_init.c
Normal 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
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -223,6 +223,7 @@ typedef struct {
|
|||||||
ino_t ino_count;
|
ino_t ino_count;
|
||||||
const rtems_filesystem_file_handlers_r *memfile_handlers;
|
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;
|
||||||
} IMFS_fs_info_t;
|
} 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_memfile_handlers;
|
||||||
extern const rtems_filesystem_file_handlers_r IMFS_fifo_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 IMFS_ops;
|
||||||
extern const rtems_filesystem_operations_table miniIMFS_ops;
|
|
||||||
extern const rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS;
|
extern const rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -259,6 +259,11 @@ extern int IMFS_initialize(
|
|||||||
const void *data
|
const void *data
|
||||||
);
|
);
|
||||||
|
|
||||||
|
extern int fifoIMFS_initialize(
|
||||||
|
rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||||
|
const void *data
|
||||||
|
);
|
||||||
|
|
||||||
extern int miniIMFS_initialize(
|
extern int miniIMFS_initialize(
|
||||||
rtems_filesystem_mount_table_entry_t *mt_entry,
|
rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||||
const void *data
|
const void *data
|
||||||
@@ -268,7 +273,8 @@ extern int IMFS_initialize_support(
|
|||||||
rtems_filesystem_mount_table_entry_t *mt_entry,
|
rtems_filesystem_mount_table_entry_t *mt_entry,
|
||||||
const rtems_filesystem_operations_table *op_table,
|
const rtems_filesystem_operations_table *op_table,
|
||||||
const rtems_filesystem_file_handlers_r *memfile_handlers,
|
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(
|
extern int IMFS_fsunmount(
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ int IMFS_Set_handlers(
|
|||||||
loc->handlers = fs_info->memfile_handlers;
|
loc->handlers = fs_info->memfile_handlers;
|
||||||
break;
|
break;
|
||||||
case IMFS_FIFO:
|
case IMFS_FIFO:
|
||||||
loc->handlers = &IMFS_fifo_handlers;
|
loc->handlers = fs_info->fifo_handlers;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
/*
|
/**
|
||||||
* IMFS Initialization
|
* @file
|
||||||
*
|
*
|
||||||
|
* @ingroup LibFSIMFS
|
||||||
|
*
|
||||||
|
* @brief IMFS initialization.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
* COPYRIGHT (c) 1989-1999.
|
* COPYRIGHT (c) 1989-1999.
|
||||||
* On-Line Applications Research Corporation (OAR).
|
* On-Line Applications Research Corporation (OAR).
|
||||||
*
|
*
|
||||||
@@ -15,58 +21,41 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#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>
|
#include <rtems/libio_.h>
|
||||||
|
|
||||||
#if defined(IMFS_DEBUG)
|
#include "imfs.h"
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
const rtems_filesystem_operations_table IMFS_ops = {
|
||||||
* IMFS file system operations table
|
.evalpath_h = IMFS_eval_path,
|
||||||
*/
|
.evalformake_h = IMFS_evaluate_for_make,
|
||||||
|
.link_h = IMFS_link,
|
||||||
const rtems_filesystem_operations_table IMFS_ops = {
|
.unlink_h = IMFS_unlink,
|
||||||
IMFS_eval_path,
|
.node_type_h = IMFS_node_type,
|
||||||
IMFS_evaluate_for_make,
|
.mknod_h = IMFS_mknod,
|
||||||
IMFS_link,
|
.chown_h = IMFS_chown,
|
||||||
IMFS_unlink,
|
.freenod_h = IMFS_freenodinfo,
|
||||||
IMFS_node_type,
|
.mount_h = IMFS_mount,
|
||||||
IMFS_mknod,
|
.fsmount_me_h = IMFS_initialize,
|
||||||
IMFS_chown,
|
.unmount_h = IMFS_unmount,
|
||||||
IMFS_freenodinfo,
|
.fsunmount_me_h = IMFS_fsunmount,
|
||||||
IMFS_mount,
|
.utime_h = IMFS_utime,
|
||||||
IMFS_initialize,
|
.eval_link_h = IMFS_evaluate_link,
|
||||||
IMFS_unmount,
|
.symlink_h = IMFS_symlink,
|
||||||
IMFS_fsunmount,
|
.readlink_h = IMFS_readlink,
|
||||||
IMFS_utime,
|
.rename_h = IMFS_rename,
|
||||||
IMFS_evaluate_link,
|
.statvfs_h = NULL
|
||||||
IMFS_symlink,
|
|
||||||
IMFS_readlink,
|
|
||||||
IMFS_rename,
|
|
||||||
NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* IMFS_initialize
|
|
||||||
*/
|
|
||||||
|
|
||||||
int 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
|
const void *data
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return IMFS_initialize_support(
|
return IMFS_initialize_support(
|
||||||
temp_mt_entry,
|
mt_entry,
|
||||||
&IMFS_ops,
|
&IMFS_ops,
|
||||||
&IMFS_memfile_handlers,
|
&IMFS_memfile_handlers,
|
||||||
&IMFS_directory_handlers
|
&IMFS_directory_handlers,
|
||||||
);
|
&rtems_filesystem_null_handlers /* for fifos */
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ int IMFS_initialize_support(
|
|||||||
rtems_filesystem_mount_table_entry_t *temp_mt_entry,
|
rtems_filesystem_mount_table_entry_t *temp_mt_entry,
|
||||||
const rtems_filesystem_operations_table *op_table,
|
const rtems_filesystem_operations_table *op_table,
|
||||||
const rtems_filesystem_file_handlers_r *memfile_handlers,
|
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;
|
static int imfs_instance;
|
||||||
@@ -108,12 +109,10 @@ int IMFS_initialize_support(
|
|||||||
fs_info->ino_count = 1;
|
fs_info->ino_count = 1;
|
||||||
fs_info->memfile_handlers = memfile_handlers;
|
fs_info->memfile_handlers = memfile_handlers;
|
||||||
fs_info->directory_handlers = directory_handlers;
|
fs_info->directory_handlers = directory_handlers;
|
||||||
|
fs_info->fifo_handlers = fifo_handlers;
|
||||||
|
|
||||||
jnode = temp_mt_entry->mt_fs_root.node_access;
|
jnode = temp_mt_entry->mt_fs_root.node_access;
|
||||||
jnode->st_ino = fs_info->ino_count;
|
jnode->st_ino = fs_info->ino_count;
|
||||||
|
|
||||||
/* Initialize POSIX FIFO/pipe module */
|
|
||||||
rtems_pipe_initialize();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
/*
|
/**
|
||||||
* Mini-IMFS Initialization
|
* @file
|
||||||
*
|
*
|
||||||
|
* @ingroup LibFSIMFS
|
||||||
|
*
|
||||||
|
* @brief Mini-IMFS initialization.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
* COPYRIGHT (c) 1989-1999.
|
* COPYRIGHT (c) 1989-1999.
|
||||||
* On-Line Applications Research Corporation (OAR).
|
* On-Line Applications Research Corporation (OAR).
|
||||||
*
|
*
|
||||||
@@ -15,58 +21,41 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#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>
|
#include <rtems/libio_.h>
|
||||||
|
|
||||||
#if defined(IMFS_DEBUG)
|
#include "imfs.h"
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
static const rtems_filesystem_operations_table miniIMFS_ops = {
|
||||||
* miniIMFS file system operations table
|
.evalpath_h = IMFS_eval_path,
|
||||||
*/
|
.evalformake_h = IMFS_evaluate_for_make,
|
||||||
|
.link_h = NULL,
|
||||||
const rtems_filesystem_operations_table miniIMFS_ops = {
|
.unlink_h = NULL,
|
||||||
IMFS_eval_path,
|
.node_type_h = IMFS_node_type,
|
||||||
IMFS_evaluate_for_make,
|
.mknod_h = IMFS_mknod,
|
||||||
NULL, /* XXX IMFS_link, */
|
.chown_h = NULL,
|
||||||
NULL, /* XXX IMFS_unlink, */
|
.freenod_h = NULL,
|
||||||
IMFS_node_type,
|
.mount_h = IMFS_mount,
|
||||||
IMFS_mknod,
|
.fsmount_me_h = miniIMFS_initialize,
|
||||||
NULL, /* XXX IMFS_chown, */
|
.unmount_h = NULL,
|
||||||
NULL, /* XXX IMFS_freenodinfo, */
|
.fsunmount_me_h = NULL,
|
||||||
NULL, /* XXX IMFS_mount, */
|
.utime_h = NULL,
|
||||||
miniIMFS_initialize,
|
.eval_link_h = NULL,
|
||||||
NULL, /* XXX IMFS_unmount, */
|
.symlink_h = NULL,
|
||||||
NULL, /* XXX IMFS_fsunmount, */
|
.readlink_h = NULL,
|
||||||
NULL, /* XXX IMFS_utime, */
|
.rename_h = NULL,
|
||||||
NULL, /* XXX IMFS_evaluate_link, */
|
.statvfs_h = NULL
|
||||||
NULL, /* XXX IMFS_symlink, */
|
|
||||||
NULL, /* XXX IMFS_readlink */
|
|
||||||
NULL, /* XXX IMFS_rename */
|
|
||||||
NULL /* XXX IMFS_statvfs */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* miniIMFS_initialize
|
|
||||||
*/
|
|
||||||
|
|
||||||
int 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
|
const void *data
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return IMFS_initialize_support(
|
return IMFS_initialize_support(
|
||||||
temp_mt_entry,
|
mt_entry,
|
||||||
&miniIMFS_ops,
|
&miniIMFS_ops,
|
||||||
&rtems_filesystem_null_handlers, /* for memfiles */
|
&rtems_filesystem_null_handlers, /* for memfiles */
|
||||||
&rtems_filesystem_null_handlers /* for directories */
|
&rtems_filesystem_null_handlers, /* for directories */
|
||||||
);
|
&rtems_filesystem_null_handlers /* for fifos */
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,10 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <rtems.h>
|
||||||
|
#include <rtems/libio_.h>
|
||||||
|
|
||||||
#include "pipe.h"
|
#include "pipe.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -29,9 +33,7 @@
|
|||||||
#define LIBIO_ACCMODE(_iop) ((_iop)->flags & LIBIO_FLAGS_READ_WRITE)
|
#define LIBIO_ACCMODE(_iop) ((_iop)->flags & LIBIO_FLAGS_READ_WRITE)
|
||||||
#define LIBIO_NODELAY(_iop) ((_iop)->flags & LIBIO_FLAGS_NO_DELAY)
|
#define LIBIO_NODELAY(_iop) ((_iop)->flags & LIBIO_FLAGS_NO_DELAY)
|
||||||
|
|
||||||
extern uint16_t rtems_pipe_no;
|
static rtems_id pipe_semaphore = RTEMS_ID_NONE;
|
||||||
static rtems_id rtems_pipe_semaphore = 0;
|
|
||||||
extern bool rtems_pipe_configured;
|
|
||||||
|
|
||||||
|
|
||||||
#define PIPE_EMPTY(_pipe) (_pipe->Length == 0)
|
#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.
|
* Alloc pipe control structure, buffer, and resources.
|
||||||
* Called with rtems_pipe_semaphore held.
|
* Called with pipe_semaphore held.
|
||||||
*/
|
*/
|
||||||
static int pipe_alloc(
|
static int pipe_alloc(
|
||||||
pipe_control_t **pipep
|
pipe_control_t **pipep
|
||||||
@@ -139,7 +141,7 @@ err_buf:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called with rtems_pipe_semaphore held. */
|
/* Called with pipe_semaphore held. */
|
||||||
static inline void pipe_free(
|
static inline void pipe_free(
|
||||||
pipe_control_t *pipe
|
pipe_control_t *pipe
|
||||||
)
|
)
|
||||||
@@ -151,6 +153,48 @@ static inline void pipe_free(
|
|||||||
free(pipe);
|
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
|
* If called with *pipep = NULL, pipe_new will call pipe_alloc to allocate a
|
||||||
* pipe control structure and set *pipep to its address.
|
* pipe control structure and set *pipep to its address.
|
||||||
@@ -163,9 +207,9 @@ static int pipe_new(
|
|||||||
pipe_control_t *pipe;
|
pipe_control_t *pipe;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
if (rtems_semaphore_obtain(rtems_pipe_semaphore,
|
err = pipe_lock();
|
||||||
RTEMS_WAIT, RTEMS_NO_TIMEOUT) != RTEMS_SUCCESSFUL)
|
if (err)
|
||||||
return -EINTR;
|
return err;
|
||||||
|
|
||||||
pipe = *pipep;
|
pipe = *pipep;
|
||||||
if (pipe == NULL) {
|
if (pipe == NULL) {
|
||||||
@@ -185,7 +229,7 @@ static int pipe_new(
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
rtems_semaphore_release(rtems_pipe_semaphore);
|
pipe_unlock();
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,11 +248,16 @@ int pipe_release(
|
|||||||
uint32_t mode;
|
uint32_t mode;
|
||||||
|
|
||||||
rtems_status_code sc;
|
rtems_status_code sc;
|
||||||
sc = rtems_semaphore_obtain(pipe->Semaphore,
|
|
||||||
RTEMS_WAIT, RTEMS_NO_TIMEOUT);
|
if (pipe_lock())
|
||||||
/* WARN pipe not released! */
|
/* WARN pipe not freed and pipep not set to NULL! */
|
||||||
if(sc != RTEMS_SUCCESSFUL)
|
/* FIXME */
|
||||||
rtems_fatal_error_occurred(sc);
|
rtems_fatal_error_occurred(0xdeadbeef);
|
||||||
|
|
||||||
|
if (!PIPE_LOCK(pipe))
|
||||||
|
/* WARN pipe not released! */
|
||||||
|
/* FIXME */
|
||||||
|
rtems_fatal_error_occurred(0xdeadbeef);
|
||||||
|
|
||||||
mode = LIBIO_ACCMODE(iop);
|
mode = LIBIO_ACCMODE(iop);
|
||||||
if (mode & LIBIO_FLAGS_READ)
|
if (mode & LIBIO_FLAGS_READ)
|
||||||
@@ -216,12 +265,6 @@ int pipe_release(
|
|||||||
if (mode & LIBIO_FLAGS_WRITE)
|
if (mode & LIBIO_FLAGS_WRITE)
|
||||||
pipe->Writers --;
|
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);
|
PIPE_UNLOCK(pipe);
|
||||||
|
|
||||||
if (pipe->Readers == 0 && pipe->Writers == 0) {
|
if (pipe->Readers == 0 && pipe->Writers == 0) {
|
||||||
@@ -239,7 +282,7 @@ int pipe_release(
|
|||||||
else if (pipe->Writers == 0 && mode != LIBIO_FLAGS_READ)
|
else if (pipe->Writers == 0 && mode != LIBIO_FLAGS_READ)
|
||||||
PIPE_WAKEUPREADERS(pipe);
|
PIPE_WAKEUPREADERS(pipe);
|
||||||
|
|
||||||
rtems_semaphore_release(rtems_pipe_semaphore);
|
pipe_unlock();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (! delfile)
|
if (! delfile)
|
||||||
@@ -539,27 +582,3 @@ int pipe_lseek(
|
|||||||
/* Seek on pipe is not supported */
|
/* Seek on pipe is not supported */
|
||||||
return -ESPIPE;
|
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;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -20,7 +20,8 @@
|
|||||||
#include <rtems/seterr.h>
|
#include <rtems/seterr.h>
|
||||||
|
|
||||||
/* Incremental number added to names of anonymous pipe files */
|
/* 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.
|
* Called by pipe() to create an anonymous pipe.
|
||||||
@@ -33,6 +34,7 @@ int pipe_create(
|
|||||||
rtems_libio_t *iop;
|
rtems_libio_t *iop;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
/* Create /tmp if not exists */
|
/* 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)
|
if (rtems_filesystem_evaluate_path("/tmp", 3, RTEMS_LIBIO_PERMS_RWX, &loc, TRUE)
|
||||||
!= 0) {
|
!= 0) {
|
||||||
if (errno != ENOENT)
|
if (errno != ENOENT)
|
||||||
|
|||||||
@@ -109,11 +109,6 @@ extern int pipe_lseek(
|
|||||||
rtems_libio_t *iop
|
rtems_libio_t *iop
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialization of FIFO/pipe module.
|
|
||||||
*/
|
|
||||||
extern void rtems_pipe_initialize (void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -293,7 +293,11 @@ rtems_fs_init_functions_t rtems_fs_init_helper =
|
|||||||
*/
|
*/
|
||||||
#if !defined(CONFIGURE_FILESYSTEM_ENTRY_IMFS) && \
|
#if !defined(CONFIGURE_FILESYSTEM_ENTRY_IMFS) && \
|
||||||
defined(CONFIGURE_FILESYSTEM_IMFS)
|
defined(CONFIGURE_FILESYSTEM_IMFS)
|
||||||
#define CONFIGURE_FILESYSTEM_ENTRY_IMFS { "imfs", IMFS_initialize }
|
#if defined(CONFIGURE_PIPES_ENABLED)
|
||||||
|
#define CONFIGURE_FILESYSTEM_ENTRY_IMFS { "imfs", fifoIMFS_initialize }
|
||||||
|
#else
|
||||||
|
#define CONFIGURE_FILESYSTEM_ENTRY_IMFS { "imfs", IMFS_initialize }
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -428,20 +432,6 @@ rtems_fs_init_functions_t rtems_fs_init_helper =
|
|||||||
};
|
};
|
||||||
#endif
|
#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
|
#ifndef CONFIGURE_HAS_OWN_MOUNT_TABLE
|
||||||
const rtems_filesystem_mount_table_t configuration_mount_table = {
|
const rtems_filesystem_mount_table_t configuration_mount_table = {
|
||||||
#if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM)
|
#if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM)
|
||||||
|
|||||||
Reference in New Issue
Block a user