2008-01-01 00:52:53 +01:00
|
|
|
/****************************************************************************
|
2014-09-28 19:17:36 +02:00
|
|
|
* fs/dirent/fs_opendir.c
|
2007-03-14 23:41:09 +01:00
|
|
|
*
|
2020-03-30 01:36:19 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2007-03-14 23:41:09 +01:00
|
|
|
*
|
2020-03-30 01:36:19 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-03-14 23:41:09 +01:00
|
|
|
*
|
2020-03-30 01:36:19 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2007-03-14 23:41:09 +01:00
|
|
|
*
|
2008-01-01 00:52:53 +01:00
|
|
|
****************************************************************************/
|
2007-03-14 23:41:09 +01:00
|
|
|
|
2008-01-01 00:52:53 +01:00
|
|
|
/****************************************************************************
|
2007-03-14 23:41:09 +01:00
|
|
|
* Included Files
|
2008-01-01 00:52:53 +01:00
|
|
|
****************************************************************************/
|
2007-03-14 23:41:09 +01:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
2008-05-31 22:14:15 +02:00
|
|
|
|
2009-12-15 01:18:32 +01:00
|
|
|
#include <stdbool.h>
|
2007-05-26 18:05:59 +02:00
|
|
|
#include <string.h>
|
2018-11-16 18:45:18 +01:00
|
|
|
#include <ctype.h>
|
2017-02-04 23:35:49 +01:00
|
|
|
#include <dirent.h>
|
2008-05-31 22:14:15 +02:00
|
|
|
#include <assert.h>
|
2007-03-14 23:41:09 +01:00
|
|
|
#include <errno.h>
|
2008-05-31 22:14:15 +02:00
|
|
|
|
2011-04-05 22:54:00 +02:00
|
|
|
#include <nuttx/kmalloc.h>
|
2012-03-21 19:01:07 +01:00
|
|
|
#include <nuttx/fs/fs.h>
|
|
|
|
#include <nuttx/fs/dirent.h>
|
2008-05-31 22:14:15 +02:00
|
|
|
|
2014-09-29 15:14:38 +02:00
|
|
|
#include "inode/inode.h"
|
2007-03-14 23:41:09 +01:00
|
|
|
|
2008-01-01 00:52:53 +01:00
|
|
|
/****************************************************************************
|
2007-03-14 23:41:09 +01:00
|
|
|
* Private Functions
|
2008-01-01 00:52:53 +01:00
|
|
|
****************************************************************************/
|
2007-03-14 23:41:09 +01:00
|
|
|
|
2011-03-28 19:43:34 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: open_mountpoint
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Handle the case where the inode to be opened is within a mountpoint.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Input Parameters:
|
2011-03-28 19:43:34 +02:00
|
|
|
* inode -- the inode of the mountpoint to open
|
|
|
|
* relpath -- the relative path within the mountpoint to open
|
|
|
|
* dir -- the dirent structure to be initialized
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2011-03-28 19:43:34 +02:00
|
|
|
* On success, OK is returned; Otherwise, a positive errno is returned.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
|
|
|
static inline int open_mountpoint(FAR struct inode *inode,
|
|
|
|
FAR const char *relpath,
|
|
|
|
FAR struct fs_dirent_s *dir)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!inode->u.i_mops || !inode->u.i_mops->opendir)
|
|
|
|
{
|
2019-07-31 15:18:07 +02:00
|
|
|
return ENOSYS;
|
2011-03-28 19:43:34 +02:00
|
|
|
}
|
|
|
|
|
2014-02-19 16:21:38 +01:00
|
|
|
/* Take reference to the mountpoint inode. Note that we do not use
|
|
|
|
* inode_addref() because we already hold the tree semaphore.
|
2011-03-28 19:43:34 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
inode->i_crefs++;
|
|
|
|
|
|
|
|
/* Perform the opendir() operation */
|
|
|
|
|
|
|
|
ret = inode->u.i_mops->opendir(inode, relpath, dir);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
/* We now need to back off our reference to the inode. We can't
|
|
|
|
* call inode_release() to do that unless we release the tree
|
|
|
|
* semaphore. The following should be safe because: (1) after the
|
|
|
|
* reference count was incremented above it should be >=1 so it should
|
|
|
|
* not decrement below zero, and (2) we hold the tree semaphore so no
|
|
|
|
* other thread should be able to change the reference count.
|
|
|
|
*/
|
|
|
|
|
|
|
|
inode->i_crefs--;
|
|
|
|
DEBUGASSERT(inode->i_crefs >= 0);
|
|
|
|
|
|
|
|
/* Negate the error value so that it can be used to set errno */
|
|
|
|
|
|
|
|
return -ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: open_pseudodir
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Handle the case where the inode to be opened is within the top-level
|
|
|
|
* pseudo-file system.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Input Parameters:
|
2011-03-28 19:43:34 +02:00
|
|
|
* inode -- the inode of the mountpoint to open
|
|
|
|
* dir -- the dirent structure to be initialized
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2014-02-19 16:21:38 +01:00
|
|
|
* None
|
2011-03-28 19:43:34 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-07-31 15:18:07 +02:00
|
|
|
static void open_pseudodir(FAR struct inode *inode,
|
|
|
|
FAR struct fs_dirent_s *dir)
|
2011-03-28 19:43:34 +02:00
|
|
|
{
|
2012-08-05 19:44:11 +02:00
|
|
|
/* We have a valid pseudo-filesystem node. Take two references on the
|
2011-03-28 19:43:34 +02:00
|
|
|
* inode -- one for the parent (fd_root) and one for the child (fd_next).
|
|
|
|
* Note that we do not call inode_addref because we are holding the tree
|
|
|
|
* semaphore and that would result in deadlock.
|
|
|
|
*/
|
|
|
|
|
2014-02-19 16:21:38 +01:00
|
|
|
inode->i_crefs += 2;
|
|
|
|
dir->fd_root = inode; /* Save the inode where we start */
|
2012-08-05 19:44:11 +02:00
|
|
|
dir->u.pseudo.fd_next = inode; /* This is the next node to use for readdir() */
|
2011-03-28 19:43:34 +02:00
|
|
|
|
2012-08-05 19:44:11 +02:00
|
|
|
/* Flag the inode as belonging to the pseudo-filesystem */
|
2011-03-28 19:43:34 +02:00
|
|
|
|
|
|
|
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
2012-08-05 19:44:11 +02:00
|
|
|
DIRENT_SETPSEUDONODE(dir->fd_flags);
|
2011-03-28 19:43:34 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-02-19 16:21:38 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: open_emptydir
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Handle the case where the inode to be opened is an empty, directory node
|
|
|
|
* within the top-level pseudo-file system. That is, it has no operations
|
|
|
|
* and, therefore, it must be a directory node. But is has no children
|
|
|
|
* to be enumerated either.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Input Parameters:
|
2014-02-19 16:21:38 +01:00
|
|
|
* dir -- the dirent structure to be initialized
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2014-02-19 16:21:38 +01:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static inline void open_emptydir(FAR struct fs_dirent_s *dir)
|
|
|
|
{
|
|
|
|
/* We have a valid, but empty pseudo-filesystem node. fd_next is NULL
|
|
|
|
* meaning that we are already at the end of the list of its children.
|
|
|
|
* fd_root is NULL so that if the directory is rewound, it will still be
|
|
|
|
* at the end of the list.
|
|
|
|
*/
|
|
|
|
|
2014-09-01 00:24:24 +02:00
|
|
|
#if 0 /* Already nullified by kumm_zalloc */
|
2014-02-19 16:21:38 +01:00
|
|
|
dir->fd_root = NULL; /* Save the inode where we start */
|
|
|
|
dir->u.pseudo.fd_next = NULL; /* We are at the end of the list */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Flag the inode as belonging to the pseudo-filesystem */
|
|
|
|
|
|
|
|
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
|
|
|
DIRENT_SETPSEUDONODE(dir->fd_flags);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-01-01 00:52:53 +01:00
|
|
|
/****************************************************************************
|
2007-03-14 23:41:09 +01:00
|
|
|
* Public Functions
|
2008-01-01 00:52:53 +01:00
|
|
|
****************************************************************************/
|
2007-03-14 23:41:09 +01:00
|
|
|
|
2008-01-01 00:52:53 +01:00
|
|
|
/****************************************************************************
|
2007-03-14 23:41:09 +01:00
|
|
|
* Name: opendir
|
|
|
|
*
|
|
|
|
* Description:
|
2011-03-28 19:43:34 +02:00
|
|
|
* The opendir() function opens a directory stream corresponding to the
|
|
|
|
* directory name, and returns a pointer to the directory stream. The
|
|
|
|
* stream is positioned at the first entry in the directory.
|
2007-03-14 23:41:09 +01:00
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Input Parameters:
|
2007-03-14 23:41:09 +01:00
|
|
|
* path -- the directory to open
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2011-03-28 19:43:34 +02:00
|
|
|
* The opendir() function returns a pointer to the directory stream. On
|
|
|
|
* error, NULL is returned, and errno is set appropriately.
|
2007-03-14 23:41:09 +01:00
|
|
|
*
|
|
|
|
* EACCES - Permission denied.
|
|
|
|
* EMFILE - Too many file descriptors in use by process.
|
|
|
|
* ENFILE - Too many files are currently open in the
|
|
|
|
* system.
|
|
|
|
* ENOENT - Directory does not exist, or name is an empty
|
|
|
|
* string.
|
|
|
|
* ENOMEM - Insufficient memory to complete the operation.
|
|
|
|
* ENOTDIR - 'path' is not a directory.
|
|
|
|
*
|
2008-01-01 00:52:53 +01:00
|
|
|
****************************************************************************/
|
2007-03-14 23:41:09 +01:00
|
|
|
|
2008-01-01 00:52:53 +01:00
|
|
|
FAR DIR *opendir(FAR const char *path)
|
2007-03-14 23:41:09 +01:00
|
|
|
{
|
2007-05-27 00:37:57 +02:00
|
|
|
FAR struct inode *inode = NULL;
|
2011-03-28 02:05:58 +02:00
|
|
|
FAR struct fs_dirent_s *dir;
|
2017-02-04 18:21:44 +01:00
|
|
|
struct inode_search_s desc;
|
2017-02-16 16:53:13 +01:00
|
|
|
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
2017-02-04 18:21:44 +01:00
|
|
|
FAR const char *relpath = NULL;
|
2017-02-16 16:53:13 +01:00
|
|
|
#endif
|
2018-11-16 18:45:18 +01:00
|
|
|
FAR char *alloc = NULL;
|
2014-02-19 16:21:38 +01:00
|
|
|
bool isroot = false;
|
2018-11-16 18:45:18 +01:00
|
|
|
int len;
|
2007-05-26 18:05:59 +02:00
|
|
|
int ret;
|
2007-03-14 23:41:09 +01:00
|
|
|
|
2018-11-16 18:45:18 +01:00
|
|
|
/* Strip off any trailing whitespace or '/' characters. In this case we
|
|
|
|
* must make a copy of the user string so we can chop off bytes on the
|
|
|
|
* 'right' without modifying the user's const string.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (path != NULL)
|
|
|
|
{
|
|
|
|
/* Length of the string excludes NUL terminator */
|
|
|
|
|
|
|
|
len = strlen(path);
|
|
|
|
|
|
|
|
/* Check for whitespace or a dangling '/' at the end of the string.
|
|
|
|
* But don't muck with the string any further if it has been reduced
|
|
|
|
* to "/"
|
|
|
|
*/
|
|
|
|
|
|
|
|
while (len > 0 && strcmp(path, "/") != 0 &&
|
|
|
|
(isspace(path[len - 1]) || path[len - 1] == '/'))
|
|
|
|
{
|
|
|
|
/* Have we already allocated memory for the modified string? */
|
|
|
|
|
|
|
|
if (alloc == NULL)
|
|
|
|
{
|
|
|
|
alloc = strdup(path); /* Allocates one too many bytes */
|
|
|
|
if (alloc == NULL)
|
|
|
|
{
|
|
|
|
ret = ENOMEM;
|
|
|
|
goto errout;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Use the cloned, writable string instead of the user string */
|
|
|
|
|
|
|
|
path = alloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Chop off the final character */
|
|
|
|
|
|
|
|
len--;
|
|
|
|
alloc[len] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-27 00:37:57 +02:00
|
|
|
/* If we are given 'nothing' then we will interpret this as
|
|
|
|
* request for the root inode.
|
2007-03-14 23:41:09 +01:00
|
|
|
*/
|
|
|
|
|
2017-02-05 21:25:45 +01:00
|
|
|
SETUP_SEARCH(&desc, path, false);
|
|
|
|
|
2020-03-30 01:36:19 +02:00
|
|
|
ret = inode_semtake();
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
ret = -ret;
|
|
|
|
goto errout_with_alloc;
|
|
|
|
}
|
|
|
|
|
2015-06-11 19:24:20 +02:00
|
|
|
if (path == NULL || *path == '\0' || strcmp(path, "/") == 0)
|
2007-05-27 00:37:57 +02:00
|
|
|
{
|
2015-06-11 19:24:20 +02:00
|
|
|
inode = g_root_inode;
|
2015-06-05 00:58:59 +02:00
|
|
|
isroot = true;
|
2007-05-27 00:37:57 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-11-16 18:45:18 +01:00
|
|
|
/* We don't know what to do with relative paths */
|
2007-05-27 00:37:57 +02:00
|
|
|
|
2012-07-14 23:05:40 +02:00
|
|
|
if (*path != '/')
|
2007-05-27 00:37:57 +02:00
|
|
|
{
|
2019-07-31 15:18:07 +02:00
|
|
|
ret = ENOTDIR;
|
2007-06-10 19:50:16 +02:00
|
|
|
goto errout_with_semaphore;
|
2007-05-27 00:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Find the node matching the path. */
|
|
|
|
|
2017-02-04 18:21:44 +01:00
|
|
|
ret = inode_search(&desc);
|
|
|
|
if (ret >= 0)
|
|
|
|
{
|
|
|
|
inode = desc.node;
|
|
|
|
DEBUGASSERT(inode != NULL);
|
2017-02-16 16:53:13 +01:00
|
|
|
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
2017-02-04 18:21:44 +01:00
|
|
|
relpath = desc.relpath;
|
2017-02-16 16:53:13 +01:00
|
|
|
#endif
|
2017-02-04 18:21:44 +01:00
|
|
|
}
|
2007-05-27 00:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Did we get an inode? */
|
|
|
|
|
2017-02-04 19:51:14 +01:00
|
|
|
if (inode == NULL)
|
2007-03-14 23:41:09 +01:00
|
|
|
{
|
2017-02-04 19:51:14 +01:00
|
|
|
/* Inode for 'path' does not exist. */
|
2007-03-14 23:41:09 +01:00
|
|
|
|
2007-05-26 18:05:59 +02:00
|
|
|
ret = ENOTDIR;
|
2007-05-27 00:37:57 +02:00
|
|
|
goto errout_with_semaphore;
|
2007-03-14 23:41:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate a type DIR -- which is little more than an inode
|
|
|
|
* container.
|
|
|
|
*/
|
|
|
|
|
2014-09-01 00:24:24 +02:00
|
|
|
dir = (FAR struct fs_dirent_s *)kumm_zalloc(sizeof(struct fs_dirent_s));
|
2007-03-14 23:41:09 +01:00
|
|
|
if (!dir)
|
|
|
|
{
|
2015-10-11 19:39:29 +02:00
|
|
|
/* Insufficient memory to complete the operation. */
|
2007-03-14 23:41:09 +01:00
|
|
|
|
2007-05-26 18:05:59 +02:00
|
|
|
ret = ENOMEM;
|
2007-05-27 00:37:57 +02:00
|
|
|
goto errout_with_semaphore;
|
2007-03-14 23:41:09 +01:00
|
|
|
}
|
|
|
|
|
2007-05-26 18:05:59 +02:00
|
|
|
/* Populate the DIR structure and return it to the caller. The way that
|
2012-08-05 19:44:11 +02:00
|
|
|
* we do this depends on whenever this is a "normal" pseudo-file-system
|
2007-05-26 18:05:59 +02:00
|
|
|
* inode or a file system mountpoint.
|
|
|
|
*/
|
|
|
|
|
2007-05-26 21:22:34 +02:00
|
|
|
dir->fd_position = 0; /* This is the position in the read stream */
|
2007-05-26 18:05:59 +02:00
|
|
|
|
2011-03-28 19:43:34 +02:00
|
|
|
/* First, handle the special case of the root inode. This must be
|
|
|
|
* special-cased here because the root inode might ALSO be a mountpoint.
|
|
|
|
*/
|
2007-05-26 18:05:59 +02:00
|
|
|
|
2014-02-19 16:21:38 +01:00
|
|
|
if (isroot)
|
2011-03-28 19:43:34 +02:00
|
|
|
{
|
|
|
|
/* Whatever payload the root inode carries, the root inode is always
|
|
|
|
* a directory inode in the pseudo-file system
|
2008-05-31 22:14:15 +02:00
|
|
|
*/
|
2007-05-26 18:37:37 +02:00
|
|
|
|
2011-03-28 19:43:34 +02:00
|
|
|
open_pseudodir(inode, dir);
|
|
|
|
}
|
2007-05-27 00:37:57 +02:00
|
|
|
|
2012-08-05 19:44:11 +02:00
|
|
|
/* Is this a node in the pseudo filesystem? Or a mountpoint? If the node
|
2014-02-19 16:21:38 +01:00
|
|
|
* is the root (isroot == TRUE), then this is a special case.
|
2011-03-28 19:43:34 +02:00
|
|
|
*/
|
2007-05-26 18:37:37 +02:00
|
|
|
|
2011-03-28 19:43:34 +02:00
|
|
|
#ifndef CONFIG_DISABLE_MOUNTPOINT
|
2017-02-04 18:21:44 +01:00
|
|
|
else if (INODE_IS_MOUNTPT(inode))
|
|
|
|
{
|
|
|
|
/* Yes, the node is a file system mountpoint */
|
2014-02-19 16:21:38 +01:00
|
|
|
|
|
|
|
dir->fd_root = inode; /* Save the inode where we start */
|
|
|
|
|
|
|
|
/* Open the directory at the relative path */
|
2007-05-26 18:05:59 +02:00
|
|
|
|
2011-03-28 19:43:34 +02:00
|
|
|
ret = open_mountpoint(inode, relpath, dir);
|
|
|
|
if (ret != OK)
|
2007-05-26 18:05:59 +02:00
|
|
|
{
|
2019-07-31 15:18:07 +02:00
|
|
|
goto errout_with_direntry;
|
2007-05-26 18:05:59 +02:00
|
|
|
}
|
|
|
|
}
|
2007-05-26 21:22:34 +02:00
|
|
|
#endif
|
2011-03-28 19:43:34 +02:00
|
|
|
else
|
2007-05-26 18:05:59 +02:00
|
|
|
{
|
2014-02-19 16:21:38 +01:00
|
|
|
/* The node is part of the root pseudo file system. Does the inode
|
|
|
|
* have a child? If so that the child would be the 'root' of a list
|
|
|
|
* of nodes under the directory.
|
2007-05-27 00:37:57 +02:00
|
|
|
*/
|
|
|
|
|
2014-02-19 16:21:38 +01:00
|
|
|
FAR struct inode *child = inode->i_child;
|
2017-02-04 19:51:14 +01:00
|
|
|
if (child != NULL)
|
2014-02-19 16:21:38 +01:00
|
|
|
{
|
|
|
|
/* It looks we have a valid pseudo-filesystem directory node. */
|
|
|
|
|
|
|
|
open_pseudodir(child, dir);
|
|
|
|
}
|
|
|
|
else if (!inode->u.i_ops)
|
|
|
|
{
|
|
|
|
/* This is a dangling node with no children and no operations. Set
|
|
|
|
* up to enumerate an empty directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
open_emptydir(dir);
|
|
|
|
}
|
|
|
|
else
|
2007-05-27 00:37:57 +02:00
|
|
|
{
|
2011-03-28 19:43:34 +02:00
|
|
|
ret = ENOTDIR;
|
|
|
|
goto errout_with_direntry;
|
2007-05-27 00:37:57 +02:00
|
|
|
}
|
2007-05-26 18:05:59 +02:00
|
|
|
}
|
2007-03-14 23:41:09 +01:00
|
|
|
|
2017-02-05 21:25:45 +01:00
|
|
|
RELEASE_SEARCH(&desc);
|
2007-05-27 00:37:57 +02:00
|
|
|
inode_semgive();
|
2018-11-16 18:45:18 +01:00
|
|
|
|
|
|
|
/* Free any allocated string memory */
|
|
|
|
|
|
|
|
if (alloc != NULL)
|
|
|
|
{
|
|
|
|
kmm_free(alloc);
|
|
|
|
}
|
|
|
|
|
2015-10-11 19:39:29 +02:00
|
|
|
return ((FAR DIR *)dir);
|
2007-05-26 18:05:59 +02:00
|
|
|
|
|
|
|
/* Nasty goto's make error handling simpler */
|
|
|
|
|
2007-05-27 00:37:57 +02:00
|
|
|
errout_with_direntry:
|
2014-09-01 00:15:11 +02:00
|
|
|
kumm_free(dir);
|
2007-12-02 19:18:59 +01:00
|
|
|
|
2007-05-27 00:37:57 +02:00
|
|
|
errout_with_semaphore:
|
2017-02-05 21:25:45 +01:00
|
|
|
RELEASE_SEARCH(&desc);
|
2007-05-27 00:37:57 +02:00
|
|
|
inode_semgive();
|
2018-11-16 18:45:18 +01:00
|
|
|
|
2020-03-30 01:36:19 +02:00
|
|
|
errout_with_alloc:
|
|
|
|
|
2018-11-16 18:45:18 +01:00
|
|
|
/* Free any allocated string memory */
|
|
|
|
|
|
|
|
if (alloc != NULL)
|
|
|
|
{
|
|
|
|
kmm_free(alloc);
|
|
|
|
}
|
|
|
|
|
|
|
|
errout:
|
2012-07-14 23:05:40 +02:00
|
|
|
set_errno(ret);
|
2007-05-26 18:05:59 +02:00
|
|
|
return NULL;
|
2007-03-14 23:41:09 +01:00
|
|
|
}
|