fs/procfs: Add a tiny, primitive procfs file system. Might get more interesting in the future

This commit is contained in:
Gregory Nutt
2013-11-13 15:59:14 -06:00
parent 7de422a42c
commit 6e7c9b93c6
14 changed files with 1306 additions and 8 deletions
+2
View File
@@ -6040,3 +6040,5 @@
apps/examples/i2schar test (2011-11-11). apps/examples/i2schar test (2011-11-11).
* arch/arm/src/sama5/sam_ssc.c: I2S loopback test finally works * arch/arm/src/sama5/sam_ssc.c: I2S loopback test finally works
(2013-11-11). (2013-11-11).
* fs/procfs: Add a little, primitive procfs file system. (2013-11-13).
+4 -2
View File
@@ -233,8 +233,10 @@
| |- fs/ | |- fs/
| | |- mmap/ | | |- mmap/
| | | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/fs/mmap/README.txt"><b><i>README.txt</i></b></a> | | | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/fs/mmap/README.txt"><b><i>README.txt</i></b></a>
| | `- nxffs/ | | |- nxffs/
| | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/fs/nxffs/README.txt"><b><i>README.txt</i></b></a> | | | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/fs/nxffs/README.txt"><b><i>README.txt</i></b></a>
| | `- procfs/
| | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/fs/procfs/README.txt"><b><i>README.txt</i></b></a>
| |- graphics/ | |- graphics/
| | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/graphics/README.txt"><b><i>README.txt</i></b></a> | | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/graphics/README.txt"><b><i>README.txt</i></b></a>
| |- lib/ | |- lib/
+3 -1
View File
@@ -1161,7 +1161,9 @@ nuttx
|- fs/ |- fs/
| |- mmap/ | |- mmap/
| | `- README.txt | | `- README.txt
| `- nxffs/ | |- nxffs/
| | `- README.txt
| `- procfs/
| `- README.txt | `- README.txt
|- graphics/ |- graphics/
| `- README.txt | `- README.txt
+1
View File
@@ -16,6 +16,7 @@ source fs/nxffs/Kconfig
source fs/romfs/Kconfig source fs/romfs/Kconfig
source fs/smartfs/Kconfig source fs/smartfs/Kconfig
source fs/binfs/Kconfig source fs/binfs/Kconfig
source fs/procfs/Kconfig
comment "System Logging" comment "System Logging"
+2 -1
View File
@@ -111,6 +111,7 @@ include nxffs/Make.defs
include nfs/Make.defs include nfs/Make.defs
include smartfs/Make.defs include smartfs/Make.defs
include binfs/Make.defs include binfs/Make.defs
include procfs/Make.defs
endif endif
endif endif
@@ -122,7 +123,7 @@ OBJS = $(AOBJS) $(COBJS)
BIN = libfs$(LIBEXT) BIN = libfs$(LIBEXT)
SUBDIRS = mmap fat romfs nxffs nfs binfs SUBDIRS = mmap fat romfs nxffs nfs binfs procfs
all: $(BIN) all: $(BIN)
+10 -3
View File
@@ -63,7 +63,7 @@
/* Configuration ************************************************************/ /* Configuration ************************************************************/
/* In the canonical case, a file system is bound to a block driver. However, /* In the canonical case, a file system is bound to a block driver. However,
* some less typical cases a block driver is not required. Examples are * some less typical cases a block driver is not required. Examples are
* pseudo file systems (like BINFS) and MTD file systems (like NXFFS). * pseudo file systems (like BINFS or PROCFS) and MTD file systems (like NXFFS).
* *
* These file systems all require block drivers: * These file systems all require block drivers:
*/ */
@@ -74,7 +74,8 @@
/* These file systems do not require block drivers */ /* These file systems do not require block drivers */
#if defined(CONFIG_FS_NXFFS) || defined(CONFIG_FS_BINFS) || defined(CONFIG_NFS) #if defined(CONFIG_FS_NXFFS) || defined(CONFIG_FS_BINFS) || \
defined(CONFIG_FS_PROCFS) || defined(CONFIG_NFS)
# define NONBDFS_SUPPORT # define NONBDFS_SUPPORT
#endif #endif
@@ -128,6 +129,9 @@ extern const struct mountpt_operations nfs_operations;
#ifdef CONFIG_FS_BINFS #ifdef CONFIG_FS_BINFS
extern const struct mountpt_operations binfs_operations; extern const struct mountpt_operations binfs_operations;
#endif #endif
#ifdef CONFIG_FS_PROCFS
extern const struct mountpt_operations procfs_operations;
#endif
static const struct fsmap_t g_nonbdfsmap[] = static const struct fsmap_t g_nonbdfsmap[] =
{ {
@@ -140,7 +144,10 @@ static const struct fsmap_t g_nonbdfsmap[] =
#ifdef CONFIG_FS_BINFS #ifdef CONFIG_FS_BINFS
{ "binfs", &binfs_operations }, { "binfs", &binfs_operations },
#endif #endif
{ NULL, NULL }, #ifdef CONFIG_FS_PROCFS
{ "procfs", &procfs_operations },
#endif
{ NULL, NULL },
}; };
#endif /* NONBDFS_SUPPORT */ #endif /* NONBDFS_SUPPORT */
+13
View File
@@ -0,0 +1,13 @@
#
# For a description of the syntax of this configuration file,
# see misc/tools/kconfig-language.txt.
#
config FS_PROCFS
bool "PROCFS File System"
default n
---help---
The PROCFS file system is provides access to task status through the
NuttX file system. The PROCFS may, for example, be mount at /proc.
Then information about all of the currently active tasks and threads
will be available in proc/.
+48
View File
@@ -0,0 +1,48 @@
############################################################################
# fs/procfs/Make.defs
#
# Copyright (C) 2013 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name Nuttx nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
ifeq ($(CONFIG_FS_PROCFS),y)
# Files required for procfs file system support
ASRCS +=
CSRCS += fs_procfs.c
# Include procfs build support
DEPPATH += --dep-path procfs
VPATH += :procfs
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)fs$(DELIM)procfs}
endif
+12
View File
@@ -0,0 +1,12 @@
fs/procfs README
================
This is a tiny procfs file system that allows read-only access to a few
attributes of a task or thread. This tiny procfs fs file system can be
built into the system by enabling:
CONFIG_FS_PROCFS=y
It can then be mounted from the NSH command like like:
nsh> mount -t procfs /proc
File diff suppressed because it is too large Load Diff
+3
View File
@@ -196,6 +196,9 @@ struct fs_dirent_s
#ifdef CONFIG_FS_BINFS #ifdef CONFIG_FS_BINFS
struct fs_binfsdir_s binfs; struct fs_binfsdir_s binfs;
#endif #endif
#ifdef CONFIG_FS_PROCFS
FAR void *procfs;
#endif
#ifdef CONFIG_FS_NXFFS #ifdef CONFIG_FS_NXFFS
struct fs_nxffsdir_s nxffs; struct fs_nxffsdir_s nxffs;
#endif #endif
+4
View File
@@ -624,6 +624,10 @@ FAR struct tcb_s *sched_self(void);
void sched_foreach(sched_foreach_t handler, FAR void *arg); void sched_foreach(sched_foreach_t handler, FAR void *arg);
/* Give a task ID, look up the corresponding TCB */
FAR struct tcb_s *sched_gettcb(pid_t pid);
/* File system helpers **********************************************************/ /* File system helpers **********************************************************/
/* These functions all extract lists from the group structure assocated with the /* These functions all extract lists from the group structure assocated with the
* currently executing task. * currently executing task.
+1
View File
@@ -99,6 +99,7 @@
/* NuttX specific file-systems */ /* NuttX specific file-systems */
#define BINFS_MAGIC 0x4242 #define BINFS_MAGIC 0x4242
#define PROCFS_MAGIC 0x434f5250
#define NXFFS_MAGIC 0x4747 #define NXFFS_MAGIC 0x4747
#define SMARTFS_MAGIC 0x54524D53 #define SMARTFS_MAGIC 0x54524D53
-1
View File
@@ -258,7 +258,6 @@ int sched_reprioritize(FAR struct tcb_s *tcb, int sched_priority);
#else #else
# define sched_reprioritize(tcb,sched_priority) sched_setpriority(tcb,sched_priority) # define sched_reprioritize(tcb,sched_priority) sched_setpriority(tcb,sched_priority)
#endif #endif
FAR struct tcb_s *sched_gettcb(pid_t pid);
bool sched_verifytcb(FAR struct tcb_s *tcb); bool sched_verifytcb(FAR struct tcb_s *tcb);
int sched_releasetcb(FAR struct tcb_s *tcb, uint8_t ttype); int sched_releasetcb(FAR struct tcb_s *tcb, uint8_t ttype);