Remove some unnecessary (and inappropriate) soft link logic

This commit is contained in:
Gregory Nutt 2017-02-03 15:50:41 -06:00
parent 70dcec7df7
commit 982cfea490
3 changed files with 20 additions and 50 deletions

View File

@ -147,7 +147,10 @@ static int _inode_compare(FAR const char *fname,
*
* Both versions will follow soft links in path leading up to the terminal
* node. inode_search() will deference that terminal node,
* inode_search_nofollow will not.
* inode_search_nofollow will not.
*
* If a soft link is encountered that is not the terminal node in the path,
* that that WILL be deferenced and the mountpoint inode will be returned.
*
* Assumptions:
* The caller holds the g_inode_sem semaphore
@ -175,12 +178,6 @@ FAR struct inode *inode_search(FAR const char **path,
FAR struct inode *newnode;
#endif
#ifdef CONFIG_PSEUDOFS_SOFTLINKS
/* Handle the case were the root node is a symbolic link */
#warning Missing logic
#endif
/* Traverse the pseudo file system node tree until either (1) all nodes
* have been examined without finding the matching node, or (2) the
* matching node is found.
@ -209,42 +206,7 @@ FAR struct inode *inode_search(FAR const char **path,
else if (result > 0)
{
#ifdef CONFIG_PSEUDOFS_SOFTLINKS
/* If the inode in the is a soft link and this is the inode at
* at the head of the peer list and not the final node in the
* path), then (1) get the name of the full path of the soft
* link, (2) recursively look-up the inode referenced by the
* soft link, and (3) use the peer of that inode instead.
*/
FAR const char *nextname = inode_nextname(name);
if (*nextname != '\0')
{
newnode = inode_linktarget(node, NULL, &above, relpath);
if (newnode == NULL)
{
/* Probably means that the node is a symbolic link, but
* that the target of the symbolic link does not exist.
*/
break;
}
else if (newnode != node)
{
/* The node was a valid symbolic link and we have jumped to a
* different, spot in the the pseudo file system tree. Reset
* everything and continue looking at the next level "down"
* from that new spot in the tree.
*/
above = newnode;
left = NULL;
node = newnode->i_child;
continue;
}
}
#endif
/* Continue looking to the left */
/* Continue looking to the "right" of this inode. */
left = node;
node = node->i_peer;
@ -285,7 +247,7 @@ FAR struct inode *inode_search(FAR const char **path,
}
else
{
/* More nodes to be examined in the path... */
/* More nodes to be examined in the path "below" this one. */
#ifdef CONFIG_PSEUDOFS_SOFTLINKS
/* If this intermediate inode in the is a soft link, then (1)
@ -314,6 +276,8 @@ FAR struct inode *inode_search(FAR const char **path,
if (newnode->i_peer != NULL)
{
/* Set up to continue searching at the new node */
above = NULL; /* REVISIT: This can't be right */
left = newnode;
node = newnode->i_peer;
@ -386,7 +350,7 @@ FAR struct inode *inode_search(FAR const char **path,
if (node != NULL)
{
/* Yes.. If the terminal inode in the is a soft link, then (1) get
/* Yes.. If the terminating inode is a soft link, then (1) get
* the name of the full path of the soft link, (2) recursively
* look-up the inode referenced by the soft link, and (3)
* return that inode instead.

View File

@ -122,6 +122,9 @@ void inode_semgive(void);
* node. inode_search() will deference that terminal node,
* inode_search_nofollow will not.
*
* If a soft link is encountered that is not the terminal node in the path,
* that that WILL be deferenced and the mountpoint inode will be returned.
*
* Assumptions:
* The caller holds the g_inode_sem semaphore
*
@ -248,6 +251,9 @@ int inode_remove(FAR const char *path);
* node. inode_find() will deference that terminal node,
* indode_find_nofollow no follow will not.
*
* If a soft link is encounter that is not the terminal node in the path,
* that that WILL be deferenced and the mountpoint inode will be returned.
*
****************************************************************************/
FAR struct inode *inode_find(FAR const char *path, FAR const char **relpath);

View File

@ -62,11 +62,11 @@
#define DTYPE_DIRECTORY (1 << 3) /* Bit 3: Directory */
#define DTYPE_LINK (1 << 4) /* Bit 4: Symbolic link */
#define DIRENT_ISFILE(dtype) (((dtype) & DTYPE_FILE) != 0 )
#define DIRENT_ISCHR(dtype) (((dtype) & DTYPE_CHR) != 0 )
#define DIRENT_ISBLK(dtype) (((dtype) & DTYPE_BLK) != 0 )
#define DIRENT_ISDIRECTORY(dtype) (((dtype) & DTYPE_DIRECTORY) != 0 )
#define DIRENT_ISLINK(dtype) (((dtype) & DTYPE_LINK) != 0 )
#define DIRENT_ISFILE(dtype) (((dtype) & DTYPE_FILE) != 0)
#define DIRENT_ISCHR(dtype) (((dtype) & DTYPE_CHR) != 0)
#define DIRENT_ISBLK(dtype) (((dtype) & DTYPE_BLK) != 0)
#define DIRENT_ISDIRECTORY(dtype) (((dtype) & DTYPE_DIRECTORY) != 0)
#define DIRENT_ISLINK(dtype) (((dtype) & DTYPE_LINK) != 0)
/****************************************************************************
* Public Type Definitions