forked from Archive/PX4-Autopilot
Add support for dup2'ing files. Infrastructure and ROMFS done. Still need FAT, BINFS, NXFFS, and NFS
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5516 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
b3f3dd123c
commit
930f9a1351
|
@ -466,3 +466,4 @@
|
|||
death-of-child signals (SIGCHLD).
|
||||
* apps/examples/ostest/waitpid.c: Add a test for waitpid(), waitid(),
|
||||
and wait().
|
||||
* builtin/binfs.c: Add hooks for dup() method (not implemented).
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* apps/builtin/binfs.c
|
||||
*
|
||||
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -118,7 +118,9 @@ const struct mountpt_operations binfs_operations =
|
|||
NULL, /* write */
|
||||
NULL, /* seek */
|
||||
binfs_ioctl, /* ioctl */
|
||||
|
||||
NULL, /* sync */
|
||||
NULL, /* dup */
|
||||
|
||||
binfs_opendir, /* opendir */
|
||||
NULL, /* closedir */
|
||||
|
|
|
@ -89,15 +89,6 @@
|
|||
# error "You must not disable loadable modules via CONFIG_BINFMT_DISABLE in your configuration file"
|
||||
#endif
|
||||
|
||||
/* The redirection test does not work. This is because it tries to redirect
|
||||
* file as stdin. That won't work now because (1) the file descriptors must
|
||||
* be dup'ed when the new task is created, and (2) there is no support in
|
||||
* place for dup'ing file descriptors for anything other than sockets and
|
||||
* character drivers. This is a bug!
|
||||
*/
|
||||
|
||||
#define FILE_DUP_BUG 1
|
||||
|
||||
/* Describe the ROMFS file system */
|
||||
|
||||
#define SECTORSIZE 512
|
||||
|
@ -147,9 +138,7 @@ static unsigned int g_mmstep; /* Memory Usage at beginning of test step */
|
|||
|
||||
static const char delimiter[] =
|
||||
"****************************************************************************";
|
||||
#ifndef FILE_DUP_BUG
|
||||
static const char g_redirect[] = "redirect";
|
||||
#endif
|
||||
static const char g_hello[] = "hello";
|
||||
static const char g_data[] = "testdata.txt";
|
||||
|
||||
|
@ -375,8 +364,6 @@ int spawn_main(int argc, char *argv[])
|
|||
* Case 2: Simple program with redirection of stdin to a file input
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef FILE_DUP_BUG
|
||||
|
||||
/* Output a seperated so that we can clearly discriminate the output of
|
||||
* this program from the others.
|
||||
*/
|
||||
|
@ -463,7 +450,6 @@ int spawn_main(int argc, char *argv[])
|
|||
posix_spawnattr_dump(&attr);
|
||||
|
||||
mm_update(&g_mmstep, "after file_action/attr destruction");
|
||||
#endif
|
||||
|
||||
/* Clean-up */
|
||||
|
||||
|
|
|
@ -3929,3 +3929,14 @@
|
|||
need to.
|
||||
* sched/sched_waitid.c and sched_wait.c: Add support for waitid()
|
||||
and wait(). See issues with waitpid() above.
|
||||
* include/nuttx/fs/fs.h and fs/fs_files.c: Add a dup() method to
|
||||
the struct mountpt_operations. When dup'ing a file that resides
|
||||
on a mounted volume, let the file system's dup() method do the
|
||||
work.
|
||||
* fs/romfs/fs_romfs.c: Implemented the dup() method for the ROMFS
|
||||
file system.
|
||||
* fs/fat/fs_fat32.c, fs/nxffs/nxffs_initialize, and
|
||||
fs/nfs/nfs_vfsops.c: Add hooks for dup() method (not yet
|
||||
implemented).
|
||||
* fs/romfs: Remove the rf_open flag. It looks good, but actually
|
||||
does nothing.
|
||||
|
|
47
nuttx/TODO
47
nuttx/TODO
|
@ -1,4 +1,4 @@
|
|||
NuttX TODO List (Last updated January 11, 2013)
|
||||
NuttX TODO List (Last updated January 13, 2013)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This file summarizes known NuttX bugs, limitations, inconsistencies with
|
||||
|
@ -8,7 +8,7 @@ nuttx/
|
|||
|
||||
(10) Task/Scheduler (sched/)
|
||||
(1) Memory Managment (mm/)
|
||||
(2) Signals (sched/, arch/)
|
||||
(3) Signals (sched/, arch/)
|
||||
(2) pthreads (sched/)
|
||||
(2) C++ Support
|
||||
(6) Binary loaders (binfmt/)
|
||||
|
@ -99,13 +99,6 @@ o Task/Scheduler (sched/)
|
|||
someone gets motivated and drives the change.
|
||||
Priority: Low
|
||||
|
||||
Title: posix_spawn()
|
||||
Description: This would be a good interface to add to NuttX. It is really
|
||||
just a re-packaging of the existing, non-standard NuttX exec()
|
||||
function.
|
||||
Status: Open. There are no plans to implement this capabilitiey now.
|
||||
Priority: Medium low.
|
||||
|
||||
Title: pause() NON-COMPLIANCE
|
||||
Description: In the POSIX description of this function is the pause() function
|
||||
will suspend the calling thread until delivery of a signal whose
|
||||
|
@ -178,6 +171,30 @@ o Task/Scheduler (sched/)
|
|||
Status: Open
|
||||
Priority: Medium Low for now
|
||||
|
||||
Title: RETAINING TASK EXIT STATUS
|
||||
Description: When a task exists, its exit status should be retained in
|
||||
so data structure until it is reaped (via waitpid(), or
|
||||
similar interface) or until the parent thread exists.
|
||||
|
||||
You would think that this should be a clone of the existing
|
||||
pthread join logic. Howver there is no need for zombies
|
||||
in NuttX so, the status if the parent has already exit'ed.
|
||||
|
||||
At present, exit status is not retained. If waitpid()
|
||||
is called after the child task has exit'ed it simpley
|
||||
returns with the ECHLD error. That is not too bad, but
|
||||
does not tell you what the exit status was.
|
||||
|
||||
A work-around is to:
|
||||
1) Call sched_lock() to disable pre-emption.
|
||||
2) Start the task (it cannot run because pre-emption is
|
||||
disbled.
|
||||
3) Call waitpid();
|
||||
4) Call sched_unlock() to re-enable pre-emption.
|
||||
|
||||
Status: Open
|
||||
Priority: Low
|
||||
|
||||
o Memory Managment (mm/)
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -249,7 +266,9 @@ o Signals (sched/, arch/)
|
|||
|
||||
Title: STANDARD SIGNALS
|
||||
Description: 'Standard' signals and signal actions are not supported.
|
||||
(e.g., SIGINT, SIGCHLD, SIGSEGV, etc).
|
||||
(e.g., SIGINT, SIGSEGV, etc).
|
||||
|
||||
Update: SIG_CHLD is support if configured.
|
||||
Status: Open. No changes are planned.
|
||||
Priority: Low, required by standards but not so critical for an
|
||||
embedded system.
|
||||
|
@ -262,6 +281,14 @@ o Signals (sched/, arch/)
|
|||
are required by the POSIX standard.
|
||||
Priority: Low for now
|
||||
|
||||
Title: SIGNAL NUMBERING
|
||||
Description: In signal.h, the range of valid signals is listed as 0-31. However,
|
||||
in many interfaces, 0 is not a valid signal number. The valid
|
||||
signal number should be 1-32. The signal set operations would need
|
||||
to map bits appropriately.
|
||||
Status: Open
|
||||
Priority: Low. Even if there are only 31 usable signals, that is still a lot.
|
||||
|
||||
o pthreads (sched/)
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
@ -121,28 +121,30 @@ static int fat_stat(struct inode *mountpt, const char *relpath, struct stat
|
|||
|
||||
const struct mountpt_operations fat_operations =
|
||||
{
|
||||
fat_open,
|
||||
fat_close,
|
||||
fat_read,
|
||||
fat_write,
|
||||
fat_seek,
|
||||
fat_ioctl,
|
||||
fat_sync,
|
||||
fat_open, /* open */
|
||||
fat_close, /* close */
|
||||
fat_read, /* read */
|
||||
fat_write, /* write */
|
||||
fat_seek, /* seek */
|
||||
fat_ioctl, /* ioctl */
|
||||
|
||||
fat_opendir,
|
||||
NULL,
|
||||
fat_readdir,
|
||||
fat_rewinddir,
|
||||
fat_sync, /* sync */
|
||||
NULL, /* dup */
|
||||
|
||||
fat_bind,
|
||||
fat_unbind,
|
||||
fat_statfs,
|
||||
fat_opendir, /* opendir */
|
||||
NULL, /* closedir */
|
||||
fat_readdir, /* readdir */
|
||||
fat_rewinddir, /* rewinddir */
|
||||
|
||||
fat_unlink,
|
||||
fat_mkdir,
|
||||
fat_rmdir,
|
||||
fat_rename,
|
||||
fat_stat
|
||||
fat_bind, /* bind */
|
||||
fat_unbind, /* unbind */
|
||||
fat_statfs, /* statfs */
|
||||
|
||||
fat_unlink, /* unlinke */
|
||||
fat_mkdir, /* mkdir */
|
||||
fat_rmdir, /* rmdir */
|
||||
fat_rename, /* rename */
|
||||
fat_stat /* stat */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* fs/fs_files.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -284,14 +284,6 @@ int files_dup(FAR struct file *filep1, FAR struct file *filep2)
|
|||
goto errout;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||
if (INODE_IS_MOUNTPT(filep1->f_inode))
|
||||
{
|
||||
err = ENOSYS; /* Not yet supported */
|
||||
goto errout;
|
||||
}
|
||||
#endif
|
||||
|
||||
list = sched_getfiles();
|
||||
if (!list)
|
||||
{
|
||||
|
@ -331,18 +323,16 @@ int files_dup(FAR struct file *filep1, FAR struct file *filep2)
|
|||
if (inode->u.i_ops && inode->u.i_ops->open)
|
||||
{
|
||||
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
||||
#if 0 /* Not implemented */
|
||||
if (INODE_IS_MOUNTPT(inode))
|
||||
{
|
||||
/* Open a file on the mountpoint */
|
||||
/* Dup the open file on the in the new file structure */
|
||||
|
||||
ret = inode->u.i_mops->open(filep2, ?, filep2->f_oflags, ?);
|
||||
ret = inode->u.i_mops->dup(filep1, filep2);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
/* Open the pseudo file or device driver */
|
||||
/* (Re-)open the pseudo file or device driver */
|
||||
|
||||
ret = inode->u.i_ops->open(filep2);
|
||||
}
|
||||
|
|
|
@ -166,7 +166,9 @@ const struct mountpt_operations nfs_operations =
|
|||
nfs_write, /* write */
|
||||
NULL, /* seek */
|
||||
NULL, /* ioctl */
|
||||
|
||||
NULL, /* sync */
|
||||
NULL, /* dup */
|
||||
|
||||
nfs_opendir, /* opendir */
|
||||
NULL, /* closedir */
|
||||
|
|
|
@ -82,7 +82,9 @@ const struct mountpt_operations nxffs_operations =
|
|||
nxffs_write, /* write */
|
||||
NULL, /* seek -- Use f_pos in struct file */
|
||||
nxffs_ioctl, /* ioctl */
|
||||
|
||||
NULL, /* sync -- No buffered data */
|
||||
NULL, /* dup -- not implemented */
|
||||
|
||||
nxffs_opendir, /* opendir */
|
||||
NULL, /* closedir */
|
||||
|
|
|
@ -70,24 +70,33 @@
|
|||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static int romfs_open(FAR struct file *filep, const char *relpath,
|
||||
static int romfs_open(FAR struct file *filep, FAR const char *relpath,
|
||||
int oflags, mode_t mode);
|
||||
static int romfs_close(FAR struct file *filep);
|
||||
static ssize_t romfs_read(FAR struct file *filep, char *buffer, size_t buflen);
|
||||
static ssize_t romfs_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen);
|
||||
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,
|
||||
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_dup(FAR const struct file *oldp, FAR struct file *newp);
|
||||
|
||||
static int romfs_bind(FAR struct inode *blkdriver, const void *data,
|
||||
void **handle);
|
||||
static int romfs_unbind(void *handle, FAR struct inode **blkdriver);
|
||||
static int romfs_statfs(struct inode *mountpt, struct statfs *buf);
|
||||
static int romfs_opendir(FAR struct inode *mountpt,
|
||||
FAR const char *relpath,
|
||||
FAR struct fs_dirent_s *dir);
|
||||
static int romfs_readdir(FAR struct inode *mountpt,
|
||||
FAR struct fs_dirent_s *dir);
|
||||
static int romfs_rewinddir(FAR struct inode *mountpt,
|
||||
FAR struct fs_dirent_s *dir);
|
||||
|
||||
static int romfs_stat(struct inode *mountpt, const char *relpath, struct stat *buf);
|
||||
static int romfs_bind(FAR struct inode *blkdriver, FAR const void *data,
|
||||
FAR void **handle);
|
||||
static int romfs_unbind(FAR void *handle, FAR struct inode **blkdriver);
|
||||
static int romfs_statfs(FAR struct inode *mountpt,
|
||||
FAR struct statfs *buf);
|
||||
|
||||
static int romfs_stat(FAR struct inode *mountpt, FAR const char *relpath,
|
||||
FAR struct stat *buf);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
|
@ -110,7 +119,9 @@ const struct mountpt_operations romfs_operations =
|
|||
NULL, /* write */
|
||||
romfs_seek, /* seek */
|
||||
romfs_ioctl, /* ioctl */
|
||||
|
||||
NULL, /* sync */
|
||||
romfs_dup, /* dup */
|
||||
|
||||
romfs_opendir, /* opendir */
|
||||
NULL, /* closedir */
|
||||
|
@ -136,13 +147,13 @@ const struct mountpt_operations romfs_operations =
|
|||
* Name: romfs_open
|
||||
****************************************************************************/
|
||||
|
||||
static int romfs_open(FAR struct file *filep, const char *relpath,
|
||||
int oflags, mode_t mode)
|
||||
static int romfs_open(FAR struct file *filep, FAR const char *relpath,
|
||||
int oflags, mode_t mode)
|
||||
{
|
||||
struct romfs_dirinfo_s dirinfo;
|
||||
struct romfs_mountpt_s *rm;
|
||||
struct romfs_file_s *rf;
|
||||
int ret;
|
||||
struct romfs_dirinfo_s dirinfo;
|
||||
FAR struct romfs_mountpt_s *rm;
|
||||
FAR struct romfs_file_s *rf;
|
||||
int ret;
|
||||
|
||||
fvdbg("Open '%s'\n", relpath);
|
||||
|
||||
|
@ -150,11 +161,11 @@ static int romfs_open(FAR struct file *filep, const char *relpath,
|
|||
|
||||
DEBUGASSERT(filep->f_priv == NULL && filep->f_inode != NULL);
|
||||
|
||||
/* mountpoint private data from the inode reference from the file
|
||||
/* Get mountpoint private data from the inode reference from the file
|
||||
* structure
|
||||
*/
|
||||
|
||||
rm = (struct romfs_mountpt_s*)filep->f_inode->i_private;
|
||||
rm = (FAR struct romfs_mountpt_s*)filep->f_inode->i_private;
|
||||
|
||||
DEBUGASSERT(rm != NULL);
|
||||
|
||||
|
@ -214,7 +225,7 @@ static int romfs_open(FAR struct file *filep, const char *relpath,
|
|||
* file.
|
||||
*/
|
||||
|
||||
rf = (struct romfs_file_s *)zalloc(sizeof(struct romfs_file_s));
|
||||
rf = (FAR struct romfs_file_s *)zalloc(sizeof(struct romfs_file_s));
|
||||
if (!rf)
|
||||
{
|
||||
fdbg("Failed to allocate private data\n", ret);
|
||||
|
@ -226,8 +237,7 @@ static int romfs_open(FAR struct file *filep, const char *relpath,
|
|||
* non-zero elements)
|
||||
*/
|
||||
|
||||
rf->rf_open = true;
|
||||
rf->rf_size = dirinfo.rd_size;
|
||||
rf->rf_size = dirinfo.rd_size;
|
||||
|
||||
/* Get the start of the file data */
|
||||
|
||||
|
@ -277,9 +287,9 @@ errout_with_semaphore:
|
|||
|
||||
static int romfs_close(FAR struct file *filep)
|
||||
{
|
||||
struct romfs_mountpt_s *rm;
|
||||
struct romfs_file_s *rf;
|
||||
int ret = OK;
|
||||
FAR struct romfs_mountpt_s *rm;
|
||||
FAR struct romfs_file_s *rf;
|
||||
int ret = OK;
|
||||
|
||||
fvdbg("Closing\n");
|
||||
|
||||
|
@ -321,19 +331,20 @@ static int romfs_close(FAR struct file *filep)
|
|||
* Name: romfs_read
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t romfs_read(FAR struct file *filep, char *buffer, size_t buflen)
|
||||
static ssize_t romfs_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen)
|
||||
{
|
||||
struct romfs_mountpt_s *rm;
|
||||
struct romfs_file_s *rf;
|
||||
unsigned int bytesread;
|
||||
unsigned int readsize;
|
||||
unsigned int nsectors;
|
||||
uint32_t offset;
|
||||
size_t bytesleft;
|
||||
off_t sector;
|
||||
uint8_t *userbuffer = (uint8_t*)buffer;
|
||||
int sectorndx;
|
||||
int ret;
|
||||
FAR struct romfs_mountpt_s *rm;
|
||||
FAR struct romfs_file_s *rf;
|
||||
unsigned int bytesread;
|
||||
unsigned int readsize;
|
||||
unsigned int nsectors;
|
||||
uint32_t offset;
|
||||
size_t bytesleft;
|
||||
off_t sector;
|
||||
FAR uint8_t *userbuffer = (FAR uint8_t*)buffer;
|
||||
int sectorndx;
|
||||
int ret;
|
||||
|
||||
fvdbg("Read %d bytes from offset %d\n", buflen, filep->f_pos);
|
||||
|
||||
|
@ -467,10 +478,10 @@ errout_with_semaphore:
|
|||
|
||||
static off_t romfs_seek(FAR struct file *filep, off_t offset, int whence)
|
||||
{
|
||||
struct romfs_mountpt_s *rm;
|
||||
struct romfs_file_s *rf;
|
||||
off_t position;
|
||||
int ret;
|
||||
FAR struct romfs_mountpt_s *rm;
|
||||
FAR struct romfs_file_s *rf;
|
||||
off_t position;
|
||||
int ret;
|
||||
|
||||
fvdbg("Seek to offset: %d whence: %d\n", offset, whence);
|
||||
|
||||
|
@ -548,9 +559,9 @@ errout_with_semaphore:
|
|||
|
||||
static int romfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
struct romfs_mountpt_s *rm;
|
||||
struct romfs_file_s *rf;
|
||||
FAR void **ppv = (FAR void**)arg;
|
||||
FAR struct romfs_mountpt_s *rm;
|
||||
FAR struct romfs_file_s *rf;
|
||||
FAR void **ppv = (FAR void**)arg;
|
||||
|
||||
fvdbg("cmd: %d arg: %08lx\n", cmd, arg);
|
||||
|
||||
|
@ -581,6 +592,95 @@ static int romfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
return -ENOTTY;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: romfs_dup
|
||||
****************************************************************************/
|
||||
|
||||
static int romfs_dup(FAR const struct file *oldp, FAR struct file *newp)
|
||||
{
|
||||
FAR struct romfs_mountpt_s *rm;
|
||||
FAR struct romfs_file_s *oldrf;
|
||||
FAR struct romfs_file_s *newrf;
|
||||
int ret;
|
||||
|
||||
fvdbg("Dup %p->%p\n", oldp, newp);
|
||||
|
||||
/* Sanity checks */
|
||||
|
||||
DEBUGASSERT(oldp->f_priv != NULL &&
|
||||
newp->f_priv == NULL &&
|
||||
newp->f_inode != NULL);
|
||||
|
||||
/* Get mountpoint private data from the inode reference from the file
|
||||
* structure
|
||||
*/
|
||||
|
||||
rm = (FAR struct romfs_mountpt_s*)newp->f_inode->i_private;
|
||||
DEBUGASSERT(rm != NULL);
|
||||
|
||||
/* Check if the mount is still healthy */
|
||||
|
||||
romfs_semtake(rm);
|
||||
ret = romfs_checkmount(rm);
|
||||
if (ret != OK)
|
||||
{
|
||||
fdbg("romfs_checkmount failed: %d\n", ret);
|
||||
goto errout_with_semaphore;
|
||||
}
|
||||
|
||||
/* Recover the old private data from the old struct file instance */
|
||||
|
||||
oldrf = oldp->f_priv;
|
||||
|
||||
/* Create an new instance of the file private data to describe the new
|
||||
* dup'ed file.
|
||||
*/
|
||||
|
||||
newrf = (FAR struct romfs_file_s *)malloc(sizeof(struct romfs_file_s));
|
||||
if (!newrf)
|
||||
{
|
||||
fdbg("Failed to allocate private data\n", ret);
|
||||
ret = -ENOMEM;
|
||||
goto errout_with_semaphore;
|
||||
}
|
||||
|
||||
/* Copy all file private data (except for the buffer) */
|
||||
|
||||
newrf->rf_startoffset = oldrf->rf_startoffset;
|
||||
newrf->rf_size = oldrf->rf_size;
|
||||
|
||||
/* Configure buffering to support access to this file */
|
||||
|
||||
ret = romfs_fileconfigure(rm, newrf);
|
||||
if (ret < 0)
|
||||
{
|
||||
fdbg("Failed configure buffering: %d\n", ret);
|
||||
goto errout_with_semaphore;
|
||||
}
|
||||
|
||||
/* Attach the new private date to the new struct file instance */
|
||||
|
||||
newp->f_priv = newrf;
|
||||
|
||||
/* Then insert the new instance into the mountpoint structure.
|
||||
* It needs to be there (1) to handle error conditions that effect
|
||||
* all files, and (2) to inform the umount logic that we are busy
|
||||
* (but a simple reference count could have done that).
|
||||
*/
|
||||
|
||||
newrf->rf_next = rm->rm_head;
|
||||
rm->rm_head = newrf->rf_next;
|
||||
|
||||
romfs_semgive(rm);
|
||||
return OK;
|
||||
|
||||
/* Error exits */
|
||||
|
||||
errout_with_semaphore:
|
||||
romfs_semgive(rm);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: romfs_opendir
|
||||
*
|
||||
|
@ -589,12 +689,12 @@ static int romfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int romfs_opendir(struct inode *mountpt, const char *relpath,
|
||||
struct fs_dirent_s *dir)
|
||||
static int romfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
|
||||
FAR struct fs_dirent_s *dir)
|
||||
{
|
||||
struct romfs_mountpt_s *rm;
|
||||
struct romfs_dirinfo_s dirinfo;
|
||||
int ret;
|
||||
FAR struct romfs_mountpt_s *rm;
|
||||
FAR struct romfs_dirinfo_s dirinfo;
|
||||
int ret;
|
||||
|
||||
fvdbg("relpath: '%s'\n", relpath);
|
||||
|
||||
|
@ -654,14 +754,15 @@ errout_with_semaphore:
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int romfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
|
||||
static int romfs_readdir(FAR struct inode *mountpt,
|
||||
FAR struct fs_dirent_s *dir)
|
||||
{
|
||||
struct romfs_mountpt_s *rm;
|
||||
uint32_t linkoffset;
|
||||
uint32_t next;
|
||||
uint32_t info;
|
||||
uint32_t size;
|
||||
int ret;
|
||||
FAR struct romfs_mountpt_s *rm;
|
||||
uint32_t linkoffset;
|
||||
uint32_t next;
|
||||
uint32_t info;
|
||||
uint32_t size;
|
||||
int ret;
|
||||
|
||||
fvdbg("Entry\n");
|
||||
|
||||
|
@ -749,9 +850,10 @@ errout_with_semaphore:
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int romfs_rewinddir(struct inode *mountpt, struct fs_dirent_s *dir)
|
||||
static int romfs_rewinddir(FAR struct inode *mountpt,
|
||||
FAR struct fs_dirent_s *dir)
|
||||
{
|
||||
struct romfs_mountpt_s *rm;
|
||||
FAR struct romfs_mountpt_s *rm;
|
||||
int ret;
|
||||
|
||||
fvdbg("Entry\n");
|
||||
|
@ -788,8 +890,8 @@ 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)
|
||||
static int romfs_bind(FAR struct inode *blkdriver, FAR const void *data,
|
||||
FAR void **handle)
|
||||
{
|
||||
struct romfs_mountpt_s *rm;
|
||||
int ret;
|
||||
|
@ -813,7 +915,7 @@ static int romfs_bind(FAR struct inode *blkdriver, const void *data,
|
|||
|
||||
/* Create an instance of the mountpt state structure */
|
||||
|
||||
rm = (struct romfs_mountpt_s *)zalloc(sizeof(struct romfs_mountpt_s));
|
||||
rm = (FAR struct romfs_mountpt_s *)zalloc(sizeof(struct romfs_mountpt_s));
|
||||
if (!rm)
|
||||
{
|
||||
fdbg("Failed to allocate mountpoint structure\n");
|
||||
|
@ -874,9 +976,9 @@ errout_with_sem:
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int romfs_unbind(void *handle, FAR struct inode **blkdriver)
|
||||
static int romfs_unbind(FAR void *handle, FAR struct inode **blkdriver)
|
||||
{
|
||||
struct romfs_mountpt_s *rm = (struct romfs_mountpt_s*)handle;
|
||||
FAR struct romfs_mountpt_s *rm = (FAR struct romfs_mountpt_s*)handle;
|
||||
int ret;
|
||||
|
||||
fvdbg("Entry\n");
|
||||
|
@ -948,10 +1050,10 @@ static int romfs_unbind(void *handle, FAR struct inode **blkdriver)
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int romfs_statfs(struct inode *mountpt, struct statfs *buf)
|
||||
static int romfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf)
|
||||
{
|
||||
struct romfs_mountpt_s *rm;
|
||||
int ret;
|
||||
FAR struct romfs_mountpt_s *rm;
|
||||
int ret;
|
||||
|
||||
fvdbg("Entry\n");
|
||||
|
||||
|
@ -1004,11 +1106,12 @@ errout_with_semaphore:
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int romfs_stat(struct inode *mountpt, const char *relpath, struct stat *buf)
|
||||
static int romfs_stat(FAR struct inode *mountpt, FAR const char *relpath,
|
||||
FAR struct stat *buf)
|
||||
{
|
||||
struct romfs_mountpt_s *rm;
|
||||
struct romfs_dirinfo_s dirinfo;
|
||||
int ret;
|
||||
FAR struct romfs_mountpt_s *rm;
|
||||
FAR struct romfs_dirinfo_s dirinfo;
|
||||
int ret;
|
||||
|
||||
fvdbg("Entry\n");
|
||||
|
||||
|
|
|
@ -159,7 +159,6 @@ struct romfs_mountpt_s
|
|||
struct romfs_file_s
|
||||
{
|
||||
struct romfs_file_s *rf_next; /* Retained in a singly linked list */
|
||||
bool rf_open; /* true: The file is (still) open */
|
||||
uint32_t rf_startoffset; /* Offset to the start of the file data */
|
||||
uint32_t rf_size; /* Size of the file in bytes */
|
||||
uint32_t rf_cachesector; /* Current sector in the rf_buffer */
|
||||
|
|
|
@ -613,7 +613,7 @@ int romfs_fsconfigure(struct romfs_mountpt_s *rm)
|
|||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: romfs_ffileconfigure
|
||||
* Name: romfs_fileconfigure
|
||||
*
|
||||
* Desciption:
|
||||
* This function is called as part of the ROMFS file open operation It
|
||||
|
@ -649,6 +649,7 @@ int romfs_fileconfigure(struct romfs_mountpt_s *rm, struct romfs_file_s *rf)
|
|||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
@ -663,7 +664,6 @@ int romfs_fileconfigure(struct romfs_mountpt_s *rm, struct romfs_file_s *rf)
|
|||
|
||||
int romfs_checkmount(struct romfs_mountpt_s *rm)
|
||||
{
|
||||
struct romfs_file_s *file;
|
||||
struct inode *inode;
|
||||
struct geometry geo;
|
||||
int ret;
|
||||
|
@ -692,14 +692,8 @@ int romfs_checkmount(struct romfs_mountpt_s *rm)
|
|||
/* If we get here, the mount is NOT healthy */
|
||||
|
||||
rm->rm_mounted = false;
|
||||
|
||||
/* Make sure that this is flagged in every opened file */
|
||||
|
||||
for (file = rm->rm_head; file; file = file->rf_next)
|
||||
{
|
||||
file->rf_open = false;
|
||||
}
|
||||
}
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
|
|
@ -161,6 +161,7 @@ struct mountpt_operations
|
|||
*/
|
||||
|
||||
int (*sync)(FAR struct file *filp);
|
||||
int (*dup)(FAR const struct file *oldp, FAR struct file *newp);
|
||||
|
||||
/* Directory operations */
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ EXTERN int execv(FAR const char *path, FAR char *const argv[]);
|
|||
/* Non-standard functions to manage symbol tables */
|
||||
|
||||
struct symtab_s; /* See include/nuttx/binfmt/symtab.h */
|
||||
EXTERN void exec_getsymtab(FAR struct symtab_s **symtab, FAR int *nsymbols);
|
||||
EXTERN void exec_getsymtab(FAR const struct symtab_s **symtab, FAR int *nsymbols);
|
||||
EXTERN void exec_setsymtab(FAR const struct symtab_s *symtab, int nsymbols);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -70,8 +70,6 @@ struct spawn_parms_s
|
|||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
extern struct symtab_s CONFIG_EXECFUNCS_SYMTAB;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
@ -157,7 +155,7 @@ static int ps_exec(FAR pid_t *pidp, FAR const char *path,
|
|||
FAR char *const argv[])
|
||||
{
|
||||
struct sched_param param;
|
||||
FAR struct symtab_s *symtab;
|
||||
FAR const struct symtab_s *symtab;
|
||||
int nsymbols;
|
||||
int pid;
|
||||
int ret = OK;
|
||||
|
|
|
@ -69,13 +69,13 @@
|
|||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
extern struct symtab_s CONFIG_EXECFUNCS_SYMTAB;
|
||||
extern const struct symtab_s CONFIG_EXECFUNCS_SYMTAB;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static FAR struct symtab_s *g_exec_symtab = &CONFIG_EXECFUNCS_SYMTAB;
|
||||
static FAR const struct symtab_s *g_exec_symtab = &CONFIG_EXECFUNCS_SYMTAB;
|
||||
static int g_exec_nsymbols = CONFIG_EXECFUNCS_NSYMBOLS;
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -97,7 +97,7 @@ static int g_exec_nsymbols = CONFIG_EXECFUNCS_NSYMBOLS;
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
void exec_getsymtab(FAR struct symtab_s **symtab, FAR int *nsymbols)
|
||||
void exec_getsymtab(FAR const struct symtab_s **symtab, FAR int *nsymbols)
|
||||
{
|
||||
irqstate_t flags;
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
|
||||
int execv(FAR const char *path, FAR char *const argv[])
|
||||
{
|
||||
FAR struct symtab_s *symtab;
|
||||
FAR const struct symtab_s *symtab;
|
||||
int nsymbols;
|
||||
int ret;
|
||||
|
||||
|
@ -148,4 +148,4 @@ int execv(FAR const char *path, FAR char *const argv[])
|
|||
return ERROR;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_LIBC_EXECFUNCS */
|
||||
#endif /* CONFIG_LIBC_EXECFUNCS */
|
||||
|
|
Loading…
Reference in New Issue