inode_find: Now takes struct inode_desc_s type as input. This was necessary before that structure includes some data storage. It was used within inode_find(), but that means that the life of the data was the life of inode_find(). That data must persist longer. It is now provided by the caller so that the life of the data persists for the entire life of the caller.

This commit is contained in:
Gregory Nutt
2017-02-05 09:51:42 -06:00
parent 990bed903e
commit 8f2c7198ed
20 changed files with 284 additions and 129 deletions
+6 -27
View File
@@ -56,55 +56,34 @@
* Description:
* This is called from the open() logic to get a reference to the inode
* associated with a path. This is accomplished by calling inode_search().
* The primary difference between inode_find() and inode_search is (1) in
* the form of the input paramters and return value and (2) inode_find()
* inode_find() is a simple wrapper around inode_search(). The primary
* difference between inode_find() and inode_search is that inode_find()
* will lock the inode tree and increment the reference count on the inode.
*
****************************************************************************/
FAR struct inode *inode_find(FAR const char *path, FAR const char **relpath,
bool nofollow)
int inode_find(FAR struct inode_search_s *desc)
{
struct inode_search_s desc;
FAR struct inode *node = NULL;
int ret;
if (path == NULL || *path != '/')
{
return NULL;
}
/* Find the node matching the path. If found, increment the count of
* references on the node.
*/
RESET_SEARCH(&desc);
desc.path = path;
#ifdef CONFIG_PSEUDOFS_SOFTLINKS
desc.nofollow = nofollow;
#endif
inode_semtake();
ret = inode_search(&desc);
ret = inode_search(desc);
if (ret >= 0)
{
/* Found it */
node = desc.node;
FAR struct inode *node = desc->node;
DEBUGASSERT(node != NULL);
/* Increment the reference count on the inode */
node->i_crefs++;
/* Return any remaining relative path fragment */
if (relpath != NULL)
{
*relpath = desc.relpath;
}
}
inode_semgive();
return node;
return ret;
}