diff --git a/fs/driver/fs_findblockdriver.c b/fs/driver/fs_findblockdriver.c index 8667beaef23..eefac431c53 100644 --- a/fs/driver/fs_findblockdriver.c +++ b/fs/driver/fs_findblockdriver.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/driver/fs_openblockdriver.c * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in pathname and binary forms, with or without @@ -41,6 +41,7 @@ #include #include +#include #include #include @@ -93,7 +94,7 @@ int find_blockdriver(FAR const char *pathname, int mountflags, FAR struct inode /* Find the inode registered with this pathname */ - inode = inode_find(pathname, NULL); + inode = inode_find(pathname, NULL, false); if (!inode) { ferr("ERROR: Failed to find %s\n", pathname); diff --git a/fs/fat/fs_fat32attrib.c b/fs/fat/fs_fat32attrib.c index ef9b90b4745..2cf0b5a549c 100644 --- a/fs/fat/fs_fat32attrib.c +++ b/fs/fat/fs_fat32attrib.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/fat/fs_fat32attrib.c * - * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -40,6 +40,7 @@ #include #include +#include #include #include @@ -70,7 +71,7 @@ static int fat_attrib(const char *path, fat_attrib_t *retattrib, /* Get an inode for this file */ - inode = inode_find(path, &relpath); + inode = inode_find(path, &relpath, false); if (!inode) { /* There is no mountpoint that includes in this path */ diff --git a/fs/inode/fs_inodefind.c b/fs/inode/fs_inodefind.c index 8a101c0bebf..c4ba53182f7 100644 --- a/fs/inode/fs_inodefind.c +++ b/fs/inode/fs_inodefind.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/inode/fs_inodefind.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -64,7 +64,8 @@ * ****************************************************************************/ -FAR struct inode *inode_find(FAR const char *path, FAR const char **relpath) +FAR struct inode *inode_find(FAR const char *path, FAR const char **relpath, + bool nofollow) { struct inode_search_s desc; FAR struct inode *node = NULL; @@ -83,7 +84,7 @@ FAR struct inode *inode_find(FAR const char *path, FAR const char **relpath) desc.path = path; inode_semtake(); - ret = inode_search(&desc); + ret = nofollow ? inode_search_nofollow(&desc) : inode_search(&desc); if (ret >= 0) { /* Found it */ @@ -106,49 +107,3 @@ FAR struct inode *inode_find(FAR const char *path, FAR const char **relpath) inode_semgive(); return node; } - -#ifdef CONFIG_PSEUDOFS_SOFTLINKS -FAR struct inode *inode_find_nofollow(FAR const char *path, - FAR const char **relpath) -{ - struct inode_search_s desc; - FAR struct inode *node = NULL; - int ret; - - if (path == NULL || *path != '/') - { - return NULL; - } - - /* Find the node matching the path. If found, increment the count of - * references on the node. - */ - - memset(&desc, 0, sizeof(struct inode_search_s)); - desc.path = path; - - inode_semtake(); - ret = inode_search_nofollow(&desc); - if (ret >= 0) - { - /* Found it */ - - node = desc.node; - DEBUGASSERT(node != NULL); - - /* Increment the reference count on the inode */ - - node->i_crefs++; - - /* Return any remaining relative path fragment */ - - if (relpath != NULL) - { - *relpath = desc.relpath; - } - } - - inode_semgive(); - return node; -} -#endif diff --git a/fs/inode/inode.h b/fs/inode/inode.h index b14210046ad..ea15b6631ae 100644 --- a/fs/inode/inode.h +++ b/fs/inode/inode.h @@ -1,7 +1,7 @@ /**************************************************************************** * fs/inode/inode.h * - * Copyright (C) 2007, 2009, 2012, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2012, 2014, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -44,6 +44,7 @@ #include #include +#include #include #include @@ -253,14 +254,8 @@ int inode_remove(FAR const char *path); * ****************************************************************************/ -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, - FAR const char **relpath); -#else -# define inode_find_nofollow(p,r) inode_find(p,r) -#endif +FAR struct inode *inode_find(FAR const char *path, FAR const char **relpath, + bool nofollow); /**************************************************************************** * Name: inode_addref diff --git a/fs/mount/fs_mount.c b/fs/mount/fs_mount.c index 4442938481e..823b5776d54 100644 --- a/fs/mount/fs_mount.c +++ b/fs/mount/fs_mount.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/mount/fs_mount.c * - * Copyright (C) 2007-2009, 2011-2013, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2013, 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -280,7 +281,7 @@ int mount(FAR const char *source, FAR const char *target, #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS /* Check if the inode already exists */ - mountpt_inode = inode_find(target, NULL); + mountpt_inode = inode_find(target, NULL, false); if (mountpt_inode != NULL) { /* Successfully found. The reference count on the inode has been diff --git a/fs/mount/fs_umount2.c b/fs/mount/fs_umount2.c index e9154a49960..8502cdf00c4 100644 --- a/fs/mount/fs_umount2.c +++ b/fs/mount/fs_umount2.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/mount/fs_umount2.c * - * Copyright (C) 2007-2009, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -40,6 +40,7 @@ #include #include +#include #include #include @@ -86,7 +87,7 @@ int umount2(FAR const char *target, unsigned int flags) /* Find the mountpt */ - mountpt_inode = inode_find(target, NULL); + mountpt_inode = inode_find(target, NULL, false); if (!mountpt_inode) { errcode = ENOENT; diff --git a/fs/mqueue/mq_open.c b/fs/mqueue/mq_open.c index 8a182bb3491..b47a7207692 100644 --- a/fs/mqueue/mq_open.c +++ b/fs/mqueue/mq_open.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/mqueue/mq_open.c * - * Copyright (C) 2007-2009, 2011, 2014-2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011, 2014-2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -39,6 +39,7 @@ #include +#include #include #include #include @@ -128,11 +129,11 @@ mqd_t mq_open(FAR const char *mq_name, int oflags, ...) sched_lock(); /* Get the inode for this mqueue. This should succeed if the message - * queue has already been created. In this case, inode_finde() will + * queue has already been created. In this case, inode_find() will * have incremented the reference count on the inode. */ - inode = inode_find(fullpath, &relpath); + inode = inode_find(fullpath, &relpath, false); if (inode) { /* It exists. Verify that the inode is a message queue */ diff --git a/fs/mqueue/mq_unlink.c b/fs/mqueue/mq_unlink.c index 85360f797d7..fda92759d4d 100644 --- a/fs/mqueue/mq_unlink.c +++ b/fs/mqueue/mq_unlink.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/mqueue/mq_unlink.c * - * Copyright (C) 2007, 2009, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2014, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -39,6 +39,7 @@ #include +#include #include #include #include @@ -87,7 +88,7 @@ int mq_unlink(FAR const char *mq_name) /* Get the inode for this message queue. */ sched_lock(); - inode = inode_find(fullpath, &relpath); + inode = inode_find(fullpath, &relpath, false); if (!inode) { /* There is no inode that includes in this path */ diff --git a/fs/semaphore/sem_open.c b/fs/semaphore/sem_open.c index 8e42cb47175..6273bb62cbc 100644 --- a/fs/semaphore/sem_open.c +++ b/fs/semaphore/sem_open.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/semaphore/sem_open.c * - * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -129,11 +130,11 @@ FAR sem_t *sem_open (FAR const char *name, int oflags, ...) snprintf(fullpath, MAX_SEMPATH, CONFIG_FS_NAMED_SEMPATH "/%s", name); /* Get the inode for this semaphore. This should succeed if the - * semaphore has already been created. In this case, inode_finde() + * semaphore has already been created. In this case, inode_find() * will have incremented the reference count on the inode. */ - inode = inode_find(fullpath, &relpath); + inode = inode_find(fullpath, &relpath, false); if (inode) { /* It exists. Verify that the inode is a semaphore */ diff --git a/fs/semaphore/sem_unlink.c b/fs/semaphore/sem_unlink.c index 19f758f0935..7e35889d917 100644 --- a/fs/semaphore/sem_unlink.c +++ b/fs/semaphore/sem_unlink.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/semaphore/sem_unlink.c * - * Copyright (C) 2007-2009, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2014, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -39,6 +39,7 @@ #include +#include #include #include #include @@ -91,7 +92,7 @@ int sem_unlink(FAR const char *name) /* Get the inode for this semaphore. */ sched_lock(); - inode = inode_find(fullpath, &relpath); + inode = inode_find(fullpath, &relpath, false); if (!inode) { /* There is no inode that includes in this path */ diff --git a/fs/unionfs/fs_unionfs.c b/fs/unionfs/fs_unionfs.c index 30d70c806da..2063e5f8afa 100644 --- a/fs/unionfs/fs_unionfs.c +++ b/fs/unionfs/fs_unionfs.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/unionfs/fs_unionfs.c * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -2445,7 +2445,7 @@ static int unionfs_getmount(FAR const char *path, FAR struct inode **inode) /* Find the mountpt */ - minode = inode_find(path, NULL); + minode = inode_find(path, NULL, false); if (!minode) { /* Mountpoint inode not found */ diff --git a/fs/vfs/fs_link.c b/fs/vfs/fs_link.c index 285db3bae8c..34aff29205b 100644 --- a/fs/vfs/fs_link.c +++ b/fs/vfs/fs_link.c @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -105,7 +106,7 @@ int link(FAR const char *path1, FAR const char *path2) * does not lie on a mounted volume. */ - inode = inode_find(path2, NULL); + inode = inode_find(path2, NULL, false); if (inode != NULL) { #ifndef CONFIG_DISABLE_MOUNTPOINT diff --git a/fs/vfs/fs_mkdir.c b/fs/vfs/fs_mkdir.c index 57b0d1be088..da584489e52 100644 --- a/fs/vfs/fs_mkdir.c +++ b/fs/vfs/fs_mkdir.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/vfs/fs_mkdir.c * - * Copyright (C) 2007, 2008, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2008, 2014, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -38,9 +38,12 @@ ****************************************************************************/ #include + #include #include +#include #include + #include #include "inode/inode.h" @@ -87,7 +90,7 @@ int mkdir(const char *pathname, mode_t mode) /* Find the inode that includes this path */ - inode = inode_find(pathname, &relpath); + inode = inode_find(pathname, &relpath, false); if (inode) { /* An inode was found that includes this path and possibly refers to a diff --git a/fs/vfs/fs_open.c b/fs/vfs/fs_open.c index a2a662f722f..401abf07ecf 100644 --- a/fs/vfs/fs_open.c +++ b/fs/vfs/fs_open.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/vfs/fs_open.c * - * Copyright (C) 2007-2009, 2011-2012, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2012, 2016-2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -120,7 +121,7 @@ int open(const char *path, int oflags, ...) /* Get an inode for this file */ - inode = inode_find(path, &relpath); + inode = inode_find(path, &relpath, false); if (!inode) { /* "O_CREAT is not set and the named file does not exist. Or, a diff --git a/fs/vfs/fs_readlink.c b/fs/vfs/fs_readlink.c index d847f485302..86b8bea44d7 100644 --- a/fs/vfs/fs_readlink.c +++ b/fs/vfs/fs_readlink.c @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -91,7 +92,7 @@ ssize_t readlink(FAR const char *path, FAR char *buf, size_t bufsize) * symbolic link node. */ - node = inode_find_nofollow(path, &relpath); + node = inode_find(path, &relpath, true); if (node == NULL) { errcode = ENOENT; diff --git a/fs/vfs/fs_rename.c b/fs/vfs/fs_rename.c index a23d7769d4b..adc979613a9 100644 --- a/fs/vfs/fs_rename.c +++ b/fs/vfs/fs_rename.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/vfs/fs_rename.c * - * Copyright (C) 2007-2009, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2014, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -39,8 +39,10 @@ #include +#include #include #include + #include #include "inode/inode.h" @@ -101,7 +103,7 @@ int rename(FAR const char *oldpath, FAR const char *newpath) /* Get an inode that includes the oldpath */ - oldinode = inode_find(oldpath, &oldrelpath); + oldinode = inode_find(oldpath, &oldrelpath, true); if (!oldinode) { /* There is no inode that includes in this path */ @@ -115,11 +117,11 @@ int rename(FAR const char *oldpath, FAR const char *newpath) if (INODE_IS_MOUNTPT(oldinode) && oldinode->u.i_mops) { - /* Get an inode for the new relpath -- it should like on the same + /* Get an inode for the new relpath -- it should lie on the same * mountpoint */ - newinode = inode_find(newpath, &newrelpath); + newinode = inode_find(newpath, &newrelpath, true); if (!newinode) { /* There is no mountpoint that includes in this path */ diff --git a/fs/vfs/fs_rmdir.c b/fs/vfs/fs_rmdir.c index d3e15bce139..3e821717718 100644 --- a/fs/vfs/fs_rmdir.c +++ b/fs/vfs/fs_rmdir.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/vfs/fs_rmdir.c * - * Copyright (C) 2007-2009, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2014, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -39,8 +39,10 @@ #include +#include #include #include + #include #include "inode/inode.h" @@ -89,7 +91,7 @@ int rmdir(FAR const char *pathname) * on the inode if one is found. */ - inode = inode_find(pathname, &relpath); + inode = inode_find(pathname, &relpath, true); if (!inode) { /* There is no inode that includes in this path */ diff --git a/fs/vfs/fs_stat.c b/fs/vfs/fs_stat.c index af9b8574ad6..461369ec80b 100644 --- a/fs/vfs/fs_stat.c +++ b/fs/vfs/fs_stat.c @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -233,7 +234,7 @@ int stat(FAR const char *path, FAR struct stat *buf) /* Get an inode for this file */ - inode = inode_find_nofollow(path, &relpath); + inode = inode_find(path, &relpath, true); if (!inode) { /* This name does not refer to a psudeo-inode and there is no diff --git a/fs/vfs/fs_statfs.c b/fs/vfs/fs_statfs.c index a70e970dc2c..acc20334388 100644 --- a/fs/vfs/fs_statfs.c +++ b/fs/vfs/fs_statfs.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/vfs/fs_statfs.c * - * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2012, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -105,7 +105,7 @@ int statfs(FAR const char *path, FAR struct statfs *buf) /* Get an inode for this file */ - inode = inode_find(path, &relpath); + inode = inode_find(path, &relpath, false); if (!inode) { /* This name does not refer to a psudeo-inode and there is no diff --git a/fs/vfs/fs_unlink.c b/fs/vfs/fs_unlink.c index 29afe30e17d..7f1d97af7d5 100644 --- a/fs/vfs/fs_unlink.c +++ b/fs/vfs/fs_unlink.c @@ -1,7 +1,7 @@ /**************************************************************************** * fs/vfs/fs_unlink.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -39,8 +39,10 @@ #include +#include #include #include + #include #include "inode/inode.h" @@ -89,7 +91,7 @@ int unlink(FAR const char *pathname) * which may be a symbolic link) */ - inode = inode_find_nofollow(pathname, &relpath); + inode = inode_find(pathname, &relpath, true); if (!inode) { /* There is no inode that includes in this path */