fs: Add parent node of inode

N/A

Signed-off-by: zhouliang3 <zhouliang3@xiaomi.com>
Change-Id: I006c6172ced8edd47b9d4661880e04d3a4274854
This commit is contained in:
zhouliang3 2021-07-08 17:01:15 +08:00 committed by Gustavo Henrique Nihei
parent ee767021b3
commit b7653e2fae
4 changed files with 9 additions and 4 deletions

View File

@ -94,7 +94,8 @@ FAR struct inode *inode_unlink(FAR const char *path)
desc.parent->i_child = node->i_peer;
}
node->i_peer = NULL;
node->i_peer = NULL;
node->i_parent = NULL;
}
RELEASE_SEARCH(&desc);

View File

@ -98,8 +98,9 @@ static void inode_insert(FAR struct inode *node,
if (peer)
{
node->i_peer = peer->i_peer;
peer->i_peer = node;
node->i_peer = peer->i_peer;
node->i_parent = parent;
peer->i_peer = node;
}
/* Then it must go at the head of parent's list of children. */
@ -108,6 +109,7 @@ static void inode_insert(FAR struct inode *node,
{
DEBUGASSERT(parent != NULL);
node->i_peer = parent->i_child;
node->i_parent = parent;
parent->i_child = node;
}
}

View File

@ -231,7 +231,8 @@ next_subdir:
/* Remove all of the children from the unlinked inode */
oldinode->i_child = NULL;
oldinode->i_child = NULL;
oldinode->i_parent = NULL;
ret = OK;
errout_with_sem:

View File

@ -347,6 +347,7 @@ union inode_ops_u
struct inode
{
FAR struct inode *i_parent; /* Link to parent level inode */
FAR struct inode *i_peer; /* Link to same level inode */
FAR struct inode *i_child; /* Link to lower level inode */
int16_t i_crefs; /* References to inode */