aboutsummaryrefslogtreecommitdiff
path: root/nuttx/fs
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-26 20:17:29 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-26 20:17:29 +0000
commit5b6482a22bb8b656e3d70a6efc5ae2c77ed2a58b (patch)
tree34b5782ba8b0613427d231151c3111b886474da1 /nuttx/fs
parenta1aa13f62853491f8bd96a3dea0f0427fa83ad05 (diff)
downloadpx4-firmware-5b6482a22bb8b656e3d70a6efc5ae2c77ed2a58b.tar.gz
px4-firmware-5b6482a22bb8b656e3d70a6efc5ae2c77ed2a58b.tar.bz2
px4-firmware-5b6482a22bb8b656e3d70a6efc5ae2c77ed2a58b.zip
Move file data from TCB to task group
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5567 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/fs')
-rw-r--r--nuttx/fs/fs_fdopen.c8
-rw-r--r--nuttx/fs/fs_files.c101
2 files changed, 24 insertions, 85 deletions
diff --git a/nuttx/fs/fs_fdopen.c b/nuttx/fs/fs_fdopen.c
index fd6aa88a8..629083c77 100644
--- a/nuttx/fs/fs_fdopen.c
+++ b/nuttx/fs/fs_fdopen.c
@@ -1,7 +1,7 @@
/****************************************************************************
* fs/fs_fdopen.c
*
- * Copyright (C) 2007-2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -68,9 +68,11 @@ static inline int fs_checkfd(FAR _TCB *tcb, int fd, int oflags)
FAR struct filelist *flist;
FAR struct inode *inode;
- /* Get the file list from the TCB */
+ DEBUGASSERT(tcb && tcb->group);
- flist = tcb->filelist;
+ /* Get the file list from the task group */
+
+ flist = &tcb->group->tg_filelist;
/* Get the inode associated with the file descriptor. This should
* normally be the case if fd >= 0. But not in the case where the
diff --git a/nuttx/fs/fs_files.c b/nuttx/fs/fs_files.c
index 06addb1ef..c68ec7e73 100644
--- a/nuttx/fs/fs_files.c
+++ b/nuttx/fs/fs_files.c
@@ -155,56 +155,19 @@ void files_initialize(void)
}
/****************************************************************************
- * Name: files_alloclist
+ * Name: files_initlist
*
- * Description: Allocate a list of files for a new task
+ * Description: Initializes the list of files for a new task
*
****************************************************************************/
-FAR struct filelist *files_alloclist(void)
+void files_initlist(FAR struct filelist *list)
{
- FAR struct filelist *list;
- list = (FAR struct filelist*)kzalloc(sizeof(struct filelist));
- if (list)
- {
- /* Start with a reference count of one */
-
- list->fl_crefs = 1;
-
- /* Initialize the list access mutex */
+ DEBUGASSERT(list);
- (void)sem_init(&list->fl_sem, 0, 1);
- }
+ /* Initialize the list access mutex */
- return list;
-}
-
-/****************************************************************************
- * Name: files_addreflist
- *
- * Description:
- * Increase the reference count on a file list
- *
- ****************************************************************************/
-
-int files_addreflist(FAR struct filelist *list)
-{
- if (list)
- {
- /* Increment the reference count on the list.
- * NOTE: that we disable interrupts to do this
- * (vs. taking the list semaphore). We do this
- * because file cleanup operations often must be
- * done from the IDLE task which cannot wait
- * on semaphores.
- */
-
- register irqstate_t flags = irqsave();
- list->fl_crefs++;
- irqrestore(flags);
- }
-
- return OK;
+ (void)sem_init(&list->fl_sem, 0, 1);
}
/****************************************************************************
@@ -215,51 +178,25 @@ int files_addreflist(FAR struct filelist *list)
*
****************************************************************************/
-int files_releaselist(FAR struct filelist *list)
+void files_releaselist(FAR struct filelist *list)
{
- int crefs;
- if (list)
- {
- /* Decrement the reference count on the list.
- * NOTE: that we disable interrupts to do this
- * (vs. taking the list semaphore). We do this
- * because file cleanup operations often must be
- * done from the IDLE task which cannot wait
- * on semaphores.
- */
-
- register irqstate_t flags = irqsave();
- crefs = --(list->fl_crefs);
- irqrestore(flags);
-
- /* If the count decrements to zero, then there is no reference
- * to the structure and it should be deallocated. Since there
- * are references, it would be an error if any task still held
- * a reference to the list's semaphore.
- */
-
- if (crefs <= 0)
- {
- int i;
+ int i;
- /* Close each file descriptor .. Normally, you would need
- * take the list semaphore, but it is safe to ignore the
- * semaphore in this context because there are no references
- */
+ DEBUGASSERT(list);
- for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++)
- {
- (void)_files_close(&list->fl_files[i]);
- }
-
- /* Destroy the semaphore and release the filelist */
+ /* Close each file descriptor .. Normally, you would need take the list
+ * semaphore, but it is safe to ignore the semaphore in this context because
+ * there should not be any references in this context.
+ */
- (void)sem_destroy(&list->fl_sem);
- sched_free(list);
- }
+ for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++)
+ {
+ (void)_files_close(&list->fl_files[i]);
}
- return OK;
+ /* Destroy the semaphore */
+
+ (void)sem_destroy(&list->fl_sem);
}
/****************************************************************************