xiaoxiang781216 commented on code in PR #19585:
URL: https://github.com/apache/nuttx/pull/19585#discussion_r3695726374
##########
fs/vfs/fs_rename.c:
##########
@@ -162,57 +162,43 @@ static int pseudorename(FAR const char *oldpath, FAR
struct inode *oldinode,
* won't really be removed until we call inode_release();
*/
- inode_remove(newpath);
+ ret = inode_remove(newpath);
+ if (ret < 0 && ret != -EBUSY)
+ {
+ goto errout_with_lock;
+ }
+
#ifdef CONFIG_FS_NOTIFY
notify_unlink(newpath);
#endif
}
-
- inode_release(newinode);
- }
-
- /* Re-resolve the final destination parent after path rewrite. */
-
- SETUP_SEARCH(&pardesc, newpath, true);
- inode_find(&pardesc); /* pardesc.parent valid even if node not found */
- parnode = pardesc.node;
-
- ret = inode_checkperm(pardesc.parent, W_OK);
-
- /* inode_find() holds a reference on parnode; RELEASE_SEARCH() only
- * frees pardesc.buffer.
- */
-
- if (parnode != NULL)
- {
- inode_release(parnode);
- }
-
- RELEASE_SEARCH(&pardesc);
-
- if (ret < 0)
- {
- goto errout;
}
/* Create a new, empty inode at the destination location.
* NOTE that the new inode will be created with a reference count
* of zero.
*/
- inode_lock();
ret = inode_reserve(newpath, 0777, &newinode);
if (ret < 0)
{
- /* It is an error if a node at newpath already exists in the tree
- * OR if we fail to allocate memory for the new inode (and possibly
- * any new intermediate path segments).
- */
+ goto errout_with_lock;
+ }
- ret = -EEXIST;
+ /* Re-resolve the source under the same lock before unlinking it. */
+
+ SETUP_SEARCH(&olddesc, oldpath, true);
+ ret = inode_search(&olddesc);
+ if (ret < 0 || olddesc.node != oldinode)
+ {
+ inode_remove(newpath);
+ ret = -ENOENT;
+ RELEASE_SEARCH(&olddesc);
Review Comment:
move before line 192 and remove line 200
##########
sched/environ/env_secureexec.c:
##########
@@ -0,0 +1,171 @@
+/****************************************************************************
+ * sched/environ/env_secureexec.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#ifndef CONFIG_DISABLE_ENVIRON
Review Comment:
but CONFIG_DISABLE_ENVIRON is already checked in Makefile
--
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]