diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-07-14 21:05:40 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-07-14 21:05:40 +0000 |
commit | 7c6185ae4bfefb70c17e75219db7269c03c7fd79 (patch) | |
tree | 189259eb60c6bdc6a646e62b0eb684ae5719554d /nuttx | |
parent | 1faee63c00cf63807dea0681a8ee48104e0765f5 (diff) | |
download | px4-firmware-7c6185ae4bfefb70c17e75219db7269c03c7fd79.tar.gz px4-firmware-7c6185ae4bfefb70c17e75219db7269c03c7fd79.tar.bz2 px4-firmware-7c6185ae4bfefb70c17e75219db7269c03c7fd79.zip |
Clean-up files in fs/ directory
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4942 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx')
43 files changed, 388 insertions, 328 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index dc8c6bcc5..54e2ad3a8 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -2993,3 +2993,4 @@ descriptors (sure, why not?). * sched/: Stylistic clean-up of all files. Some of these files are pretty old and do not follow current NuttX coding standards in detail. + * fs/: More stylistic file clean-up. diff --git a/nuttx/fs/Makefile b/nuttx/fs/Makefile index 00227e1d0..e03f5c23d 100644 --- a/nuttx/fs/Makefile +++ b/nuttx/fs/Makefile @@ -2,7 +2,7 @@ # fs/Makefile # # Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> +# 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 diff --git a/nuttx/fs/fs_close.c b/nuttx/fs/fs_close.c index ce506725a..7f08995de 100644 --- a/nuttx/fs/fs_close.c +++ b/nuttx/fs/fs_close.c @@ -55,7 +55,7 @@ ****************************************************************************/ /**************************************************************************** - * Function: close + * Name: close * * Description: * close() closes a file descriptor, so that it no longer refers to any @@ -127,7 +127,7 @@ int close(int fd) #endif errout: - errno = err; + set_errno(err); return ERROR; } diff --git a/nuttx/fs/fs_closeblockdriver.c b/nuttx/fs/fs_closeblockdriver.c index c6900ee80..2151b04df 100644 --- a/nuttx/fs/fs_closeblockdriver.c +++ b/nuttx/fs/fs_closeblockdriver.c @@ -2,7 +2,7 @@ * fs/fs_closeblockdriver.c * * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in pathname and binary forms, with or without * modification, are permitted provided that the following conditions @@ -75,6 +75,7 @@ int close_blockdriver(FAR struct inode *inode) int ret = 0; /* Assume success */ /* Sanity checks */ + #ifdef CONFIG_DEBUG if (!inode || !inode->u.i_bops) { @@ -105,6 +106,7 @@ int close_blockdriver(FAR struct inode *inode) /* Then release the reference on the inode */ inode_release(inode); + errout: return ret; } diff --git a/nuttx/fs/fs_closedir.c b/nuttx/fs/fs_closedir.c index 572be4053..fe0994478 100644 --- a/nuttx/fs/fs_closedir.c +++ b/nuttx/fs/fs_closedir.c @@ -2,7 +2,7 @@ * fs/fs_closedir.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -57,20 +57,19 @@ ****************************************************************************/ /**************************************************************************** - * Name: seekdir + * Name: closedir * * Description: - * The closedir() function closes the directory stream - * associated with 'dirp'. The directory stream - * descriptor 'dirp' is not available after this call. + * The closedir() function closes the directory stream associated with + * 'dirp'. The directory stream descriptor 'dirp' is not available after + * this call. * * Inputs: - * dirp -- An instance of type DIR created by a previous - * call to opendir(); + * dirp -- An instance of type DIR created by a previous call to opendir(); * * Return: - * The closedir() function returns 0 on success. On error, - * -1 is returned, and errno is set appropriately. + * The closedir() function returns 0 on success. On error, -1 is + * returned, and errno is set appropriately. * ****************************************************************************/ @@ -104,8 +103,8 @@ int closedir(FAR DIR *dirp) */ if (inode->u.i_mops && inode->u.i_mops->closedir) - { - /* Perform the closedir() operation */ + { + /* Perform the closedir() operation */ ret = inode->u.i_mops->closedir(inode, idir); if (ret < 0) @@ -144,7 +143,6 @@ errout_with_inode: #endif errout: - errno = ret; + set_errno(ret); return ERROR; } - diff --git a/nuttx/fs/fs_dup.c b/nuttx/fs/fs_dup.c index a72509595..890da039b 100644 --- a/nuttx/fs/fs_dup.c +++ b/nuttx/fs/fs_dup.c @@ -2,7 +2,7 @@ * fs/fs_dup.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -98,10 +98,10 @@ int dup(int fildes) { /* No.. then it is a bad descriptor number */ - errno = EBADF; + set_errno(EBADF); ret = ERROR; } } + return ret; } - diff --git a/nuttx/fs/fs_dup2.c b/nuttx/fs/fs_dup2.c index e5c2fe869..45ff2bb73 100644 --- a/nuttx/fs/fs_dup2.c +++ b/nuttx/fs/fs_dup2.c @@ -2,7 +2,7 @@ * fs/fs_dup2.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -76,7 +76,8 @@ int dup2(int fildes1, int fildes2) { /* Check the range of the descriptor to see if we got a file or a socket - * descriptor. */ + * descriptor. + */ if ((unsigned int)fildes1 >= CONFIG_NFILE_DESCRIPTORS) { @@ -92,7 +93,7 @@ int dup2(int fildes1, int fildes2) { /* No.. then it is a bad descriptor number */ - errno = EBADF; + set_errno(EBADF); return ERROR; } } diff --git a/nuttx/fs/fs_fcntl.c b/nuttx/fs/fs_fcntl.c index b7e688895..ff53b0f20 100644 --- a/nuttx/fs/fs_fcntl.c +++ b/nuttx/fs/fs_fcntl.c @@ -53,6 +53,10 @@ * Private Functions ****************************************************************************/ +/**************************************************************************** + * Name: file_vfcntl + ****************************************************************************/ + #if CONFIG_NFILE_DESCRIPTORS > 0 static inline int file_vfcntl(int fildes, int cmd, va_list ap) { @@ -112,8 +116,8 @@ static inline int file_vfcntl(int fildes, int cmd, va_list ap) * successful execution of one of the exec functions. */ - err = ENOSYS; - break; + err = ENOSYS; + break; case F_GETFL: /* Get the file status flags and file access modes, defined in <fcntl.h>, @@ -158,8 +162,8 @@ static inline int file_vfcntl(int fildes, int cmd, va_list ap) * fildes does not refer to a socket, the results are unspecified. */ - err = EBADF; /* Only valid on socket descriptors */ - break; + err = EBADF; /* Only valid on socket descriptors */ + break; case F_GETLK: /* Get the first lock which blocks the lock description pointed to by the third @@ -188,20 +192,21 @@ static inline int file_vfcntl(int fildes, int cmd, va_list ap) * not be done. */ - err = ENOSYS; /* Not implemented */ - break; + err = ENOSYS; /* Not implemented */ + break; default: - err = EINVAL; - break; - } + err = EINVAL; + break; + } errout: if (err != 0) { - errno = err; + set_errno(err); return ERROR; } + return ret; } #endif /* CONFIG_NFILE_DESCRIPTORS > 0 */ @@ -210,6 +215,10 @@ errout: * Global Functions ****************************************************************************/ +/**************************************************************************** + * Name: fcntl + ****************************************************************************/ + int fcntl(int fildes, int cmd, ...) { va_list ap; diff --git a/nuttx/fs/fs_fdopen.c b/nuttx/fs/fs_fdopen.c index 09af07124..ee6440bf5 100644 --- a/nuttx/fs/fs_fdopen.c +++ b/nuttx/fs/fs_fdopen.c @@ -205,6 +205,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR _TCB *tcb) if (stream->fs_filedes < 0) { /* Zero the structure */ + #if CONFIG_STDIO_BUFFER_SIZE > 0 memset(stream, 0, sizeof(FILE)); #elif CONFIG_NUNGET_CHARS > 0 @@ -258,4 +259,3 @@ errout: errout_with_errno: return NULL; } - diff --git a/nuttx/fs/fs_filedup.c b/nuttx/fs/fs_filedup.c index 746c3aa61..d074b3fab 100644 --- a/nuttx/fs/fs_filedup.c +++ b/nuttx/fs/fs_filedup.c @@ -2,7 +2,7 @@ * fs/fs_filedup.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -85,15 +85,15 @@ int file_dup(int fildes, int minfd) list = sched_getfiles(); if (!list) { - errno = EMFILE; + set_errno(EMFILE); return ERROR; } - /* Verify that fildes is a valid, open file descriptor */ + /* Verify that fildes is a valid, open file descriptor */ if (!DUP_ISOPEN(fildes, list)) { - errno = EBADF; + set_errno(EBADF); return ERROR; } @@ -109,10 +109,11 @@ int file_dup(int fildes, int minfd) minfd); if (fildes2 < 0) { - errno = EMFILE; + set_errno(EMFILE); inode_release(list->fl_files[fildes].f_inode); return ERROR; } + return fildes2; } diff --git a/nuttx/fs/fs_filedup2.c b/nuttx/fs/fs_filedup2.c index 30a4a3aa0..0e785ca48 100644 --- a/nuttx/fs/fs_filedup2.c +++ b/nuttx/fs/fs_filedup2.c @@ -2,7 +2,7 @@ * fs/fs_filedup2.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -87,15 +87,15 @@ int dup2(int fildes1, int fildes2) list = sched_getfiles(); if (!list) { - errno = EMFILE; + set_errno(EMFILE); return ERROR; } - /* Verify that fildes is a valid, open file descriptor */ + /* Verify that fildes is a valid, open file descriptor */ if (!DUP_ISOPEN(fildes1, list)) { - errno = EBADF; + set_errno(EBADF); return ERROR; } @@ -110,7 +110,7 @@ int dup2(int fildes1, int fildes2) if ((unsigned int)fildes2 >= CONFIG_NFILE_DESCRIPTORS) { - errno = EBADF; + set_errno(EBADF); return ERROR; } diff --git a/nuttx/fs/fs_files.c b/nuttx/fs/fs_files.c index d4dec1992..d237b17bd 100644 --- a/nuttx/fs/fs_files.c +++ b/nuttx/fs/fs_files.c @@ -85,7 +85,7 @@ static void _files_semtake(FAR struct filelist *list) * the wait was awakened by a signal. */ - ASSERT(*get_errno_ptr() == EINTR); + ASSERT(get_errno() == EINTR); } } @@ -124,16 +124,17 @@ static int _files_close(FAR struct file *filep) ret = inode->u.i_ops->close(filep); } - /* And release the inode */ + /* And release the inode */ - inode_release(inode); + inode_release(inode); - /* Release the file descriptor */ + /* Release the file descriptor */ - filep->f_oflags = 0; - filep->f_pos = 0; - filep->f_inode = NULL; + filep->f_oflags = 0; + filep->f_pos = 0; + filep->f_inode = NULL; } + return ret; } @@ -174,6 +175,7 @@ FAR struct filelist *files_alloclist(void) (void)sem_init(&list->fl_sem, 0, 1); } + return list; } @@ -188,18 +190,19 @@ 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); + /* 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; } @@ -216,43 +219,44 @@ int files_releaselist(FAR struct filelist *list) 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; - - /* 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 - */ - - for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++) - { - (void)_files_close(&list->fl_files[i]); - } - - /* Destroy the semaphore and release the filelist */ - - (void)sem_destroy(&list->fl_sem); - sched_free(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; + + /* 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 + */ + + for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++) + { + (void)_files_close(&list->fl_files[i]); + } + + /* Destroy the semaphore and release the filelist */ + + (void)sem_destroy(&list->fl_sem); + sched_free(list); + } } + return OK; } @@ -361,7 +365,7 @@ errout_with_ret: err = -ret; _files_semgive(list); errout: - errno = err; + set_errno(err); return ERROR; } diff --git a/nuttx/fs/fs_findblockdriver.c b/nuttx/fs/fs_findblockdriver.c index 63178a0db..febf28a7e 100644 --- a/nuttx/fs/fs_findblockdriver.c +++ b/nuttx/fs/fs_findblockdriver.c @@ -2,7 +2,7 @@ * fs/fs_openblockdriver.c * * Copyright (C) 2008 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in pathname and binary forms, with or without * modification, are permitted provided that the following conditions @@ -83,6 +83,7 @@ int find_blockdriver(FAR const char *pathname, int mountflags, FAR struct inode int ret = 0; /* Assume success */ /* Sanity checks */ + #ifdef CONFIG_DEBUG if (!pathname || !ppinode) { @@ -108,7 +109,7 @@ int find_blockdriver(FAR const char *pathname, int mountflags, FAR struct inode fdbg("%s is not a block driver\n", pathname); ret = -ENOTBLK; goto errout_with_inode; - } + } /* Make sure that the inode supports the requested access */ diff --git a/nuttx/fs/fs_fsync.c b/nuttx/fs/fs_fsync.c index 6e6d81591..877c33a83 100644 --- a/nuttx/fs/fs_fsync.c +++ b/nuttx/fs/fs_fsync.c @@ -2,7 +2,7 @@ * fs/fs_fsync.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -125,13 +125,14 @@ int fsync(int fd) ret = inode->u.i_mops->sync(this_file); if (ret >= 0) - { + { return OK; - } + } + ret = -ret; - errout: - *get_errno_ptr() = ret; +errout: + set_errno(ret); return ERROR; } diff --git a/nuttx/fs/fs_inode.c b/nuttx/fs/fs_inode.c index a2b9d27d8..0b88c4b3b 100644 --- a/nuttx/fs/fs_inode.c +++ b/nuttx/fs/fs_inode.c @@ -2,7 +2,7 @@ * fs/fs_inode.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -90,31 +90,36 @@ static int _inode_compare(const char *fname, for (;;) { /* At end of node name? */ + if (!*nname) { - /* Yes.. also end of find name? */ - if (!*fname || *fname == '/') - { - /* Yes.. return match */ - return 0; - } - else - { - /* No... return find name > node name */ - return 1; - } + /* Yes.. also end of find name? */ + + if (!*fname || *fname == '/') + { + /* Yes.. return match */ + + return 0; + } + else + { + /* No... return find name > node name */ + + return 1; + } } /* At end of find name?*/ else if (!*fname || *fname == '/') { - /* Yes... return find name < node name */ + /* Yes... return find name < node name */ - return -1; + return -1; } - /* check for non-matching characters */ + /* Check for non-matching characters */ + else if (*fname > *nname) { return 1; @@ -127,6 +132,7 @@ static int _inode_compare(const char *fname, /* Not at the end of either string and all of the * characters still match. keep looking. */ + else { fname++; @@ -143,8 +149,8 @@ static int _inode_compare(const char *fname, * Name: fs_initialize * * Description: - * This is called from the OS initialization logic to configure - * the file system. + * This is called from the OS initialization logic to configure the file + * system. * ****************************************************************************/ @@ -180,7 +186,7 @@ void inode_semtake(void) * the wait was awakened by a signal. */ - ASSERT(errno == EINTR); + ASSERT(get_errno() == EINTR); } } @@ -190,15 +196,15 @@ void inode_semtake(void) void inode_semgive(void) { - sem_post(&tree_sem); + sem_post(&tree_sem); } /**************************************************************************** * Name: inode_search * * Description: - * Find the inode associated with 'path' returning the - * inode references and references to its companion nodes. + * Find the inode associated with 'path' returning the inode references + * and references to its companion nodes. * * Assumptions: * The caller holds the tree_sem @@ -293,8 +299,16 @@ FAR struct inode *inode_search(const char **path, * (4) When the node matching the full path is found */ - if (peer) *peer = left; - if (parent) *parent = above; + if (peer) + { + *peer = left; + } + + if (parent) + { + *parent = above; + } + *path = name; return node; } @@ -322,10 +336,26 @@ void inode_free(FAR struct inode *node) * ****************************************************************************/ -const char *inode_nextname(const char *name) +FAR const char *inode_nextname(FAR const char *name) { - while (*name && *name != '/') name++; - if (*name) name++; + /* Search for the '/' delimiter or the NUL terminator at the end of the + * string. + */ + + while (*name && *name != '/') + { + name++; + } + + /* If we found the '/' delimiter, then the path segment we want begins at + * the next character (which might also be the NUL terminator). + */ + + if (*name) + { + name++; + } + return name; } diff --git a/nuttx/fs/fs_inodeaddref.c b/nuttx/fs/fs_inodeaddref.c index c43f23479..32d4426d2 100644 --- a/nuttx/fs/fs_inodeaddref.c +++ b/nuttx/fs/fs_inodeaddref.c @@ -2,7 +2,7 @@ * fs_inodeaddref.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -67,8 +67,8 @@ * Name: inode_addref * * Description: - * Increment the reference count on an inode (as when a file - * descriptor is dup'ed. + * Increment the reference count on an inode (as when a file descriptor + * is dup'ed). * ****************************************************************************/ diff --git a/nuttx/fs/fs_inodefind.c b/nuttx/fs/fs_inodefind.c index 22b8d9861..905539366 100644 --- a/nuttx/fs/fs_inodefind.c +++ b/nuttx/fs/fs_inodefind.c @@ -2,7 +2,7 @@ * fs/fs_inodefind.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -68,8 +68,8 @@ * Name: inode_find * * Description: - * This is called from the open() logic to get a reference - * to the inode associated with a path. + * This is called from the open() logic to get a reference to the inode + * associated with a path. * ****************************************************************************/ @@ -82,8 +82,8 @@ FAR struct inode *inode_find(FAR const char *path, FAR const char **relpath) return NULL; } - /* Find the node matching the path. If found, - * increment the count of references on the node. + /* Find the node matching the path. If found, increment the count of + * references on the node. */ inode_semtake(); @@ -92,6 +92,7 @@ FAR struct inode *inode_find(FAR const char *path, FAR const char **relpath) { node->i_crefs++; } + inode_semgive(); return node; } diff --git a/nuttx/fs/fs_inoderelease.c b/nuttx/fs/fs_inoderelease.c index 27b36985a..bc5026534 100644 --- a/nuttx/fs/fs_inoderelease.c +++ b/nuttx/fs/fs_inoderelease.c @@ -2,7 +2,7 @@ * fs_inoderelease.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -70,8 +70,7 @@ * Name: inode_release * * Description: - * This is called from close() logic when it no longer refers - * to the inode. + * This is called from close() logic when it no longer refers to the inode. * ****************************************************************************/ @@ -94,13 +93,13 @@ void inode_release(FAR struct inode *node) if (node->i_crefs <= 0 && (node->i_flags & FSNODEFLAG_DELETED) != 0) { - inode_semgive(); - inode_free(node->i_child); - kfree(node); + inode_semgive(); + inode_free(node->i_child); + kfree(node); } else { - inode_semgive(); + inode_semgive(); } } } diff --git a/nuttx/fs/fs_inoderemove.c b/nuttx/fs/fs_inoderemove.c index 314596e38..cad136f3b 100644 --- a/nuttx/fs/fs_inoderemove.c +++ b/nuttx/fs/fs_inoderemove.c @@ -2,7 +2,7 @@ * fs/fs_inoderemove.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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,27 +74,28 @@ static void inode_unlink(struct inode *node, * of that peer node. */ - if (peer) - { - peer->i_peer = node->i_peer; - } + if (peer) + { + peer->i_peer = node->i_peer; + } - /* If parent is non-null, then remove the node from head of - * of the list of children. - */ + /* If parent is non-null, then remove the node from head of + * of the list of children. + */ - else if (parent) - { - parent->i_child = node->i_peer; - } + else if (parent) + { + parent->i_child = node->i_peer; + } - /* Otherwise, we must be removing the root inode. */ + /* Otherwise, we must be removing the root inode. */ - else - { - root_inode = node->i_peer; - } - node->i_peer = NULL; + else + { + root_inode = node->i_peer; + } + + node->i_peer = NULL; } /**************************************************************************** @@ -105,6 +106,7 @@ static void inode_unlink(struct inode *node, * Name: inode_remove * * NOTE: Caller must hold the inode semaphore + * ****************************************************************************/ int inode_remove(const char *path) @@ -132,16 +134,16 @@ int inode_remove(const char *path) if (node->i_crefs) { - /* In that case, we will mark it deleted, when the FS - * releases the inode, we will then, finally delete - * the subtree. - */ + /* In that case, we will mark it deleted, when the FS + * releases the inode, we will then, finally delete + * the subtree. + */ node->i_flags |= FSNODEFLAG_DELETED; return -EBUSY; - } - else - { + } + else + { /* And delete it now -- recursively to delete all of its children */ inode_free(node->i_child); diff --git a/nuttx/fs/fs_inodereserve.c b/nuttx/fs/fs_inodereserve.c index e48b2793a..73e0fff28 100644 --- a/nuttx/fs/fs_inodereserve.c +++ b/nuttx/fs/fs_inodereserve.c @@ -96,6 +96,7 @@ static FAR struct inode *inode_alloc(FAR const char *name) { inode_namecpy(node->i_name, name); } + return node; } @@ -111,29 +112,29 @@ static void inode_insert(FAR struct inode *node, * of that peer node. */ - if (peer) - { - node->i_peer = peer->i_peer; - peer->i_peer = node; - } - - /* If parent is non-null, then it must go at the head of its - * list of children. - */ - - else if (parent) - { - node->i_peer = parent->i_child; - parent->i_child = node; - } - - /* Otherwise, this must be the new root_inode */ - - else - { - node->i_peer = root_inode; - root_inode = node; - } + if (peer) + { + node->i_peer = peer->i_peer; + peer->i_peer = node; + } + + /* If parent is non-null, then it must go at the head of its + * list of children. + */ + + else if (parent) + { + node->i_peer = parent->i_child; + parent->i_child = node; + } + + /* Otherwise, this must be the new root_inode */ + + else + { + node->i_peer = root_inode; + root_inode = node; + } } /**************************************************************************** diff --git a/nuttx/fs/fs_ioctl.c b/nuttx/fs/fs_ioctl.c index 409c168b1..3440bc0d0 100644 --- a/nuttx/fs/fs_ioctl.c +++ b/nuttx/fs/fs_ioctl.c @@ -139,11 +139,12 @@ int ioctl(int fd, int req, unsigned long arg) goto errout; } } + return ret; #endif errout: - *get_errno_ptr() = err; + set_errno(err); return ERROR; } diff --git a/nuttx/fs/fs_lseek.c b/nuttx/fs/fs_lseek.c index 12c8b1342..c57658434 100644 --- a/nuttx/fs/fs_lseek.c +++ b/nuttx/fs/fs_lseek.c @@ -2,7 +2,7 @@ * fs/fs_lseek.c * * Copyright (C) 2008 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -124,52 +124,53 @@ off_t lseek(int fd, off_t offset, int whence) if (inode->u.i_ops->seek) { - /* Yes, then let it perform the seek */ - - err = (int)inode->u.i_ops->seek(filep, offset, whence); - if (err < 0) - { - err = -err; - goto errout; - } + /* Yes, then let it perform the seek */ + + err = (int)inode->u.i_ops->seek(filep, offset, whence); + if (err < 0) + { + err = -err; + goto errout; + } } else { - /* No... there are a couple of default actions we can take */ - - switch (whence) - { - case SEEK_CUR: - offset += filep->f_pos; - - case SEEK_SET: - if (offset >= 0) - { - filep->f_pos = offset; /* Might be beyond the end-of-file */ - break; - } - else - { - err = EINVAL; - goto errout; - } - break; - - case SEEK_END: - err = ENOSYS; - goto errout; - - default: - err = EINVAL; - goto errout; - } + /* No... there are a couple of default actions we can take */ + + switch (whence) + { + case SEEK_CUR: + offset += filep->f_pos; + + case SEEK_SET: + if (offset >= 0) + { + filep->f_pos = offset; /* Might be beyond the end-of-file */ + break; + } + else + { + err = EINVAL; + goto errout; + } + break; + + case SEEK_END: + err = ENOSYS; + goto errout; + + default: + err = EINVAL; + goto errout; + } } } + return filep->f_pos; errout: - *get_errno_ptr() = err; + set_errno(err); return (off_t)ERROR; } -#endif +#endif diff --git a/nuttx/fs/fs_mkdir.c b/nuttx/fs/fs_mkdir.c index 3564ba7f6..6e201ce34 100644 --- a/nuttx/fs/fs_mkdir.c +++ b/nuttx/fs/fs_mkdir.c @@ -2,7 +2,7 @@ * fs/fs_mkdir.c * * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -124,7 +124,7 @@ int mkdir(const char *pathname, mode_t mode) errout_with_inode: inode_release(inode); errout: - *get_errno_ptr() = ret; + set_errno(ret); return ERROR; } diff --git a/nuttx/fs/fs_mount.c b/nuttx/fs/fs_mount.c index a7b871aaf..228c1fc6e 100644 --- a/nuttx/fs/fs_mount.c +++ b/nuttx/fs/fs_mount.c @@ -160,6 +160,7 @@ static FAR const struct mountpt_operations * mount_findfs(FAR const struct fsmap_t *fstab, FAR const char *filesystemtype) { FAR const struct fsmap_t *fsmap; + for (fsmap = fstab; fsmap->fs_filesystemtype; fsmap++) { if (strcmp(filesystemtype, fsmap->fs_filesystemtype) == 0) @@ -167,6 +168,7 @@ mount_findfs(FAR const struct fsmap_t *fstab, FAR const char *filesystemtype) return fsmap->fs_mops; } } + return NULL; } #endif @@ -231,9 +233,9 @@ int mount(FAR const char *source, FAR const char *target, ret = find_blockdriver(source, mountflags, &blkdrvr_inode); if (ret < 0) { - fdbg("Failed to find block driver %s\n", source); - errcode = -ret; - goto errout; + fdbg("Failed to find block driver %s\n", source); + errcode = -ret; + goto errout; } } else @@ -304,7 +306,7 @@ int mount(FAR const char *source, FAR const char *target, ret = mops->bind(NULL, data, &fshandle); #endif if (ret != 0) - { + { /* The inode is unhappy with the blkdrvr for some reason. Back out * the count for the reference we failed to pass and exit with an * error. @@ -321,7 +323,7 @@ int mount(FAR const char *source, FAR const char *target, #endif errcode = -ret; goto errout_with_mountpt; - } + } /* We have it, now populate it with driver specific information. */ @@ -348,6 +350,7 @@ int mount(FAR const char *source, FAR const char *target, inode_release(blkdrvr_inode); } #endif + return OK; /* A lot of goto's! But they make the error handling much simpler */ @@ -364,6 +367,7 @@ errout_with_mountpt: inode_release(blkdrvr_inode); } #endif + inode_release(mountpt_inode); goto errout; @@ -379,12 +383,12 @@ errout_with_semaphore: #endif errout: - errno = errcode; + set_errno(errcode); return ERROR; #else fdbg("No filesystems enabled\n"); - ernno = ENOSYS; + set_errno(ENOSYS); return error; #endif /* BDFS_SUPPORT || NONBDFS_SUPPORT */ } diff --git a/nuttx/fs/fs_open.c b/nuttx/fs/fs_open.c index 1bbae2f02..8b3a81862 100644 --- a/nuttx/fs/fs_open.c +++ b/nuttx/fs/fs_open.c @@ -2,7 +2,7 @@ * fs_open.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -56,6 +56,10 @@ * Public Functions ****************************************************************************/ +/**************************************************************************** + * Name: inode_checkflags + ****************************************************************************/ + int inode_checkflags(FAR struct inode *inode, int oflags) { if (((oflags & O_RDOK) != 0 && !inode->u.i_ops->read) || @@ -185,7 +189,6 @@ int open(const char *path, int oflags, ...) errout_with_inode: inode_release(inode); errout: - errno = ret; + set_errno(ret); return ERROR; } - diff --git a/nuttx/fs/fs_openblockdriver.c b/nuttx/fs/fs_openblockdriver.c index 62b33bee7..c59a255b0 100644 --- a/nuttx/fs/fs_openblockdriver.c +++ b/nuttx/fs/fs_openblockdriver.c @@ -2,7 +2,7 @@ * fs/fs_openblockdriver.c * * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in pathname and binary forms, with or without * modification, are permitted provided that the following conditions @@ -76,14 +76,15 @@ * ****************************************************************************/ -int open_blockdriver(FAR const char *pathname, int mountflags, FAR struct inode **ppinode) +int open_blockdriver(FAR const char *pathname, int mountflags, + FAR struct inode **ppinode) { FAR struct inode *inode; int ret; /* Minimal sanity checks */ -#ifdef CONFIG_DEBUG +#ifdef CONFIG_DEBUG if (!ppinode) { ret = -EINVAL; diff --git a/nuttx/fs/fs_opendir.c b/nuttx/fs/fs_opendir.c index f070115c4..a52c538fe 100644 --- a/nuttx/fs/fs_opendir.c +++ b/nuttx/fs/fs_opendir.c @@ -2,7 +2,7 @@ * fs/fs_opendir.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -81,7 +81,6 @@ static inline int open_mountpoint(FAR struct inode *inode, /* The inode itself as the 'root' of mounted volume. The actually * directory is at relpath into the* mounted filesystem. * - * * Verify that the mountpoint inode supports the opendir() method */ @@ -200,15 +199,15 @@ FAR DIR *opendir(FAR const char *path) inode_semtake(); if (!path || *path == 0 || strcmp(path, "/") == 0) { - inode = root_inode; - bisroot = true; - relpath = NULL; + inode = root_inode; + bisroot = true; + relpath = NULL; } else { /* We don't know what to do with relative pathes */ - if (*path != '/') + if (*path != '/') { ret = -ENOTDIR; goto errout_with_semaphore; @@ -308,7 +307,6 @@ errout_with_direntry: errout_with_semaphore: inode_semgive(); - errno = ret; + set_errno(ret); return NULL; } - diff --git a/nuttx/fs/fs_poll.c b/nuttx/fs/fs_poll.c index f7795a170..2e3adeb5d 100644 --- a/nuttx/fs/fs_poll.c +++ b/nuttx/fs/fs_poll.c @@ -79,7 +79,7 @@ static void poll_semtake(FAR sem_t *sem) * the wait was awakened by a signal. */ - ASSERT(errno == EINTR); + ASSERT(get_errno() == EINTR); } } @@ -220,6 +220,7 @@ static inline int poll_teardown(FAR struct pollfd *fds, nfds_t nfds, int *count) fds[i].sem = NULL; } + return ret; } #endif @@ -309,13 +310,14 @@ int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout) ret = poll_teardown(fds, nfds, &count); } + sem_destroy(&sem); /* Check for errors */ if (ret < 0) { - errno = -ret; + set_errno(-ret); return ERROR; } @@ -323,4 +325,3 @@ int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout) } #endif /* CONFIG_DISABLE_POLL */ - diff --git a/nuttx/fs/fs_read.c b/nuttx/fs/fs_read.c index 045c81f59..30dd4af03 100644 --- a/nuttx/fs/fs_read.c +++ b/nuttx/fs/fs_read.c @@ -134,7 +134,7 @@ ssize_t read(int fd, FAR void *buf, size_t nbytes) #else /* No networking... it is a bad descriptor in any event */ - errno = EBADF; + set_errno(EBADF); return ERROR; #endif } diff --git a/nuttx/fs/fs_readdir.c b/nuttx/fs/fs_readdir.c index a1cbfb89b..8df1bf655 100644 --- a/nuttx/fs/fs_readdir.c +++ b/nuttx/fs/fs_readdir.c @@ -2,7 +2,7 @@ * fs/fs_readdir.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -140,19 +140,18 @@ static inline int readpsuedodir(struct fs_dirent_s *idir) * Name: readdir * * Description: - * The readdir() function returns a pointer to a dirent - * structure representing the next directory entry in the - * directory stream pointed to by dir. It returns NULL on - * reaching the end-of-file or if an error occurred. + * The readdir() function returns a pointer to a dirent structure + * representing the next directory entry in the directory stream pointed + * to by dir. It returns NULL on reaching the end-of-file or if an error + * occurred. * * Inputs: - * dirp -- An instance of type DIR created by a previous - * call to opendir(); + * dirp -- An instance of type DIR created by a previous call to opendir(); * * Return: - * The readdir() function returns a pointer to a dirent - * structure, or NULL if an error occurs or end-of-file - * is reached. On error, errno is set appropriately. + * The readdir() function returns a pointer to a dirent structure, or NULL + * if an error occurs or end-of-file is reached. On error, errno is set + * appropriately. * * EBADF - Invalid directory stream descriptor dir * @@ -187,10 +186,10 @@ FAR struct dirent *readdir(DIR *dirp) */ if (!inode->u.i_mops || !inode->u.i_mops->readdir) - { - ret = EACCES; - goto errout; - } + { + ret = EACCES; + goto errout; + } /* Perform the readdir() operation */ @@ -225,7 +224,7 @@ FAR struct dirent *readdir(DIR *dirp) return &idir->fd_dir; errout: - *get_errno_ptr() = ret; + set_errno(ret); return NULL; } diff --git a/nuttx/fs/fs_registerblockdriver.c b/nuttx/fs/fs_registerblockdriver.c index fb5e462c2..365e164e1 100644 --- a/nuttx/fs/fs_registerblockdriver.c +++ b/nuttx/fs/fs_registerblockdriver.c @@ -38,9 +38,12 @@ ****************************************************************************/ #include <nuttx/config.h> + #include <sys/types.h> #include <errno.h> + #include <nuttx/fs/fs.h> + #include "fs_internal.h" /**************************************************************************** diff --git a/nuttx/fs/fs_registerdriver.c b/nuttx/fs/fs_registerdriver.c index 4e76adc2c..cc1759ee7 100644 --- a/nuttx/fs/fs_registerdriver.c +++ b/nuttx/fs/fs_registerdriver.c @@ -38,9 +38,12 @@ ****************************************************************************/ #include <nuttx/config.h> + #include <sys/types.h> #include <errno.h> + #include <nuttx/fs/fs.h> + #include "fs_internal.h" /**************************************************************************** diff --git a/nuttx/fs/fs_rename.c b/nuttx/fs/fs_rename.c index 83e0ac368..157775132 100644 --- a/nuttx/fs/fs_rename.c +++ b/nuttx/fs/fs_rename.c @@ -2,7 +2,7 @@ * fs/fs_rename.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -148,7 +148,6 @@ int rename(FAR const char *oldpath, FAR const char *newpath) errout_with_oldinode: inode_release(oldinode); errout: - *get_errno_ptr() = ret; + set_errno(ret); return ERROR; } - diff --git a/nuttx/fs/fs_rewinddir.c b/nuttx/fs/fs_rewinddir.c index 271132010..a0e2be7d8 100644 --- a/nuttx/fs/fs_rewinddir.c +++ b/nuttx/fs/fs_rewinddir.c @@ -2,7 +2,7 @@ * fs/fs_rewinddir.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -143,4 +143,3 @@ void rewinddir(FAR DIR *dirp) rewindpsuedodir(idir); } } - diff --git a/nuttx/fs/fs_rmdir.c b/nuttx/fs/fs_rmdir.c index 4a45e42ba..6c64de5cf 100644 --- a/nuttx/fs/fs_rmdir.c +++ b/nuttx/fs/fs_rmdir.c @@ -2,7 +2,7 @@ * fs/fs_rmdir.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -124,7 +124,7 @@ int rmdir(FAR const char *pathname) errout_with_inode: inode_release(inode); errout: - *get_errno_ptr() = ret; + set_errno(ret); return ERROR; } diff --git a/nuttx/fs/fs_seekdir.c b/nuttx/fs/fs_seekdir.c index fa304545e..ec530c67d 100644 --- a/nuttx/fs/fs_seekdir.c +++ b/nuttx/fs/fs_seekdir.c @@ -2,7 +2,7 @@ * fs/fs_seekdir.c * * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -70,13 +70,13 @@ static inline void seekpsuedodir(struct fs_dirent_s *idir, off_t offset) if ( offset < idir->fd_position ) { - pos = 0; - curr = idir->fd_root; + pos = 0; + curr = idir->fd_root; } else { - pos = idir->fd_position; - curr = idir->u.psuedo.fd_next; + pos = idir->fd_position; + curr = idir->u.psuedo.fd_next; } /* Traverse the peer list starting at the 'root' of the @@ -137,7 +137,7 @@ static inline void seekmountptdir(struct fs_dirent_s *idir, off_t offset) } else { - /* We can't do the seek and there is no way to return + /* We can't do the seek and there is no way to return * an error indication. */ @@ -146,7 +146,7 @@ static inline void seekmountptdir(struct fs_dirent_s *idir, off_t offset) } else { - pos = idir->fd_position; + pos = idir->fd_position; } /* This is a brute force approach... we will just read @@ -155,19 +155,19 @@ static inline void seekmountptdir(struct fs_dirent_s *idir, off_t offset) while (pos < offset) { - if (!inode->u.i_mops || !inode->u.i_mops->readdir || - inode->u.i_mops->readdir(inode, idir) < 0) - { - /* We can't read the next entry and there is no way to return + if (!inode->u.i_mops || !inode->u.i_mops->readdir || + inode->u.i_mops->readdir(inode, idir) < 0) + { + /* We can't read the next entry and there is no way to return * an error indication. */ - return; - } + return; + } - /* Increment the position on each successful read */ + /* Increment the position on each successful read */ - pos++; + pos++; } /* If we get here the directory position has been successfully set */ @@ -184,10 +184,9 @@ static inline void seekmountptdir(struct fs_dirent_s *idir, off_t offset) * Name: seekdir * * Description: - * The seekdir() function sets the location in the - * directory stream from which the next readdir() call will - * start. seekdir() should be used with an offset returned - * by telldir(). + * The seekdir() function sets the location in the directory stream from + * which the next readdir() call will start. seekdir() should be used with + * an offset returned by telldir(). * * Inputs: * dirp -- An instance of type DIR created by a previous @@ -229,4 +228,3 @@ void seekdir(FAR DIR *dirp, off_t offset) seekpsuedodir(idir, offset); } } - diff --git a/nuttx/fs/fs_select.c b/nuttx/fs/fs_select.c index f87697310..e40c5bc13 100644 --- a/nuttx/fs/fs_select.c +++ b/nuttx/fs/fs_select.c @@ -114,7 +114,7 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds, pollset = (struct pollfd *)kzalloc(nfds * sizeof(struct pollfd)); if (!pollset) { - errno = ENOMEM; + set_errno(ENOMEM); return ERROR; } @@ -133,9 +133,9 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds, if (readfds && FD_ISSET(fd, readfds)) { - pollset[npfds].fd = fd; - pollset[npfds].events |= POLLIN; - incr = 1; + pollset[npfds].fd = fd; + pollset[npfds].events |= POLLIN; + incr = 1; } /* The writefds set holds the set of FDs that the caller can be assured @@ -144,17 +144,17 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds, if (writefds && FD_ISSET(fd, writefds)) { - pollset[npfds].fd = fd; - pollset[npfds].events |= POLLOUT; - incr = 1; + pollset[npfds].fd = fd; + pollset[npfds].events |= POLLOUT; + incr = 1; } /* The exceptfds set holds the set of FDs that are watched for exceptions */ if (exceptfds && FD_ISSET(fd, exceptfds)) { - pollset[npfds].fd = fd; - incr = 1; + pollset[npfds].fd = fd; + incr = 1; } npfds += incr; diff --git a/nuttx/fs/fs_stat.c b/nuttx/fs/fs_stat.c index 138d6a2c1..5cb342081 100644 --- a/nuttx/fs/fs_stat.c +++ b/nuttx/fs/fs_stat.c @@ -221,4 +221,3 @@ errout: set_errno(ret); return ERROR; } - diff --git a/nuttx/fs/fs_umount.c b/nuttx/fs/fs_umount.c index 05865d28e..5bf44e4f7 100644 --- a/nuttx/fs/fs_umount.c +++ b/nuttx/fs/fs_umount.c @@ -2,7 +2,7 @@ * fs/fs_umount.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -191,16 +191,16 @@ int umount(const char *target) /* A lot of goto's! But they make the error handling much simpler */ - errout_with_semaphore: +errout_with_semaphore: inode_semgive(); - errout_with_mountpt: +errout_with_mountpt: inode_release(mountpt_inode); if (blkdrvr_inode) { inode_release(blkdrvr_inode); } - errout: - *get_errno_ptr() = errcode; +errout: + set_errno(errcode); return ERROR; } diff --git a/nuttx/fs/fs_unlink.c b/nuttx/fs/fs_unlink.c index c2842ce4d..f57bd33b5 100644 --- a/nuttx/fs/fs_unlink.c +++ b/nuttx/fs/fs_unlink.c @@ -2,7 +2,7 @@ * fs_unlink.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -124,7 +124,7 @@ int unlink(FAR const char *pathname) errout_with_inode: inode_release(inode); errout: - *get_errno_ptr() = ret; + set_errno(ret); return ERROR; } diff --git a/nuttx/fs/fs_unregisterblockdriver.c b/nuttx/fs/fs_unregisterblockdriver.c index ccf5a2aa9..0166da141 100644 --- a/nuttx/fs/fs_unregisterblockdriver.c +++ b/nuttx/fs/fs_unregisterblockdriver.c @@ -2,7 +2,7 @@ * fs/fs_unregisterblockdriver.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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,9 +74,9 @@ int unregister_blockdriver(const char *path) { int ret; + inode_semtake(); ret = inode_remove(path); inode_semgive(); return ret; } - diff --git a/nuttx/fs/fs_unregisterdriver.c b/nuttx/fs/fs_unregisterdriver.c index c891c7d02..9ab7fb6ce 100644 --- a/nuttx/fs/fs_unregisterdriver.c +++ b/nuttx/fs/fs_unregisterdriver.c @@ -74,9 +74,9 @@ int unregister_driver(FAR const char *path) { int ret; + inode_semtake(); ret = inode_remove(path); inode_semgive(); return ret; } - diff --git a/nuttx/fs/fs_write.c b/nuttx/fs/fs_write.c index 2912e8ed5..3b3dd1f76 100644 --- a/nuttx/fs/fs_write.c +++ b/nuttx/fs/fs_write.c @@ -2,7 +2,7 @@ * fs/fs_write.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * 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 @@ -102,7 +102,7 @@ static inline ssize_t file_write(int fd, FAR const void *buf, size_t nbytes) return ret; errout: - *get_errno_ptr() = err; + set_errno(err); return ERROR; } #endif @@ -112,7 +112,7 @@ errout: ****************************************************************************/ /*************************************************************************** - * Function: write + * Name: write * * Description: * write() writes up to nytes bytes to the file referenced by the file @@ -174,7 +174,7 @@ ssize_t write(int fd, FAR const void *buf, size_t nbytes) #if defined(CONFIG_NET_TCP) && CONFIG_NSOCKET_DESCRIPTORS > 0 return send(fd, buf, nbytes, 0); #else - errno = EBADF; + set_errno(EBADF); return ERROR; #endif } |