forked from Imagelibrary/rtems
@@ -449,14 +449,8 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
|
|||||||
#if !defined(CONFIGURE_FILESYSTEM_ENTRY_JFFS2) && \
|
#if !defined(CONFIGURE_FILESYSTEM_ENTRY_JFFS2) && \
|
||||||
defined(CONFIGURE_FILESYSTEM_JFFS2)
|
defined(CONFIGURE_FILESYSTEM_JFFS2)
|
||||||
#include <rtems/jffs2.h>
|
#include <rtems/jffs2.h>
|
||||||
#if !defined(CONFIGURE_MAXIMUM_JFFS2_MOUNTS)
|
|
||||||
#define CONFIGURE_MAXIMUM_JFFS2_MOUNTS 1
|
|
||||||
#endif
|
|
||||||
#define CONFIGURE_FILESYSTEM_ENTRY_JFFS2 \
|
#define CONFIGURE_FILESYSTEM_ENTRY_JFFS2 \
|
||||||
{ RTEMS_FILESYSTEM_TYPE_JFFS2, rtems_jffs2_initialize }
|
{ RTEMS_FILESYSTEM_TYPE_JFFS2, rtems_jffs2_initialize }
|
||||||
#define _CONFIGURE_SEMAPHORES_FOR_JFFS2 CONFIGURE_MAXIMUM_JFFS2_MOUNTS
|
|
||||||
#else
|
|
||||||
#define _CONFIGURE_SEMAPHORES_FOR_JFFS2 0
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -467,8 +461,7 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
|
|||||||
(_CONFIGURE_SEMAPHORES_FOR_FIFOS + \
|
(_CONFIGURE_SEMAPHORES_FOR_FIFOS + \
|
||||||
_CONFIGURE_SEMAPHORES_FOR_NFS + \
|
_CONFIGURE_SEMAPHORES_FOR_NFS + \
|
||||||
_CONFIGURE_SEMAPHORES_FOR_DOSFS + \
|
_CONFIGURE_SEMAPHORES_FOR_DOSFS + \
|
||||||
_CONFIGURE_SEMAPHORES_FOR_RFS + \
|
_CONFIGURE_SEMAPHORES_FOR_RFS)
|
||||||
_CONFIGURE_SEMAPHORES_FOR_JFFS2)
|
|
||||||
|
|
||||||
#ifdef CONFIGURE_INIT
|
#ifdef CONFIGURE_INIT
|
||||||
|
|
||||||
|
|||||||
@@ -315,18 +315,14 @@ typedef struct {
|
|||||||
struct jffs2_inode_cache *inode_cache[];
|
struct jffs2_inode_cache *inode_cache[];
|
||||||
} rtems_jffs2_fs_info;
|
} rtems_jffs2_fs_info;
|
||||||
|
|
||||||
static void rtems_jffs2_do_lock(const struct super_block *sb)
|
static void rtems_jffs2_do_lock(struct super_block *sb)
|
||||||
{
|
{
|
||||||
rtems_status_code sc = rtems_semaphore_obtain(sb->s_mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
|
rtems_recursive_mutex_lock(&sb->s_mutex);
|
||||||
assert(sc == RTEMS_SUCCESSFUL);
|
|
||||||
(void) sc; /* avoid unused variable warning */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rtems_jffs2_do_unlock(const struct super_block *sb)
|
static void rtems_jffs2_do_unlock(struct super_block *sb)
|
||||||
{
|
{
|
||||||
rtems_status_code sc = rtems_semaphore_release(sb->s_mutex);
|
rtems_recursive_mutex_unlock(&sb->s_mutex);
|
||||||
assert(sc == RTEMS_SUCCESSFUL);
|
|
||||||
(void) sc; /* avoid unused variable warning */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rtems_jffs2_free_directory_entries(struct _inode *inode)
|
static void rtems_jffs2_free_directory_entries(struct _inode *inode)
|
||||||
@@ -366,15 +362,9 @@ static void rtems_jffs2_free_fs_info(rtems_jffs2_fs_info *fs_info, bool do_mount
|
|||||||
free(c->blocks);
|
free(c->blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sb->s_mutex != 0) {
|
|
||||||
rtems_status_code sc = rtems_semaphore_delete(sb->s_mutex);
|
|
||||||
assert(sc == RTEMS_SUCCESSFUL);
|
|
||||||
(void) sc; /* avoid unused variable warning */
|
|
||||||
}
|
|
||||||
|
|
||||||
rtems_jffs2_flash_control_destroy(fs_info->sb.s_flash_control);
|
rtems_jffs2_flash_control_destroy(fs_info->sb.s_flash_control);
|
||||||
rtems_jffs2_compressor_control_destroy(fs_info->sb.s_compressor_control);
|
rtems_jffs2_compressor_control_destroy(fs_info->sb.s_compressor_control);
|
||||||
|
rtems_recursive_mutex_destroy(&sb->s_mutex);
|
||||||
free(fs_info);
|
free(fs_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -883,16 +873,16 @@ static const rtems_filesystem_eval_path_generic_config rtems_jffs2_eval_config =
|
|||||||
|
|
||||||
static void rtems_jffs2_lock(const rtems_filesystem_mount_table_entry_t *mt_entry)
|
static void rtems_jffs2_lock(const rtems_filesystem_mount_table_entry_t *mt_entry)
|
||||||
{
|
{
|
||||||
const rtems_jffs2_fs_info *fs_info = mt_entry->fs_info;
|
rtems_jffs2_fs_info *fs_info = mt_entry->fs_info;
|
||||||
const struct super_block *sb = &fs_info->sb;
|
struct super_block *sb = &fs_info->sb;
|
||||||
|
|
||||||
rtems_jffs2_do_lock(sb);
|
rtems_jffs2_do_lock(sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rtems_jffs2_unlock(const rtems_filesystem_mount_table_entry_t *mt_entry)
|
static void rtems_jffs2_unlock(const rtems_filesystem_mount_table_entry_t *mt_entry)
|
||||||
{
|
{
|
||||||
const rtems_jffs2_fs_info *fs_info = mt_entry->fs_info;
|
rtems_jffs2_fs_info *fs_info = mt_entry->fs_info;
|
||||||
const struct super_block *sb = &fs_info->sb;
|
struct super_block *sb = &fs_info->sb;
|
||||||
|
|
||||||
rtems_jffs2_do_unlock(sb);
|
rtems_jffs2_do_unlock(sb);
|
||||||
}
|
}
|
||||||
@@ -1244,6 +1234,10 @@ int rtems_jffs2_initialize(
|
|||||||
sb = &fs_info->sb;
|
sb = &fs_info->sb;
|
||||||
c = JFFS2_SB_INFO(sb);
|
c = JFFS2_SB_INFO(sb);
|
||||||
|
|
||||||
|
if (err == 0) {
|
||||||
|
rtems_recursive_mutex_init(&sb->s_mutex, RTEMS_FILESYSTEM_TYPE_JFFS2);
|
||||||
|
}
|
||||||
|
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
uint32_t blocks = fc->flash_size / fc->block_size;
|
uint32_t blocks = fc->flash_size / fc->block_size;
|
||||||
|
|
||||||
@@ -1260,18 +1254,6 @@ int rtems_jffs2_initialize(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err == 0) {
|
|
||||||
rtems_status_code sc = rtems_semaphore_create(
|
|
||||||
rtems_build_name('J', 'F', 'F', 'S'),
|
|
||||||
1,
|
|
||||||
RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY | RTEMS_BINARY_SEMAPHORE,
|
|
||||||
0,
|
|
||||||
&sb->s_mutex
|
|
||||||
);
|
|
||||||
|
|
||||||
err = sc == RTEMS_SUCCESSFUL ? 0 : -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
sb->s_is_readonly = !mt_entry->writeable;
|
sb->s_is_readonly = !mt_entry->writeable;
|
||||||
sb->s_flash_control = fc;
|
sb->s_flash_control = fc;
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include <rtems/jffs2.h>
|
#include <rtems/jffs2.h>
|
||||||
|
#include <rtems/thread.h>
|
||||||
|
|
||||||
#define CONFIG_JFFS2_RTIME
|
#define CONFIG_JFFS2_RTIME
|
||||||
|
|
||||||
@@ -104,7 +105,7 @@ struct super_block {
|
|||||||
rtems_jffs2_compressor_control *s_compressor_control;
|
rtems_jffs2_compressor_control *s_compressor_control;
|
||||||
bool s_is_readonly;
|
bool s_is_readonly;
|
||||||
unsigned char s_gc_buffer[PAGE_CACHE_SIZE]; // Avoids malloc when user may be under memory pressure
|
unsigned char s_gc_buffer[PAGE_CACHE_SIZE]; // Avoids malloc when user may be under memory pressure
|
||||||
rtems_id s_mutex;
|
rtems_recursive_mutex s_mutex;
|
||||||
char s_name_buf[JFFS2_MAX_NAME_LEN];
|
char s_name_buf[JFFS2_MAX_NAME_LEN];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user