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
This commit is contained in:
patacongo
2011-03-28 00:05:58 +00:00
parent 39bbebdce9
commit 7b69f1af91
21 changed files with 286 additions and 146 deletions
+4
View File
@@ -1619,4 +1619,8 @@
output PWMs and interrupt logic output PWMs and interrupt logic
* config/vsn/src: added basic support for Sensor Interface (GPIO and * config/vsn/src: added basic support for Sensor Interface (GPIO and
Power Output, and the sif utility program) 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.
+1 -1
View File
@@ -149,7 +149,7 @@ LINKLIBS += libxx/liblibxx$(LIBEXT)
endif endif
# Add library for application support # 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. # or nuttX applications are to be included.
ifneq ($(APPDIR),) ifneq ($(APPDIR),)
+2 -2
View File
@@ -12,7 +12,7 @@ Execution starts in the following order:
is set. It must be set for the VSN board. is set. It must be set for the VSN board.
- boot, performs initial chip and board initialization - 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 with application as set in the .config
@@ -55,4 +55,4 @@ Compile notes
To link-in the sif_main() utility do, in this folder: To link-in the sif_main() utility do, in this folder:
- make context TOPDIR=<path to nuttx top dir> - 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.
+8 -7
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* fs_fat32.c * 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> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* References: * References:
@@ -60,6 +60,7 @@
#include <nuttx/fs.h> #include <nuttx/fs.h>
#include <nuttx/fat.h> #include <nuttx/fat.h>
#include <nuttx/dirent.h>
#include "fs_internal.h" #include "fs_internal.h"
#include "fs_fat32.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_sync(FAR struct file *filep);
static int fat_opendir(struct inode *mountpt, const char *relpath, static int fat_opendir(struct inode *mountpt, const char *relpath,
struct internal_dir_s *dir); struct fs_dirent_s *dir);
static int fat_readdir(struct inode *mountpt, struct internal_dir_s *dir); static int fat_readdir(struct inode *mountpt, struct fs_dirent_s *dir);
static int fat_rewinddir(struct inode *mountpt, struct internal_dir_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, static int fat_bind(FAR struct inode *blkdriver, const void *data,
void **handle); 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_mountpt_s *fs;
struct fat_dirinfo_s dirinfo; 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; struct fat_mountpt_s *fs;
unsigned int dirindex; 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; struct fat_mountpt_s *fs;
int ret; int ret;
+2
View File
@@ -48,6 +48,8 @@
#include <semaphore.h> #include <semaphore.h>
#include <time.h> #include <time.h>
#include <nuttx/dirent.h>
/**************************************************************************** /****************************************************************************
* Definitions * Definitions
****************************************************************************/ ****************************************************************************/
+4 -2
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* fs/fs_closedir.c * 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> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
#include <nuttx/fs.h> #include <nuttx/fs.h>
#include <nuttx/dirent.h>
#include "fs_internal.h" #include "fs_internal.h"
@@ -74,7 +76,7 @@
int closedir(FAR DIR *dirp) 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; struct inode *inode;
int ret; int ret;
-93
View File
@@ -84,99 +84,6 @@
* Public Types * 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 * Global Variables
****************************************************************************/ ****************************************************************************/
+8 -1
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* fs/fs_mount.c * 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> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,10 @@
#include <errno.h> #include <errno.h>
#include <nuttx/fs.h> #include <nuttx/fs.h>
#ifdef CONFIG_APPS_BINDIR
# include <apps/apps.h>
#endif
#include "fs_internal.h" #include "fs_internal.h"
/* At least one filesystem must be defined, or this file will not compile. /* At least one filesystem must be defined, or this file will not compile.
@@ -87,6 +91,9 @@ static const struct fsmap_t g_fsmap[] =
#endif #endif
#ifdef CONFIG_FS_ROMFS #ifdef CONFIG_FS_ROMFS
{ "romfs", &romfs_operations }, { "romfs", &romfs_operations },
#endif
#ifdef CONFIG_APPS_BINDIR
{ "binfs", &binfs_operations },
#endif #endif
{ NULL, NULL }, { NULL, NULL },
}; };
+4 -3
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* fs/fs_opendir.c * 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> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -47,6 +47,7 @@
#include <errno.h> #include <errno.h>
#include <nuttx/fs.h> #include <nuttx/fs.h>
#include <nuttx/dirent.h>
#include "fs_internal.h" #include "fs_internal.h"
@@ -89,7 +90,7 @@
FAR DIR *opendir(FAR const char *path) FAR DIR *opendir(FAR const char *path)
{ {
FAR struct inode *inode = NULL; FAR struct inode *inode = NULL;
FAR struct internal_dir_s *dir; FAR struct fs_dirent_s *dir;
FAR const char *relpath; FAR const char *relpath;
bool isroot = false; bool isroot = false;
int ret; int ret;
@@ -133,7 +134,7 @@ FAR DIR *opendir(FAR const char *path)
* container. * 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) if (!dir)
{ {
/* Insufficient memory to complete the operation.*/ /* Insufficient memory to complete the operation.*/
+5 -3
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* fs/fs_readdir.c * 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> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,9 @@
#include <string.h> #include <string.h>
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
#include <nuttx/fs.h> #include <nuttx/fs.h>
#include <nuttx/dirent.h>
#include "fs_internal.h" #include "fs_internal.h"
@@ -54,7 +56,7 @@
* Name: readpsuedodir * Name: readpsuedodir
****************************************************************************/ ****************************************************************************/
static inline int readpsuedodir(struct internal_dir_s *idir) static inline int readpsuedodir(struct fs_dirent_s *idir)
{ {
FAR struct inode *prev; 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 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 #ifndef CONFIG_DISABLE_MOUNTPOINT
struct inode *inode; struct inode *inode;
#endif #endif
+5 -3
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* fs/fs_rewinddir.c * 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> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -41,7 +41,9 @@
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
#include <nuttx/fs.h> #include <nuttx/fs.h>
#include <nuttx/dirent.h>
#include "fs_internal.h" #include "fs_internal.h"
@@ -53,7 +55,7 @@
* Name: rewindpsuedodir * Name: rewindpsuedodir
****************************************************************************/ ****************************************************************************/
static inline void rewindpsuedodir(struct internal_dir_s *idir) static inline void rewindpsuedodir(struct fs_dirent_s *idir)
{ {
struct inode *prev; struct inode *prev;
@@ -102,7 +104,7 @@ static inline void rewindpsuedodir(struct internal_dir_s *idir)
void rewinddir(FAR DIR *dirp) 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 #ifndef CONFIG_DISABLE_MOUNTPOINT
struct inode *inode; struct inode *inode;
#endif #endif
+8 -4
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* fs/fs_seekdir.c * 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> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -38,10 +38,14 @@
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
#include <nuttx/fs.h> #include <nuttx/fs.h>
#include <nuttx/dirent.h>
#include "fs_internal.h" #include "fs_internal.h"
/**************************************************************************** /****************************************************************************
@@ -52,7 +56,7 @@
* Name: seekpsuedodir * 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 *curr;
struct inode *prev; struct inode *prev;
@@ -110,7 +114,7 @@ static inline void seekpsuedodir(struct internal_dir_s *idir, off_t offset)
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_DISABLE_MOUNTPOINT #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; struct inode *inode;
off_t pos; 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) 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 */ /* Sanity checks */
+6 -2
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* fs/fs_telldir.c * 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> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -38,10 +38,14 @@
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
#include <sys/types.h> #include <sys/types.h>
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
#include <nuttx/fs.h> #include <nuttx/fs.h>
#include <nuttx/dirent.h>
#include "fs_internal.h" #include "fs_internal.h"
/**************************************************************************** /****************************************************************************
@@ -74,7 +78,7 @@
off_t telldir(FAR DIR *dirp) 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) if (!idir || !idir->fd_root)
{ {
+9 -8
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* rm/romfs/fs_romfs.h * 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> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* References: Linux/Documentation/filesystems/romfs.txt * References: Linux/Documentation/filesystems/romfs.txt
@@ -58,6 +58,7 @@
#include <nuttx/fs.h> #include <nuttx/fs.h>
#include <nuttx/ioctl.h> #include <nuttx/ioctl.h>
#include <nuttx/dirent.h>
#include "fs_romfs.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_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
static int romfs_opendir(struct inode *mountpt, const char *relpath, static int romfs_opendir(struct inode *mountpt, const char *relpath,
struct internal_dir_s *dir); struct fs_dirent_s *dir);
static int romfs_readdir(struct inode *mountpt, struct internal_dir_s *dir); static int romfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir);
static int romfs_rewinddir(struct inode *mountpt, struct internal_dir_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, static int romfs_bind(FAR struct inode *blkdriver, const void *data,
void **handle); 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, 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_mountpt_s *rm;
struct romfs_dirinfo_s dirinfo; 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; struct romfs_mountpt_s *rm;
uint32_t linkoffset; 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; struct romfs_mountpt_s *rm;
int ret; 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. */ /* Check if there are sill any files opened on the filesystem. */
ret = OK; /* Assume success */
romfs_semtake(rm); romfs_semtake(rm);
if (rm->rm_head) if (rm->rm_head)
{ {
@@ -934,6 +934,7 @@ static int romfs_unbind(void *handle, FAR struct inode **blkdriver)
sem_destroy(&rm->rm_sem); sem_destroy(&rm->rm_sem);
free(rm); free(rm);
return OK;
} }
romfs_semgive(rm); romfs_semgive(rm);
+3 -1
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* fs/romfs/fs_romfs.h * 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> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* References: Linux/Documentation/filesystems/romfs.txt * References: Linux/Documentation/filesystems/romfs.txt
@@ -47,6 +47,8 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <nuttx/dirent.h>
#include "../fs_internal.h" #include "../fs_internal.h"
/**************************************************************************** /****************************************************************************
+1
View File
@@ -52,6 +52,7 @@
#include <debug.h> #include <debug.h>
#include <nuttx/ioctl.h> #include <nuttx/ioctl.h>
#include <nuttx/dirent.h>
#include "fs_romfs.h" #include "fs_romfs.h"
+21 -8
View File
@@ -52,7 +52,7 @@
* Public Types * Public Types
****************************************************************************/ ****************************************************************************/
struct nuttapp_s struct namedapp_s
{ {
const char *name; /* Invocation name and as seen under /sbin/ */ const char *name; /* Invocation name and as seen under /sbin/ */
int priority; /* Use: SCHED_PRIORITY_DEFAULT */ int priority; /* Use: SCHED_PRIORITY_DEFAULT */
@@ -60,6 +60,19 @@ struct nuttapp_s
main_t main; /* Entry point: main(int argc, char *argv[]) */ main_t main; /* Entry point: main(int argc, char *argv[]) */
}; };
/****************************************************************************
* 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 * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -73,7 +86,7 @@ extern "C" {
#endif #endif
/**************************************************************************** /****************************************************************************
* Name: check for availability of builtin NuttX application * Name: namedapp_isavail
* *
* Description: * Description:
* Checks for availabiliy of application registerred during compile time. * 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: * Description:
* Returns pointer to a name of built-in application pointed by the * 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: * 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). * New application is run in a separate task context (and thread).
* *
* Input Parameter: * 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 #undef EXTERN
#if defined(__cplusplus) #if defined(__cplusplus)
+186
View File
@@ -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 */
+6 -6
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* include/nuttx/fs.h * 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> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -124,7 +124,7 @@ struct block_operations
*/ */
struct inode; struct inode;
struct internal_dir_s; struct fs_dirent_s;
struct stat; struct stat;
struct statfs; struct statfs;
struct mountpt_operations struct mountpt_operations
@@ -160,10 +160,10 @@ struct mountpt_operations
/* Directory operations */ /* Directory operations */
int (*opendir)(FAR struct inode *mountpt, FAR const char *relpath, 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 internal_dir_s *dir); int (*closedir)(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir);
int (*readdir)(FAR struct inode *mountpt, FAR struct internal_dir_s *dir); int (*readdir)(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir);
int (*rewinddir)(FAR struct inode *mountpt, FAR struct internal_dir_s *dir); int (*rewinddir)(FAR struct inode *mountpt, FAR struct fs_dirent_s *dir);
/* General volume-related mountpoint operations: */ /* General volume-related mountpoint operations: */
+1
View File
@@ -95,6 +95,7 @@
#define XENIX_SUPER_MAGIC 0x012FF7B4 #define XENIX_SUPER_MAGIC 0x012FF7B4
#define XFS_SUPER_MAGIC 0x58465342 #define XFS_SUPER_MAGIC 0x58465342
#define _XIAFS_SUPER_MAGIC 0x012FD16D #define _XIAFS_SUPER_MAGIC 0x012FD16D
#define BINFS_MAGIC 0x4242
/**************************************************************************** /****************************************************************************
* Type Definitions * Type Definitions
+2 -2
View File
@@ -157,11 +157,11 @@ int os_bringup(void)
svdbg("Starting init thread\n"); svdbg("Starting init thread\n");
#ifdef CONFIG_BUILTIN_APP_START #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 * 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 #else
/* Start the default application at user_start() */ /* Start the default application at user_start() */