TMPFS: Code complete, but not yet functional

This commit is contained in:
Gregory Nutt 2015-10-09 11:02:59 -06:00
parent 11a8a01462
commit d359a5be13
7 changed files with 521 additions and 212 deletions

View File

@ -11017,4 +11017,7 @@
temporary RAM file file system (2015-10-0i8).
* tools/: Add crappy style checking tool nxstyle.c. See thee tools/
README file for more info (2015-10-08).
* stm32 F4: Fix some TIM12 pin mappings. From Max Kriegleder
(2015-10-9).
* fs/tmpfs: TMPFS file system is code complete, but not yet functional
(2015-10-9).

2
arch

@ -1 +1 @@
Subproject commit 0b7bf8249b1b96f5e31597b5242db222a2c29f73
Subproject commit 00acafcbb154a076f60413eb75249c5b68c6c316

View File

@ -57,6 +57,7 @@ source fs/fat/Kconfig
source fs/nfs/Kconfig
source fs/nxffs/Kconfig
source fs/romfs/Kconfig
source fs/tmpfs/Kconfig
source fs/smartfs/Kconfig
source fs/binfs/Kconfig
source fs/procfs/Kconfig

View File

@ -64,6 +64,7 @@ ifneq ($(CONFIG_DISABLE_MOUNTPOINT),y)
include mount/Make.defs
include fat/Make.defs
include romfs/Make.defs
include tmpfs/Make.defs
include nxffs/Make.defs
include nfs/Make.defs
include smartfs/Make.defs

View File

@ -1,7 +1,7 @@
/****************************************************************************
* fs/mount/fs_mount.c
*
* Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009, 2011-2013, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -77,7 +77,8 @@
/* These file systems do not require block drivers */
#if defined(CONFIG_FS_NXFFS) || defined(CONFIG_FS_BINFS) || \
defined(CONFIG_FS_PROCFS) || defined(CONFIG_NFS)
defined(CONFIG_FS_PROCFS) || defined(CONFIG_NFS) || \
defined(CONFIG_FS_TMPFS)
# define NONBDFS_SUPPORT
#endif
@ -102,6 +103,9 @@ extern const struct mountpt_operations fat_operations;
#ifdef CONFIG_FS_ROMFS
extern const struct mountpt_operations romfs_operations;
#endif
#ifdef CONFIG_FS_TMPFS
extern const struct mountpt_operations tmpfs_operations;
#endif
#ifdef CONFIG_FS_SMARTFS
extern const struct mountpt_operations smartfs_operations;
#endif
@ -140,6 +144,9 @@ static const struct fsmap_t g_nonbdfsmap[] =
#ifdef CONFIG_FS_NXFFS
{ "nxffs", &nxffs_operations },
#endif
#ifdef CONFIG_FS_TMPFS
{ "tmpfs", &tmpfs_operations },
#endif
#ifdef CONFIG_NFS
{ "nfs", &nfs_operations },
#endif

File diff suppressed because it is too large Load Diff

View File

@ -47,8 +47,6 @@
#include <nuttx/fs/fs.h>
#ifndef CONFIG_DISABLE_MOUNTPOINT
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -56,6 +54,10 @@
#define TMPFS_BLOCKSIZE 512
/* Indicates that there is no holder of the re-entrant semaphore */
#define TMPFS_NO_HOLDER -1
/* Bit definitions for file object flags */
#define TFO_FLAG_UNLINKED (1 << 0) /* Bit 0: File is unlinked */
@ -82,22 +84,33 @@ enum tmpfs_foreach_e
TMPFS_UNLINKED /* Only the directory entry was deleted */
};
/* The generic form of a TMPFS memory object */
/* Re-entrant semaphore */
struct tmpfs_object_s
struct tmpfs_sem_s
{
size_t to_alloc; /* Allocated size of the memory object */
uint8_t to_type; /* See enum tmpfs_objtype_e */
uint8_t to_refs; /* Reference count */
sem_t to_exclsem; /* Supports exclusive access to the object */
sem_t ts_sem; /* The actual semaphore */
pid_t ts_holder; /* Current older (-1 if not held) */
uint16_t ts_count; /* Number of counts held */
};
/* The form of one directory entry */
struct tmpfs_dirent_s
{
FAR struct tmpfs_object_s *rde_object;
FAR char *rde_name;
FAR struct tmpfs_object_s *tde_object;
FAR char *tde_name;
};
/* The generic form of a TMPFS memory object */
struct tmpfs_object_s
{
FAR struct tmpfs_dirent_s *to_dirent;
struct tmpfs_sem_s to_exclsem;
size_t to_alloc; /* Allocated size of the memory object */
uint8_t to_type; /* See enum tmpfs_objtype_e */
uint8_t to_refs; /* Reference count */
};
/* The form of a directory memory object */
@ -106,10 +119,12 @@ struct tmpfs_directory_s
{
/* First fields must match common TMPFS object layout */
FAR struct tmpfs_dirent_s *tdo_dirent;
struct tmpfs_sem_s tdo_exclsem;
size_t tdo_alloc; /* Allocated size of the directory object */
uint8_t tdo_type; /* See enum tmpfs_objtype_e */
uint8_t tdo_refs; /* Reference count */
sem_t tdo_exclsem; /* Supports exclusive access to the directory */
/* Remaining fields are unique to a directory object */
@ -132,10 +147,12 @@ struct tmpfs_file_s
{
/* First fields must match common TMPFS object layout */
FAR struct tmpfs_dirent_s *tfo_dirent;
struct tmpfs_sem_s tfo_exclsem;
size_t tfo_alloc; /* Allocated size of the file object */
uint8_t tfo_type; /* See enum tmpfs_objtype_e */
uint8_t tfo_refs; /* Reference count */
sem_t tfo_exclsem; /* Supports exclusive access to the file */
/* Remaining fields are unique to a directory object */
@ -153,8 +170,7 @@ struct tmpfs_s
/* The root directory */
FAR struct tmpfs_directory_s *tfs_root;
sem_t tfs_exclsem; /* Supports exclusive access to the file system */
struct tmpfs_sem_s tfs_exclsem;
};
/* This is the type used the tmpfs_statfs_callout to accumulate memory usage */