summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-03-28 00:05:58 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-03-28 00:05:58 +0000
commit931bd2b8661c8ed4c923220490cbebc56d6c0065 (patch)
tree744ba3d223b0b158d74f077328ca226a19407d28 /nuttx
parenta67921192b48c4b0dcc5ac34d180c710ec6ea5d3 (diff)
downloadnuttx-931bd2b8661c8ed4c923220490cbebc56d6c0065.tar.gz
nuttx-931bd2b8661c8ed4c923220490cbebc56d6c0065.tar.bz2
nuttx-931bd2b8661c8ed4c923220490cbebc56d6c0065.zip
Re-organize header files so that file systems can be built outside of the nuttx tree; add a binfs file system to apps/namedapp
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3428 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/ChangeLog4
-rw-r--r--nuttx/Makefile2
-rw-r--r--nuttx/configs/vsn/src/README.txt4
-rw-r--r--nuttx/fs/fat/fs_fat32.c15
-rw-r--r--nuttx/fs/fat/fs_fat32.h2
-rw-r--r--nuttx/fs/fs_closedir.c6
-rw-r--r--nuttx/fs/fs_internal.h93
-rw-r--r--nuttx/fs/fs_mount.c9
-rw-r--r--nuttx/fs/fs_opendir.c7
-rw-r--r--nuttx/fs/fs_readdir.c8
-rw-r--r--nuttx/fs/fs_rewinddir.c8
-rw-r--r--nuttx/fs/fs_seekdir.c12
-rw-r--r--nuttx/fs/fs_telldir.c8
-rw-r--r--nuttx/fs/romfs/fs_romfs.c17
-rw-r--r--nuttx/fs/romfs/fs_romfs.h4
-rw-r--r--nuttx/fs/romfs/fs_romfsutil.c1
-rw-r--r--nuttx/include/apps/apps.h29
-rw-r--r--nuttx/include/nuttx/dirent.h186
-rw-r--r--nuttx/include/nuttx/fs.h12
-rw-r--r--nuttx/include/sys/statfs.h1
-rw-r--r--nuttx/sched/os_bringup.c4
21 files changed, 286 insertions, 146 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 3af9ffeef..5cb96b024 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -1619,4 +1619,8 @@
output PWMs and interrupt logic
* config/vsn/src: added basic support for Sensor Interface (GPIO and
Power Output, and the sif utility program)
+ * fs/ -- Reorgnize header so that file systems can be built outside
+ of the nuttx source tree
+ * apps/namedapp/binfs.c -- Create a tiny filesystem that can be used
+ to show the internal named apps under /bin.
diff --git a/nuttx/Makefile b/nuttx/Makefile
index bcf739940..8a8b44525 100644
--- a/nuttx/Makefile
+++ b/nuttx/Makefile
@@ -149,7 +149,7 @@ LINKLIBS += libxx/liblibxx$(LIBEXT)
endif
# Add library for application support
-# Always compile the framework which includes exec_nuttapp if users
+# Always compile the framework which includes exec_namedapp if users
# or nuttX applications are to be included.
ifneq ($(APPDIR),)
diff --git a/nuttx/configs/vsn/src/README.txt b/nuttx/configs/vsn/src/README.txt
index 81f3ee4e1..4e2d50e0b 100644
--- a/nuttx/configs/vsn/src/README.txt
+++ b/nuttx/configs/vsn/src/README.txt
@@ -12,7 +12,7 @@ Execution starts in the following order:
is set. It must be set for the VSN board.
- boot, performs initial chip and board initialization
- - sched/os_bringup.c then calls either user_start or exec_nuttapp()
+ - sched/os_bringup.c then calls either user_start or exec_namedapp()
with application as set in the .config
@@ -55,4 +55,4 @@ Compile notes
To link-in the sif_main() utility do, in this folder:
- make context TOPDIR=<path to nuttx top dir>
-This will result in registering the application into the nuttapp.
+This will result in registering the application into the namedapp.
diff --git a/nuttx/fs/fat/fs_fat32.c b/nuttx/fs/fat/fs_fat32.c
index b5917d1d5..e109ca75d 100644
--- a/nuttx/fs/fat/fs_fat32.c
+++ b/nuttx/fs/fat/fs_fat32.c
@@ -1,7 +1,7 @@
/****************************************************************************
* fs_fat32.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* References:
@@ -60,6 +60,7 @@
#include <nuttx/fs.h>
#include <nuttx/fat.h>
+#include <nuttx/dirent.h>
#include "fs_internal.h"
#include "fs_fat32.h"
@@ -87,9 +88,9 @@ static int fat_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
static int fat_sync(FAR struct file *filep);
static int fat_opendir(struct inode *mountpt, const char *relpath,
- struct internal_dir_s *dir);
-static int fat_readdir(struct inode *mountpt, struct internal_dir_s *dir);
-static int fat_rewinddir(struct inode *mountpt, struct internal_dir_s *dir);
+ struct fs_dirent_s *dir);
+static int fat_readdir(struct inode *mountpt, struct fs_dirent_s *dir);
+static int fat_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir);
static int fat_bind(FAR struct inode *blkdriver, const void *data,
void **handle);
@@ -1218,7 +1219,7 @@ errout_with_semaphore:
*
****************************************************************************/
-static int fat_opendir(struct inode *mountpt, const char *relpath, struct internal_dir_s *dir)
+static int fat_opendir(struct inode *mountpt, const char *relpath, struct fs_dirent_s *dir)
{
struct fat_mountpt_s *fs;
struct fat_dirinfo_s dirinfo;
@@ -1298,7 +1299,7 @@ errout_with_semaphore:
*
****************************************************************************/
-static int fat_readdir(struct inode *mountpt, struct internal_dir_s *dir)
+static int fat_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
{
struct fat_mountpt_s *fs;
unsigned int dirindex;
@@ -1398,7 +1399,7 @@ errout_with_semaphore:
*
****************************************************************************/
-static int fat_rewinddir(struct inode *mountpt, struct internal_dir_s *dir)
+static int fat_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir)
{
struct fat_mountpt_s *fs;
int ret;
diff --git a/nuttx/fs/fat/fs_fat32.h b/nuttx/fs/fat/fs_fat32.h
index ff3bda433..710417720 100644
--- a/nuttx/fs/fat/fs_fat32.h
+++ b/nuttx/fs/fat/fs_fat32.h
@@ -48,6 +48,8 @@
#include <semaphore.h>
#include <time.h>
+#include <nuttx/dirent.h>
+
/****************************************************************************
* Definitions
****************************************************************************/
diff --git a/nuttx/fs/fs_closedir.c b/nuttx/fs/fs_closedir.c
index c7824477e..bfc4f5249 100644
--- a/nuttx/fs/fs_closedir.c
+++ b/nuttx/fs/fs_closedir.c
@@ -1,7 +1,7 @@
/****************************************************************************
* fs/fs_closedir.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,9 @@
#include <stdlib.h>
#include <dirent.h>
#include <errno.h>
+
#include <nuttx/fs.h>
+#include <nuttx/dirent.h>
#include "fs_internal.h"
@@ -74,7 +76,7 @@
int closedir(FAR DIR *dirp)
{
- struct internal_dir_s *idir = (struct internal_dir_s *)dirp;
+ struct fs_dirent_s *idir = (struct fs_dirent_s *)dirp;
struct inode *inode;
int ret;
diff --git a/nuttx/fs/fs_internal.h b/nuttx/fs/fs_internal.h
index 95e4e71ef..f79715b17 100644
--- a/nuttx/fs/fs_internal.h
+++ b/nuttx/fs/fs_internal.h
@@ -84,99 +84,6 @@
* Public Types
****************************************************************************/
-/* The internal representation of type DIR is just a container for an inode
- * reference, a position, a dirent structure, and file-system-specific
- * information.
- *
- * For the root psuedo-file system, we need retain only the 'next' inode
- * need for the next readdir() operation. We hold a reference on this
- * inode so we know that it will persist until closedir is called.
- */
-
-struct fs_psuedodir_s
-{
- struct inode *fd_next; /* The inode for the next call to readdir() */
-};
-
-#ifndef CONFIG_DISABLE_MOUNTPOINT
-#ifdef CONFIG_FS_FAT
-/* For fat, we need to return the start cluster, current cluster, current
- * sector and current directory index.
- */
-
-struct fs_fatdir_s
-{
- uint32_t fd_startcluster; /* Start cluster number of the directory */
- uint32_t fd_currcluster; /* Current cluster number being read */
- size_t fd_currsector; /* Current sector being read */
- unsigned int fd_index; /* Current index of the directory entry to read */
-};
-#endif /* CONFIG_FS_FAT */
-
-#ifdef CONFIG_FS_ROMFS
-/* For ROMFS, we need to return the offset to the current and start positions
- * of the directory entry being read
- */
-
-struct fs_romfsdir_s
-{
- uint32_t fr_firstoffset; /* Offset to the first entry in the directory */
- uint32_t fr_curroffset; /* Current offset into the directory contents */
-};
-#endif /* CONFIG_FS_ROMFS */
-#endif /* CONFIG_DISABLE_MOUNTPOINT */
-
-struct internal_dir_s
-{
- /* This is the node that was opened by opendir. The type of the inode
- * determines the way that the readdir() operations are performed. For the
- * psuedo root psuedo-file system, it is also used to support rewind.
- *
- * We hold a reference on this inode so we know that it will persist until
- * closedir() is called (although inodes linked to this inode may change).
- */
-
- struct inode *fd_root;
-
- /* At present, only mountpoints require special handling flags */
-
-#ifndef CONFIG_DISABLE_MOUNTPOINT
- unsigned int fd_flags;
-#endif
-
- /* This keeps track of the current directory position for telldir */
-
- off_t fd_position;
-
- /* Retained control information depends on the type of file system that
- * provides is provides the mountpoint. Ideally this information should
- * be hidden behind an opaque, file-system-dependent void *, but we put
- * the private definitions in line here for now to reduce allocations.
- */
-
- union
- {
- /* Private data used by the built-in psuedo-file system */
-
- struct fs_psuedodir_s psuedo;
-
- /* Private data used by other file systems */
-
-#ifndef CONFIG_DISABLE_MOUNTPOINT
-#ifdef CONFIG_FS_FAT
- struct fs_fatdir_s fat;
-#endif
-#ifdef CONFIG_FS_ROMFS
- struct fs_romfsdir_s romfs;
-#endif
-#endif
- } u;
-
- /* In any event, this the actual struct dirent that is returned by readdir */
-
- struct dirent fd_dir; /* Populated when readdir is called */
-};
-
/****************************************************************************
* Global Variables
****************************************************************************/
diff --git a/nuttx/fs/fs_mount.c b/nuttx/fs/fs_mount.c
index aa0128d6f..02317ef19 100644
--- a/nuttx/fs/fs_mount.c
+++ b/nuttx/fs/fs_mount.c
@@ -1,7 +1,7 @@
/****************************************************************************
* fs/fs_mount.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,10 @@
#include <errno.h>
#include <nuttx/fs.h>
+#ifdef CONFIG_APPS_BINDIR
+# include <apps/apps.h>
+#endif
+
#include "fs_internal.h"
/* At least one filesystem must be defined, or this file will not compile.
@@ -88,6 +92,9 @@ static const struct fsmap_t g_fsmap[] =
#ifdef CONFIG_FS_ROMFS
{ "romfs", &romfs_operations },
#endif
+#ifdef CONFIG_APPS_BINDIR
+ { "binfs", &binfs_operations },
+#endif
{ NULL, NULL },
};
diff --git a/nuttx/fs/fs_opendir.c b/nuttx/fs/fs_opendir.c
index 3abdc1b3d..8f287c050 100644
--- a/nuttx/fs/fs_opendir.c
+++ b/nuttx/fs/fs_opendir.c
@@ -1,7 +1,7 @@
/****************************************************************************
* fs/fs_opendir.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -47,6 +47,7 @@
#include <errno.h>
#include <nuttx/fs.h>
+#include <nuttx/dirent.h>
#include "fs_internal.h"
@@ -89,7 +90,7 @@
FAR DIR *opendir(FAR const char *path)
{
FAR struct inode *inode = NULL;
- FAR struct internal_dir_s *dir;
+ FAR struct fs_dirent_s *dir;
FAR const char *relpath;
bool isroot = false;
int ret;
@@ -133,7 +134,7 @@ FAR DIR *opendir(FAR const char *path)
* container.
*/
- dir = (FAR struct internal_dir_s *)zalloc(sizeof(struct internal_dir_s));
+ dir = (FAR struct fs_dirent_s *)zalloc(sizeof(struct fs_dirent_s));
if (!dir)
{
/* Insufficient memory to complete the operation.*/
diff --git a/nuttx/fs/fs_readdir.c b/nuttx/fs/fs_readdir.c
index c966a9858..3be669abb 100644
--- a/nuttx/fs/fs_readdir.c
+++ b/nuttx/fs/fs_readdir.c
@@ -1,7 +1,7 @@
/****************************************************************************
* fs/fs_readdir.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,9 @@
#include <string.h>
#include <dirent.h>
#include <errno.h>
+
#include <nuttx/fs.h>
+#include <nuttx/dirent.h>
#include "fs_internal.h"
@@ -54,7 +56,7 @@
* Name: readpsuedodir
****************************************************************************/
-static inline int readpsuedodir(struct internal_dir_s *idir)
+static inline int readpsuedodir(struct fs_dirent_s *idir)
{
FAR struct inode *prev;
@@ -158,7 +160,7 @@ static inline int readpsuedodir(struct internal_dir_s *idir)
FAR struct dirent *readdir(DIR *dirp)
{
- FAR struct internal_dir_s *idir = (struct internal_dir_s *)dirp;
+ FAR struct fs_dirent_s *idir = (struct fs_dirent_s *)dirp;
#ifndef CONFIG_DISABLE_MOUNTPOINT
struct inode *inode;
#endif
diff --git a/nuttx/fs/fs_rewinddir.c b/nuttx/fs/fs_rewinddir.c
index 171f26399..a53da7725 100644
--- a/nuttx/fs/fs_rewinddir.c
+++ b/nuttx/fs/fs_rewinddir.c
@@ -1,7 +1,7 @@
/****************************************************************************
* fs/fs_rewinddir.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -41,7 +41,9 @@
#include <dirent.h>
#include <errno.h>
+
#include <nuttx/fs.h>
+#include <nuttx/dirent.h>
#include "fs_internal.h"
@@ -53,7 +55,7 @@
* Name: rewindpsuedodir
****************************************************************************/
-static inline void rewindpsuedodir(struct internal_dir_s *idir)
+static inline void rewindpsuedodir(struct fs_dirent_s *idir)
{
struct inode *prev;
@@ -102,7 +104,7 @@ static inline void rewindpsuedodir(struct internal_dir_s *idir)
void rewinddir(FAR DIR *dirp)
{
- struct internal_dir_s *idir = (struct internal_dir_s *)dirp;
+ struct fs_dirent_s *idir = (struct fs_dirent_s *)dirp;
#ifndef CONFIG_DISABLE_MOUNTPOINT
struct inode *inode;
#endif
diff --git a/nuttx/fs/fs_seekdir.c b/nuttx/fs/fs_seekdir.c
index bdbada7b6..6443ecd35 100644
--- a/nuttx/fs/fs_seekdir.c
+++ b/nuttx/fs/fs_seekdir.c
@@ -1,7 +1,7 @@
/****************************************************************************
* fs/fs_seekdir.c
*
- * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -38,10 +38,14 @@
****************************************************************************/
#include <nuttx/config.h>
+
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
+
#include <nuttx/fs.h>
+#include <nuttx/dirent.h>
+
#include "fs_internal.h"
/****************************************************************************
@@ -52,7 +56,7 @@
* Name: seekpsuedodir
****************************************************************************/
-static inline void seekpsuedodir(struct internal_dir_s *idir, off_t offset)
+static inline void seekpsuedodir(struct fs_dirent_s *idir, off_t offset)
{
struct inode *curr;
struct inode *prev;
@@ -110,7 +114,7 @@ static inline void seekpsuedodir(struct internal_dir_s *idir, off_t offset)
****************************************************************************/
#ifndef CONFIG_DISABLE_MOUNTPOINT
-static inline void seekmountptdir(struct internal_dir_s *idir, off_t offset)
+static inline void seekmountptdir(struct fs_dirent_s *idir, off_t offset)
{
struct inode *inode;
off_t pos;
@@ -197,7 +201,7 @@ static inline void seekmountptdir(struct internal_dir_s *idir, off_t offset)
void seekdir(FAR DIR *dirp, off_t offset)
{
- struct internal_dir_s *idir = (struct internal_dir_s *)dirp;
+ struct fs_dirent_s *idir = (struct fs_dirent_s *)dirp;
/* Sanity checks */
diff --git a/nuttx/fs/fs_telldir.c b/nuttx/fs/fs_telldir.c
index 67eeaf175..f8fd3b92c 100644
--- a/nuttx/fs/fs_telldir.c
+++ b/nuttx/fs/fs_telldir.c
@@ -1,7 +1,7 @@
/****************************************************************************
* fs/fs_telldir.c
*
- * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -38,10 +38,14 @@
****************************************************************************/
#include <nuttx/config.h>
+
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
+
#include <nuttx/fs.h>
+#include <nuttx/dirent.h>
+
#include "fs_internal.h"
/****************************************************************************
@@ -74,7 +78,7 @@
off_t telldir(FAR DIR *dirp)
{
- struct internal_dir_s *idir = (struct internal_dir_s *)dirp;
+ struct fs_dirent_s *idir = (struct fs_dirent_s *)dirp;
if (!idir || !idir->fd_root)
{
diff --git a/nuttx/fs/romfs/fs_romfs.c b/nuttx/fs/romfs/fs_romfs.c
index 7abfb4b14..b2ffffaaf 100644
--- a/nuttx/fs/romfs/fs_romfs.c
+++ b/nuttx/fs/romfs/fs_romfs.c
@@ -1,7 +1,7 @@
/****************************************************************************
* rm/romfs/fs_romfs.h
*
- * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* References: Linux/Documentation/filesystems/romfs.txt
@@ -58,6 +58,7 @@
#include <nuttx/fs.h>
#include <nuttx/ioctl.h>
+#include <nuttx/dirent.h>
#include "fs_romfs.h"
@@ -77,9 +78,9 @@ static off_t romfs_seek(FAR struct file *filep, off_t offset, int whence);
static int romfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
static int romfs_opendir(struct inode *mountpt, const char *relpath,
- struct internal_dir_s *dir);
-static int romfs_readdir(struct inode *mountpt, struct internal_dir_s *dir);
-static int romfs_rewinddir(struct inode *mountpt, struct internal_dir_s *dir);
+ struct fs_dirent_s *dir);
+static int romfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir);
+static int romfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir);
static int romfs_bind(FAR struct inode *blkdriver, const void *data,
void **handle);
@@ -589,7 +590,7 @@ static int romfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
****************************************************************************/
static int romfs_opendir(struct inode *mountpt, const char *relpath,
- struct internal_dir_s *dir)
+ struct fs_dirent_s *dir)
{
struct romfs_mountpt_s *rm;
struct romfs_dirinfo_s dirinfo;
@@ -653,7 +654,7 @@ errout_with_semaphore:
*
****************************************************************************/
-static int romfs_readdir(struct inode *mountpt, struct internal_dir_s *dir)
+static int romfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
{
struct romfs_mountpt_s *rm;
uint32_t linkoffset;
@@ -748,7 +749,7 @@ errout_with_semaphore:
*
****************************************************************************/
-static int romfs_rewinddir(struct inode *mountpt, struct internal_dir_s *dir)
+static int romfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir)
{
struct romfs_mountpt_s *rm;
int ret;
@@ -889,7 +890,6 @@ static int romfs_unbind(void *handle, FAR struct inode **blkdriver)
/* Check if there are sill any files opened on the filesystem. */
- ret = OK; /* Assume success */
romfs_semtake(rm);
if (rm->rm_head)
{
@@ -934,6 +934,7 @@ static int romfs_unbind(void *handle, FAR struct inode **blkdriver)
sem_destroy(&rm->rm_sem);
free(rm);
+ return OK;
}
romfs_semgive(rm);
diff --git a/nuttx/fs/romfs/fs_romfs.h b/nuttx/fs/romfs/fs_romfs.h
index b734f094f..111006788 100644
--- a/nuttx/fs/romfs/fs_romfs.h
+++ b/nuttx/fs/romfs/fs_romfs.h
@@ -1,7 +1,7 @@
/****************************************************************************
* fs/romfs/fs_romfs.h
*
- * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* References: Linux/Documentation/filesystems/romfs.txt
@@ -47,6 +47,8 @@
#include <stdint.h>
#include <stdbool.h>
+#include <nuttx/dirent.h>
+
#include "../fs_internal.h"
/****************************************************************************
diff --git a/nuttx/fs/romfs/fs_romfsutil.c b/nuttx/fs/romfs/fs_romfsutil.c
index ee2eb8f16..d441c0c8b 100644
--- a/nuttx/fs/romfs/fs_romfsutil.c
+++ b/nuttx/fs/romfs/fs_romfsutil.c
@@ -52,6 +52,7 @@
#include <debug.h>
#include <nuttx/ioctl.h>
+#include <nuttx/dirent.h>
#include "fs_romfs.h"
diff --git a/nuttx/include/apps/apps.h b/nuttx/include/apps/apps.h
index d8f8681c2..866db8e29 100644
--- a/nuttx/include/apps/apps.h
+++ b/nuttx/include/apps/apps.h
@@ -52,7 +52,7 @@
* Public Types
****************************************************************************/
-struct nuttapp_s
+struct namedapp_s
{
const char *name; /* Invocation name and as seen under /sbin/ */
int priority; /* Use: SCHED_PRIORITY_DEFAULT */
@@ -61,6 +61,19 @@ struct nuttapp_s
};
/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/* The "bindir" is file system that supports access to the named applications.
+ * It is typically mounted under /bin.
+ */
+
+#ifdef CONFIG_APPS_BINDIR
+struct mountpt_operations;
+extern const struct mountpt_operations binfs_operations;
+#endif
+
+/****************************************************************************
* Public Functions
****************************************************************************/
@@ -73,7 +86,7 @@ extern "C" {
#endif
/****************************************************************************
- * Name: check for availability of builtin NuttX application
+ * Name: namedapp_isavail
*
* Description:
* Checks for availabiliy of application registerred during compile time.
@@ -88,10 +101,10 @@ extern "C" {
*
****************************************************************************/
-EXTERN int nuttapp_isavail(FAR const char *appname);
+EXTERN int namedapp_isavail(FAR const char *appname);
/****************************************************************************
- * Name: get name of built-in application
+ * Name: namedapp_getname
*
* Description:
* Returns pointer to a name of built-in application pointed by the
@@ -106,13 +119,13 @@ EXTERN int nuttapp_isavail(FAR const char *appname);
*
****************************************************************************/
-EXTERN const char * nuttapp_getname(int index);
+EXTERN const char *namedapp_getname(int index);
/****************************************************************************
- * Name: execute builtin NuttX application
+ * Name: exec_namedapp
*
* Description:
- * Executes builtin application registerred during compile time.
+ * Executes builtin named application registered during compile time.
* New application is run in a separate task context (and thread).
*
* Input Parameter:
@@ -126,7 +139,7 @@ EXTERN const char * nuttapp_getname(int index);
*
****************************************************************************/
-EXTERN int exec_nuttapp(FAR const char *appname, FAR const char *argv[]);
+EXTERN int exec_namedapp(FAR const char *appname, FAR const char *argv[]);
#undef EXTERN
#if defined(__cplusplus)
diff --git a/nuttx/include/nuttx/dirent.h b/nuttx/include/nuttx/dirent.h
new file mode 100644
index 000000000..27835a4b2
--- /dev/null
+++ b/nuttx/include/nuttx/dirent.h
@@ -0,0 +1,186 @@
+/****************************************************************************
+ * include/nuttx/dirent.h
+ *
+ * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_NUTTX_DIRENT_H
+#define __INCLUDE_NUTTX_DIRENT_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <dirent.h>
+
+#include <nuttx/fs.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/* The internal representation of type DIR is just a container for an inode
+ * reference, a position, a dirent structure, and file-system-specific
+ * information.
+ *
+ * For the root psuedo-file system, we need retain only the 'next' inode
+ * need for the next readdir() operation. We hold a reference on this
+ * inode so we know that it will persist until closedir is called.
+ */
+
+struct fs_psuedodir_s
+{
+ struct inode *fd_next; /* The inode for the next call to readdir() */
+};
+
+#ifndef CONFIG_DISABLE_MOUNTPOINT
+#ifdef CONFIG_FS_FAT
+/* For fat, we need to return the start cluster, current cluster, current
+ * sector and current directory index.
+ */
+
+struct fs_fatdir_s
+{
+ uint32_t fd_startcluster; /* Start cluster number of the directory */
+ uint32_t fd_currcluster; /* Current cluster number being read */
+ size_t fd_currsector; /* Current sector being read */
+ unsigned int fd_index; /* Current index of the directory entry to read */
+};
+#endif /* CONFIG_FS_FAT */
+
+#ifdef CONFIG_FS_ROMFS
+/* For ROMFS, we need to return the offset to the current and start positions
+ * of the directory entry being read
+ */
+
+struct fs_romfsdir_s
+{
+ uint32_t fr_firstoffset; /* Offset to the first entry in the directory */
+ uint32_t fr_curroffset; /* Current offset into the directory contents */
+};
+#endif /* CONFIG_FS_ROMFS */
+
+#ifdef CONFIG_APPS_BINDIR
+/* The apps/ pseudo bin/ directory. The state value is simply an index */
+
+struct fs_binfsdir_s
+{
+ unsigned int fb_index; /* Index to the next named entry point */
+};
+#endif
+#endif /* CONFIG_DISABLE_MOUNTPOINT */
+
+struct fs_dirent_s
+{
+ /* This is the node that was opened by opendir. The type of the inode
+ * determines the way that the readdir() operations are performed. For the
+ * psuedo root psuedo-file system, it is also used to support rewind.
+ *
+ * We hold a reference on this inode so we know that it will persist until
+ * closedir() is called (although inodes linked to this inode may change).
+ */
+
+ struct inode *fd_root;
+
+ /* At present, only mountpoints require special handling flags */
+
+#ifndef CONFIG_DISABLE_MOUNTPOINT
+ unsigned int fd_flags;
+#endif
+
+ /* This keeps track of the current directory position for telldir */
+
+ off_t fd_position;
+
+ /* Retained control information depends on the type of file system that
+ * provides is provides the mountpoint. Ideally this information should
+ * be hidden behind an opaque, file-system-dependent void *, but we put
+ * the private definitions in line here for now to reduce allocations.
+ */
+
+ union
+ {
+ /* Private data used by the built-in psuedo-file system */
+
+ struct fs_psuedodir_s psuedo;
+
+ /* Private data used by other file systems */
+
+#ifndef CONFIG_DISABLE_MOUNTPOINT
+#ifdef CONFIG_FS_FAT
+ struct fs_fatdir_s fat;
+#endif
+#ifdef CONFIG_FS_ROMFS
+ struct fs_romfsdir_s romfs;
+#endif
+#ifdef CONFIG_APPS_BINDIR
+ struct fs_binfsdir_s binfs;
+#endif
+#endif
+ } u;
+
+ /* In any event, this the actual struct dirent that is returned by readdir */
+
+ struct dirent fd_dir; /* Populated when readdir is called */
+};
+
+/****************************************************************************
+ * Global Variables
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C" {
+#else
+#define EXTERN extern
+#endif
+
+#undef EXTERN
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __INCLUDE_NUTTX_DIRENT_H */
+
diff --git a/nuttx/include/nuttx/fs.h b/nuttx/include/nuttx/fs.h
index 7fe925324..02c40121e 100644
--- a/nuttx/include/nuttx/fs.h
+++ b/nuttx/include/nuttx/fs.h
@@ -1,7 +1,7 @@
/****************************************************************************
* include/nuttx/fs.h
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -124,7 +124,7 @@ struct block_operations
*/
struct inode;
-struct internal_dir_s;
+struct fs_dirent_s;
struct stat;
struct statfs;
struct mountpt_operations
@@ -160,10 +160,10 @@ struct mountpt_operations
/* Directory operations */
- int (*opendir)(FAR struct inode *mountpt, FAR const char *relpath, FAR struct internal_dir_s *dir);
- int (*closedir)(FAR struct inode *mountpt, FAR struct internal_dir_s *dir);
- int (*readdir)(FAR struct inode *mountpt, FAR struct internal_dir_s *dir);
- int (*rewinddir)(FAR struct inode *mountpt, FAR struct internal_dir_s *dir);
+ int (*opendir)(FAR struct inode *mountpt, FAR const char *relpath, FAR struct fs_dirent_s *dir);
+ int (*closedir)(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir);
+ int (*readdir)(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir);
+ int (*rewinddir)(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir);
/* General volume-related mountpoint operations: */
diff --git a/nuttx/include/sys/statfs.h b/nuttx/include/sys/statfs.h
index fb9654b08..9c7ee26e5 100644
--- a/nuttx/include/sys/statfs.h
+++ b/nuttx/include/sys/statfs.h
@@ -95,6 +95,7 @@
#define XENIX_SUPER_MAGIC 0x012FF7B4
#define XFS_SUPER_MAGIC 0x58465342
#define _XIAFS_SUPER_MAGIC 0x012FD16D
+#define BINFS_MAGIC 0x4242
/****************************************************************************
* Type Definitions
diff --git a/nuttx/sched/os_bringup.c b/nuttx/sched/os_bringup.c
index dd413277a..38f9be51d 100644
--- a/nuttx/sched/os_bringup.c
+++ b/nuttx/sched/os_bringup.c
@@ -157,11 +157,11 @@ int os_bringup(void)
svdbg("Starting init thread\n");
#ifdef CONFIG_BUILTIN_APP_START
- /* Start the built-in application, passing an "init" argument, so that
+ /* Start the built-in named application, passing an "init" argument, so that
* application can distinguish different run-levels
*/
- init_taskid = exec_nuttapp(CONFIG_BUILTIN_APP_START, argv);
+ init_taskid = exec_namedapp(CONFIG_BUILTIN_APP_START, argv);
#else
/* Start the default application at user_start() */