Minor file system clean-up
This commit is contained in:
parent
ed9c45bcef
commit
8293a5e773
@ -235,9 +235,9 @@ FAR DIR *opendir(FAR const char *path)
|
||||
*/
|
||||
|
||||
inode_semtake();
|
||||
if (!path || *path == 0 || strcmp(path, "/") == 0)
|
||||
if (path == NULL || *path == '\0' || strcmp(path, "/") == 0)
|
||||
{
|
||||
inode = root_inode;
|
||||
inode = g_root_inode;
|
||||
isroot = true;
|
||||
relpath = NULL;
|
||||
}
|
||||
|
@ -44,6 +44,8 @@
|
||||
#include <nuttx/compiler.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
|
||||
#include "inode/inode.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
@ -61,8 +63,6 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
extern FAR struct inode *root_inode;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
@ -203,7 +203,7 @@ int foreach_inode(foreach_inode_t handler, FAR void *arg)
|
||||
/* Start the recursion at the root inode */
|
||||
|
||||
inode_semtake();
|
||||
ret = foreach_inodelevel(root_inode, info);
|
||||
ret = foreach_inodelevel(g_root_inode, info);
|
||||
inode_semgive();
|
||||
|
||||
/* Free the info structure and return the result */
|
||||
@ -224,7 +224,7 @@ int foreach_inode(foreach_inode_t handler, FAR void *arg)
|
||||
/* Start the recursion at the root inode */
|
||||
|
||||
inode_semtake();
|
||||
ret = foreach_inodelevel(root_inode, &info);
|
||||
ret = foreach_inodelevel(g_root_inode, &info);
|
||||
inode_semgive();
|
||||
|
||||
return ret;
|
||||
|
@ -82,7 +82,7 @@ static struct inode_sem_s g_inode_sem;
|
||||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct inode *root_inode = NULL;
|
||||
FAR struct inode *g_root_inode = NULL;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@ -290,7 +290,7 @@ FAR struct inode *inode_search(FAR const char **path,
|
||||
FAR const char **relpath)
|
||||
{
|
||||
FAR const char *name = *path + 1; /* Skip over leading '/' */
|
||||
FAR struct inode *node = root_inode;
|
||||
FAR struct inode *node = g_root_inode;
|
||||
FAR struct inode *left = NULL;
|
||||
FAR struct inode *above = NULL;
|
||||
|
||||
@ -396,7 +396,9 @@ FAR struct inode *inode_search(FAR const char **path,
|
||||
|
||||
void inode_free(FAR struct inode *node)
|
||||
{
|
||||
if (node)
|
||||
/* Verify that we were passed valid pointer to an inode */
|
||||
|
||||
if (node != NULL)
|
||||
{
|
||||
inode_free(node->i_peer);
|
||||
inode_free(node->i_child);
|
||||
|
@ -93,9 +93,14 @@ void inode_release(FAR struct inode *node)
|
||||
|
||||
if (node->i_crefs <= 0 && (node->i_flags & FSNODEFLAG_DELETED) != 0)
|
||||
{
|
||||
/* If the inode has been properly unlinked, then the peer pointer
|
||||
* should be NULL.
|
||||
*/
|
||||
|
||||
inode_semgive();
|
||||
inode_free(node->i_child);
|
||||
kmm_free(node);
|
||||
|
||||
DEBUGASSERT(node->i_peer == NULL);
|
||||
inode_free(node);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -120,7 +120,7 @@ FAR struct inode *inode_unlink(FAR const char *path)
|
||||
|
||||
else
|
||||
{
|
||||
root_inode = node->i_peer;
|
||||
g_root_inode = node->i_peer;
|
||||
}
|
||||
|
||||
node->i_peer = NULL;
|
||||
@ -167,10 +167,12 @@ int inode_remove(FAR const char *path)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* And delete it now -- recursively to delete all of its children */
|
||||
/* And delete it now -- recursively to delete all of its children.
|
||||
* Since it has been unlinked, then the peer pointer should be NULL.
|
||||
*/
|
||||
|
||||
inode_free(node->i_child);
|
||||
kmm_free(node);
|
||||
DEBUGASSERT(node->i_peer == NULL);
|
||||
inode_free(node);
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
|
@ -132,8 +132,8 @@ static void inode_insert(FAR struct inode *node,
|
||||
|
||||
else
|
||||
{
|
||||
node->i_peer = root_inode;
|
||||
root_inode = node;
|
||||
node->i_peer = g_root_inode;
|
||||
g_root_inode = node;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
EXTERN FAR struct inode *root_inode;
|
||||
EXTERN FAR struct inode *g_root_inode;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
|
@ -174,11 +174,14 @@ void mq_inode_release(FAR struct inode *inode)
|
||||
mq_msgqfree(msgq);
|
||||
inode->u.i_mqueue = NULL;
|
||||
|
||||
/* Release and free the inode container */
|
||||
/* Release and free the inode container. If it has been properly
|
||||
* unlinked, then the peer pointer should be NULL.
|
||||
*/
|
||||
|
||||
inode_semgive();
|
||||
inode_free(inode->i_child);
|
||||
kmm_free(inode);
|
||||
|
||||
DEBUGASSERT(inode->i_peer == NULL);
|
||||
inode_free(inode);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -134,11 +134,14 @@ int sem_close(FAR sem_t *sem)
|
||||
sem_destroy(&nsem->ns_sem);
|
||||
group_free(NULL, nsem);
|
||||
|
||||
/* Release and free the inode */
|
||||
/* Release and free the inode container. If it has been properly
|
||||
* unlinked, then the peer pointer should be NULL.
|
||||
*/
|
||||
|
||||
inode_semgive();
|
||||
inode_free(inode->i_child);
|
||||
kmm_free(inode);
|
||||
|
||||
DEBUGASSERT(inode->i_peer == NULL);
|
||||
inode_free(inode);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user