From 35d738d85f47faf711c22828428b5b40f6abd10c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 2 Feb 2017 15:24:39 -0600 Subject: [PATCH] Soft links: Fix compile problems on first build with soft links enabled. --- fs/Kconfig | 3 +-- fs/inode/fs_inode.c | 9 +++++---- fs/inode/fs_inodefind.c | 2 +- fs/inode/inode.h | 4 ++-- fs/vfs/fs_softlink.c | 16 +++++++++------- include/nuttx/fs/fs.h | 2 +- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/fs/Kconfig b/fs/Kconfig index 6b67520fd2..05ab5daea9 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -42,8 +42,7 @@ config DISABLE_PSEUDOFS_OPERATIONS config PSEUDOFS_SOFTLINKS bool "Pseudo-filesystem soft links" - default y if DEFAULT_SMALL - default n if !DEFAULT_SMALL + default n depends on !DISABLE_PSEUDOFS_OPERATIONS ---help--- Enable support for soft links in the pseudeo file system. Soft diff --git a/fs/inode/fs_inode.c b/fs/inode/fs_inode.c index b8f1bda45b..1da4069c29 100644 --- a/fs/inode/fs_inode.c +++ b/fs/inode/fs_inode.c @@ -196,7 +196,8 @@ _inode_dereference(FAR struct inode *node, FAR struct inode **peer, while (node != NULL && INODE_IS_SOFTLINK(node)) { - node = inode_search_nofollow(node->u.i_link, peer, parent, relpath); + node = inode_search_nofollow((FAR const char **)&node->u.i_link, + peer, parent, relpath); if (++count > SYMLOOP_MAX) { return NULL; @@ -526,8 +527,8 @@ void inode_free(FAR struct inode *node) #ifdef CONFIG_PSEUDOFS_SOFTLINKS /* Symbol links should never have peers or children */ - DEBUGASSERT(!INODE_IS_SOFTLINK(node)) || - (node->i_peer == NULL && node->i_child == NULL) + DEBUGASSERT(!INODE_IS_SOFTLINK(node) || + (node->i_peer == NULL && node->i_child == NULL)); #endif /* Free all peers and children of this i_node */ @@ -540,7 +541,7 @@ void inode_free(FAR struct inode *node) * entity. */ - if (INODE_IS_SOFTLINK(node) && inode->u.i_link != NULL) + if (INODE_IS_SOFTLINK(node) && node->u.i_link != NULL) { kmm_free(node->u.i_link); } diff --git a/fs/inode/fs_inodefind.c b/fs/inode/fs_inodefind.c index 38f15b595e..b5339c9b86 100644 --- a/fs/inode/fs_inodefind.c +++ b/fs/inode/fs_inodefind.c @@ -88,7 +88,7 @@ FAR struct inode *inode_find(FAR const char *path, FAR const char **relpath) #ifdef CONFIG_PSEUDOFS_SOFTLINKS FAR struct inode *inode_find_nofollow(FAR const char *path, - FARconst char **relpath) + FAR const char **relpath) { FAR struct inode *node; diff --git a/fs/inode/inode.h b/fs/inode/inode.h index 31532490c7..529642bfa7 100644 --- a/fs/inode/inode.h +++ b/fs/inode/inode.h @@ -136,7 +136,7 @@ FAR struct inode *inode_search(FAR const char **path, FAR struct inode *inode_search_nofollow(FAR const char **path, FAR struct inode **peer, FAR struct inode **parent, - FAR const char **relpath) + FAR const char **relpath); #else # define inode_search_nofollow(p,l,a,r) inode_search(p,l,a,r) #endif @@ -234,7 +234,7 @@ FAR struct inode *inode_find(FAR const char *path, FAR const char **relpath); #ifdef CONFIG_PSEUDOFS_SOFTLINKS FAR struct inode *inode_find_nofollow(FAR const char *path, - FARconst char **relpath); + FAR const char **relpath); #else # define inode_find_nofollow(p,r) inode_find(p,r) #endif diff --git a/fs/vfs/fs_softlink.c b/fs/vfs/fs_softlink.c index 225bf5b61b..b40a5ea972 100644 --- a/fs/vfs/fs_softlink.c +++ b/fs/vfs/fs_softlink.c @@ -41,8 +41,10 @@ #include #include +#include #include +#include #include #include "inode/inode.h" @@ -94,7 +96,7 @@ int link(FAR const char *path1, FAR const char *path2) if (path2 == NULL || *path2 != '/') { - errode = EINVAL; + errcode = EINVAL; goto errout; } @@ -102,7 +104,7 @@ int link(FAR const char *path1, FAR const char *path2) * does not lie on a mounted volume. */ - inode = inode_find(pathname, NULL); + inode = inode_find(path1, NULL); if (inode != NULL) { #ifndef CONFIG_DISABLE_MOUNTPOINT @@ -110,7 +112,7 @@ int link(FAR const char *path1, FAR const char *path2) if (INODE_IS_MOUNTPT(inode)) { - /* Symbol links within the mounted volume are not supported */ + /* Symbolic links within the mounted volume are not supported */ errcode = ENOSYS; } @@ -119,7 +121,7 @@ int link(FAR const char *path1, FAR const char *path2) { /* A node already exists in the pseudofs at 'path2' */ - errorcode = EEXIST; + errcode = EEXIST; } goto errout_with_inode; @@ -133,7 +135,7 @@ int link(FAR const char *path1, FAR const char *path2) { /* Copy path2 */ - FAR char newpath2 = strdup(path2); + FAR char *newpath2 = strdup(path2); if (newpath2 == NULL) { errcode = ENOMEM; @@ -146,12 +148,12 @@ int link(FAR const char *path1, FAR const char *path2) */ inode_semtake(); - ret = inode_reserve(pathname, &inode); + ret = inode_reserve(path1, &inode); inode_semgive(); if (ret < 0) { - kmm_free(newpath2) + kmm_free(newpath2); errcode = -ret; goto errout; } diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h index cf56865802..584ccef287 100644 --- a/include/nuttx/fs/fs.h +++ b/include/nuttx/fs/fs.h @@ -107,7 +107,7 @@ #define INODE_SET_DRIVER(i) INODE_SET_TYPE(i,FSNODEFLAG_TYPE_DRIVER) #define INODE_SET_BLOCK(i) INODE_SET_TYPE(i,FSNODEFLAG_TYPE_BLOCK) #define INODE_SET_MOUNTPT(i) INODE_SET_TYPE(i,FSNODEFLAG_TYPE_MOUNTPT) -#define (i) INODE_SET_TYPE(i,FSNODEFLAG_TYPE_SOFTLINK) +#define INODE_SET_SOFTLINK(i) INODE_SET_TYPE(i,FSNODEFLAG_TYPE_SOFTLINK) #define INODE_SET_NAMEDSEM(i) INODE_SET_TYPE(i,FSNODEFLAG_TYPE_NAMEDSEM) #define INODE_SET_MQUEUE(i) INODE_SET_TYPE(i,FSNODEFLAG_TYPE_MQUEUE) #define INODE_SET_SHM(i) INODE_SET_TYPE(i,FSNODEFLAG_TYPE_SHM)