diff options
Diffstat (limited to 'nuttx/fs')
-rw-r--r-- | nuttx/fs/fat/fs_fat32.c | 15 | ||||
-rw-r--r-- | nuttx/fs/fat/fs_fat32.h | 2 | ||||
-rw-r--r-- | nuttx/fs/fs_closedir.c | 6 | ||||
-rw-r--r-- | nuttx/fs/fs_internal.h | 93 | ||||
-rw-r--r-- | nuttx/fs/fs_mount.c | 9 | ||||
-rw-r--r-- | nuttx/fs/fs_opendir.c | 7 | ||||
-rw-r--r-- | nuttx/fs/fs_readdir.c | 8 | ||||
-rw-r--r-- | nuttx/fs/fs_rewinddir.c | 8 | ||||
-rw-r--r-- | nuttx/fs/fs_seekdir.c | 12 | ||||
-rw-r--r-- | nuttx/fs/fs_telldir.c | 8 | ||||
-rw-r--r-- | nuttx/fs/romfs/fs_romfs.c | 17 | ||||
-rw-r--r-- | nuttx/fs/romfs/fs_romfs.h | 4 | ||||
-rw-r--r-- | nuttx/fs/romfs/fs_romfsutil.c | 1 |
13 files changed, 63 insertions, 127 deletions
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" |