Abhishekmishra2808 commented on code in PR #19900:
URL: https://github.com/apache/nuttx/pull/19900#discussion_r3968505472
##########
fs/vfs/fs_close.c:
##########
@@ -34,6 +34,7 @@
#include <nuttx/cancelpt.h>
#include <nuttx/fs/fs.h>
+#include <nuttx/lib/lib.h>
Review Comment:
Reverted this extra include.
##########
fs/vfs/Make.defs:
##########
@@ -29,6 +29,10 @@ CSRCS += fs_rename.c fs_rmdir.c fs_select.c fs_sendfile.c
fs_stat.c
CSRCS += fs_statfs.c fs_uio.c fs_unlink.c fs_write.c fs_dir.c fs_fsync.c
CSRCS += fs_syncfs.c fs_truncate.c fs_link.c
+ifeq ($(CONFIG_FS_CHROOT),y)
+CSRCS += fs_chroot.c
Review Comment:
Moved to chroot patch.
##########
fs/vfs/fs_rename.c:
##########
@@ -96,20 +101,20 @@ static int pseudorename(FAR const char *oldpath, FAR
struct inode *oldinode,
ret = inode_checkperm(oldparent, W_OK);
if (ret < 0)
{
- goto errout_with_lock;
+ goto errout_with_newsearch;
}
/* According to POSIX, any new inode at this path should be removed
* first, provided that it is not a directory.
*/
- ret = inode_search(&newdesc);
+ ret = inode_search(&newdesc, &newinode);
if (ret >= 0)
{
/* We found it. Get the search results */
- newinode = newdesc.node;
DEBUGASSERT(newinode != NULL);
+ inode_addref(newinode);
Review Comment:
Dropped the extra addref.
##########
fs/vfs/fs_rename.c:
##########
@@ -188,24 +193,40 @@ static int pseudorename(FAR const char *oldpath, FAR
struct inode *oldinode,
* of zero.
*/
+ inode_release(newinode);
+ newinode = NULL;
+
ret = inode_reserve(newpath, 0777, &newinode);
if (ret < 0)
{
- goto errout_with_lock;
+ goto errout_with_newsearch;
}
/* Re-resolve the source under the same lock before unlinking it. */
- SETUP_SEARCH(&olddesc, oldpath, true);
- ret = inode_search(&olddesc);
- RELEASE_SEARCH(&olddesc);
- if (ret < 0 || olddesc.node != oldinode)
+ ret = inode_search_setup(&olddesc, oldpath, true);
+ if (ret < 0)
{
+ goto errout_with_newsearch;
+ }
+
+ ret = inode_search(&olddesc, &oldfound);
+ inode_search_release(&olddesc);
+ if (ret >= 0)
+ {
+ inode_addref(oldfound);
Review Comment:
Dropped the extra addref.
##########
fs/vfs/fs_rename.c:
##########
@@ -188,24 +193,40 @@ static int pseudorename(FAR const char *oldpath, FAR
struct inode *oldinode,
* of zero.
*/
+ inode_release(newinode);
+ newinode = NULL;
Review Comment:
Removed the extra zero.
##########
fs/vfs/fs_rename.c:
##########
@@ -188,24 +193,40 @@ static int pseudorename(FAR const char *oldpath, FAR
struct inode *oldinode,
* of zero.
*/
+ inode_release(newinode);
+ newinode = NULL;
+
ret = inode_reserve(newpath, 0777, &newinode);
if (ret < 0)
{
- goto errout_with_lock;
+ goto errout_with_newsearch;
}
/* Re-resolve the source under the same lock before unlinking it. */
- SETUP_SEARCH(&olddesc, oldpath, true);
Review Comment:
Removed the extra re-resolve.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]