Finish implementation of soft links.

This commit is contained in:
Gregory Nutt
2017-02-02 13:01:21 -06:00
parent 92305e400a
commit bdc002fadc
7 changed files with 222 additions and 24 deletions
+10 -2
View File
@@ -88,7 +88,15 @@ int link(FAR const char *path1, FAR const char *path2)
int errcode;
int ret;
DEBUGASSERT(path1 != NULL && path2 != NULL && *path2 != '\0');
/* Both paths must be absolute. We need only check path2 here. path1 will
* be checked by inode find.
*/
if (path2 == NULL || *path2 != '/')
{
errode = EINVAL;
goto errout;
}
/* Check that no inode exists at the 'path2' and that the path up to 'path2'
* does not lie on a mounted volume.
@@ -129,7 +137,7 @@ int link(FAR const char *path1, FAR const char *path2)
if (newpath2 == NULL)
{
errcode = ENOMEM;
goto errout;
goto errout;
}
/* Create an inode in the pseudo-filesystem at this path.
+9 -7
View File
@@ -85,9 +85,11 @@ int unlink(FAR const char *pathname)
int errcode;
int ret;
/* Get an inode for this file */
/* Get an inode for this file (without deference the final node in the path
* which may be a symbolic link)
*/
inode = inode_find(pathname, &relpath);
inode = inode_find_nofollow(pathname, &relpath);
if (!inode)
{
/* There is no inode that includes in this path */
@@ -124,17 +126,17 @@ int unlink(FAR const char *pathname)
#endif
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
/* If this is a "dangling" pseudo-file node (i.e., it has operations) then rm
* should remove the node.
/* If this is a "dangling" pseudo-file node (i.e., it has no operations)
* or a soft link, then rm should remove the node.
*/
if (!INODE_IS_SPECIAL(inode) && inode->u.i_ops)
if (!INODE_IS_SPECIAL(inode))
{
/* If this is a pseudo-file node (i.e., it has no operations)
* then rmdir should remove the node.
* then unlink should remove the node.
*/
if (inode->u.i_ops)
if (inode->u.i_ops != NULL)
{
inode_semtake();