summaryrefslogtreecommitdiff
path: root/nuttx/fs/fs_files.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-01-31 23:39:12 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-01-31 23:39:12 +0000
commitd9e1bd9b855de8783076cddae7e17177d071a8b5 (patch)
tree4ec59e18f087faba4945cf1bb1d7855d44e82080 /nuttx/fs/fs_files.c
parentc0191ed21b7cb6f978fbde31d7e106a8c801ee03 (diff)
downloadpx4-nuttx-d9e1bd9b855de8783076cddae7e17177d071a8b5.tar.gz
px4-nuttx-d9e1bd9b855de8783076cddae7e17177d071a8b5.tar.bz2
px4-nuttx-d9e1bd9b855de8783076cddae7e17177d071a8b5.zip
Add on_exit(); Re-order some logic in the task shutdown sequence. Sometimes some complex logic needs to execute when closing file descriptors and this needs to happen early while the task is still healthy
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4354 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/fs/fs_files.c')
-rw-r--r--nuttx/fs/fs_files.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/nuttx/fs/fs_files.c b/nuttx/fs/fs_files.c
index 1444d8805..066c9a4ef 100644
--- a/nuttx/fs/fs_files.c
+++ b/nuttx/fs/fs_files.c
@@ -1,8 +1,8 @@
/****************************************************************************
* fs/fs_files.c
*
- * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -74,6 +74,7 @@
/****************************************************************************
* Name: _files_semtake
****************************************************************************/
+
static void _files_semtake(FAR struct filelist *list)
{
/* Take the semaphore (perhaps waiting) */
@@ -91,6 +92,7 @@ static void _files_semtake(FAR struct filelist *list)
/****************************************************************************
* Name: _files_semgive
****************************************************************************/
+
#define _files_semgive(list) sem_post(&list->fl_sem)
/****************************************************************************
@@ -103,6 +105,7 @@ static void _files_semtake(FAR struct filelist *list)
* Caller holds the list semaphore because the file descriptor will be freed.
*
****************************************************************************/
+
static int _files_close(FAR struct file *filep)
{
struct inode *inode = filep->f_inode;
@@ -145,6 +148,7 @@ static int _files_close(FAR struct file *filep)
* This is called from the FS initialization logic to configure the files.
*
****************************************************************************/
+
void files_initialize(void)
{
}
@@ -155,6 +159,7 @@ void files_initialize(void)
* Description: Allocate a list of files for a new task
*
****************************************************************************/
+
FAR struct filelist *files_alloclist(void)
{
FAR struct filelist *list;
@@ -178,6 +183,7 @@ FAR struct filelist *files_alloclist(void)
* Description: Increase the reference count on a file list
*
****************************************************************************/
+
int files_addreflist(FAR struct filelist *list)
{
if (list)
@@ -257,6 +263,7 @@ int files_releaselist(FAR struct filelist *list)
* Assign an inode to a specific files structure. This is the heart of dup2.
*
****************************************************************************/
+
int files_dup(FAR struct file *filep1, FAR struct file *filep2)
{
FAR struct filelist *list;
@@ -402,12 +409,13 @@ int files_allocate(FAR struct inode *inode, int oflags, off_t pos, int minfd)
* Caller holds the list semaphore because the file descriptor will be freed.
*
****************************************************************************/
+
int files_close(int filedes)
{
- FAR struct filelist *list;
- int ret;
+ FAR struct filelist *list;
+ int ret;
- /* Get the thread-specific file list */
+ /* Get the thread-specific file list */
list = sched_getfiles();
if (!list)
@@ -422,12 +430,12 @@ int files_close(int filedes)
return -EBADF;
}
- /* Perform the protected close operation */
+ /* Perform the protected close operation */
- _files_semtake(list);
- ret = _files_close(&list->fl_files[filedes]);
- _files_semgive(list);
- return ret;
+ _files_semtake(list);
+ ret = _files_close(&list->fl_files[filedes]);
+ _files_semgive(list);
+ return ret;
}
/****************************************************************************
@@ -438,6 +446,7 @@ int files_close(int filedes)
* conditions.
*
****************************************************************************/
+
void files_release(int filedes)
{
FAR struct filelist *list;