diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-03-28 00:05:58 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-03-28 00:05:58 +0000 |
commit | 931bd2b8661c8ed4c923220490cbebc56d6c0065 (patch) | |
tree | 744ba3d223b0b158d74f077328ca226a19407d28 /nuttx/include | |
parent | a67921192b48c4b0dcc5ac34d180c710ec6ea5d3 (diff) | |
download | px4-nuttx-931bd2b8661c8ed4c923220490cbebc56d6c0065.tar.gz px4-nuttx-931bd2b8661c8ed4c923220490cbebc56d6c0065.tar.bz2 px4-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/include')
-rw-r--r-- | nuttx/include/apps/apps.h | 29 | ||||
-rw-r--r-- | nuttx/include/nuttx/dirent.h | 186 | ||||
-rw-r--r-- | nuttx/include/nuttx/fs.h | 12 | ||||
-rw-r--r-- | nuttx/include/sys/statfs.h | 1 |
4 files changed, 214 insertions, 14 deletions
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 |