From cc3614dfe8f67033dca8c7c1f40c3367a0d3ca06 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 14 Jan 2013 19:22:32 +0000 Subject: Finish dup logic for open files; fix bug in sigtimedwait(), would return wrong signo value if the signal was already pending git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5517 42af7a65-404d-4744-a932-0658087f49c3 --- apps/builtin/Kconfig | 15 +++++++++++++++ apps/builtin/binfs.c | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/builtin/Kconfig b/apps/builtin/Kconfig index 8310e6df9..5b262734d 100644 --- a/apps/builtin/Kconfig +++ b/apps/builtin/Kconfig @@ -12,4 +12,19 @@ config BUILTIN to support built-in applications in the NuttShell (NSH). if BUILTIN + + config APPS_BINDIR + bool "BINFS File System" + default n + ---help--- + The BINFS file system is current just a toy. The BINFS may, for example, + be mount at /bin. Then all of the built-in applications will appear as + executable file in /bin if you list them from NSH like: + + nsh> ls -l /bin + + At present, the BINFS supports nothing more than that. It is planned, + however, to support execution of the builtin applications from BINFS as + well (via a binfmt/ loader). However, that is down the road. + endif diff --git a/apps/builtin/binfs.c b/apps/builtin/binfs.c index 4159c9663..365021c7f 100644 --- a/apps/builtin/binfs.c +++ b/apps/builtin/binfs.c @@ -85,6 +85,8 @@ static int binfs_close(FAR struct file *filep); static ssize_t binfs_read(FAR struct file *filep, char *buffer, size_t buflen); static int binfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg); +static int binfs_dup(FAR const struct file *oldp, FAR struct file *newp); + static int binfs_opendir(struct inode *mountpt, const char *relpath, struct fs_dirent_s *dir); static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir); @@ -120,7 +122,7 @@ const struct mountpt_operations binfs_operations = binfs_ioctl, /* ioctl */ NULL, /* sync */ - NULL, /* dup */ + binfs_dup, /* dup */ binfs_opendir, /* opendir */ NULL, /* closedir */ @@ -296,6 +298,39 @@ static int binfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg) return -ENOTTY; } +/**************************************************************************** + * Name: binfs_dup + * + * Description: + * Duplicate open file data in the new file structure. + * + ****************************************************************************/ + +static int binfs_dup(FAR const struct file *oldp, FAR struct file *newp) +{ + struct binfs_state_s *bm; + int ret = -ENOSYS; + + fvdbg("Dup %p->%p\n", oldp, newp); + + /* Sanity checks */ + + DEBUGASSERT(oldp->f_priv == NULL && oldp->f_inode != NULL); + + /* mountpoint private data from the inode reference from the file + * structure + */ + + bm = (struct binfs_state_s*)oldp->f_inode->i_private; + DEBUGASSERT(bm != NULL); + + /* Opening of elements within the pseudo-file system is not yet supported + * and, hence, neither is dup'ing the opened file. + */ + + return ret; +} + /**************************************************************************** * Name: binfs_opendir * -- cgit v1.2.3