casaroli commented on code in PR #20598: URL: https://github.com/apache/nuttx/pull/20598#discussion_r4248103754
##########
fs/inode/fs_inodesearch.c:
##########
@@ -681,64 +696,66 @@ int inode_search(FAR struct inode_search_s *desc, FAR
struct inode **inodep)
* does not exist.
*/
+ lib_put_tempbuffer(rest);
ret = status;
break;
}
- else
+
+ /* The node was a valid symbolic link and we have jumped
+ * to a different spot in the pseudo file system tree.
+ * Check if this took us to a mountpoint.
+ */
+
+ if (INODE_IS_MOUNTPT(newnode))
{
- if (newnode != inode)
- {
- /* The node was a valid symbolic link and we have
- * jumped to a different, spot in the pseudo file
- * system tree.
- */
+ /* Return the mountpoint information. NOTE that the
+ * last path to the link target was already set by
+ * _inode_linktarget().
+ */
- /* Check if this took us to a mountpoint. */
+ inode = newnode;
+ above = desc->parent;
+ left = desc->peer;
+ ret = OK;
- if (INODE_IS_MOUNTPT(newnode))
+ if (*desc->relpath != '\0')
+ {
+ FAR char *buffer = NULL;
+
+ buffer = lib_get_tempbuffer(PATH_MAX);
+ if (buffer == NULL)
{
- /* Return the mountpoint information.
- * NOTE that the last path to the link target
- * was already set by _inode_linktarget().
- */
-
- inode = newnode;
- above = desc->parent;
- left = desc->peer;
- ret = OK;
-
- if (*desc->relpath != '\0')
- {
- FAR char *buffer = NULL;
-
- buffer = lib_get_tempbuffer(PATH_MAX);
- if (buffer == NULL)
- {
- ret = -ENOMEM;
- }
- else
- {
- snprintf(buffer, PATH_MAX, "%s/%s",
- desc->relpath, name);
- lib_put_tempbuffer(desc->buffer);
- desc->buffer = buffer;
- relpath = buffer;
- ret = OK;
- }
- }
- else
- {
- relpath = name;
- }
-
- break;
+ lib_put_tempbuffer(rest);
+ ret = -ENOMEM;
}
-
- /* Continue from this new inode. */
-
- inode = newnode;
+ else
+ {
+ snprintf(buffer, PATH_MAX, "%s/%s",
+ desc->relpath, rest);
Review Comment:
Done: at a mountpoint the rest of the path is appended to desc->relpath in
place. relpath ends desc->buffer, which holds at least PATH_MAX bytes.
##########
fs/inode/fs_inodesearch.c:
##########
@@ -681,64 +696,66 @@ int inode_search(FAR struct inode_search_s *desc, FAR
struct inode **inodep)
* does not exist.
*/
+ lib_put_tempbuffer(rest);
ret = status;
break;
}
- else
+
+ /* The node was a valid symbolic link and we have jumped
+ * to a different spot in the pseudo file system tree.
+ * Check if this took us to a mountpoint.
+ */
+
+ if (INODE_IS_MOUNTPT(newnode))
{
- if (newnode != inode)
- {
- /* The node was a valid symbolic link and we have
- * jumped to a different, spot in the pseudo file
- * system tree.
- */
+ /* Return the mountpoint information. NOTE that the
+ * last path to the link target was already set by
+ * _inode_linktarget().
+ */
- /* Check if this took us to a mountpoint. */
+ inode = newnode;
+ above = desc->parent;
+ left = desc->peer;
+ ret = OK;
- if (INODE_IS_MOUNTPT(newnode))
+ if (*desc->relpath != '\0')
+ {
+ FAR char *buffer = NULL;
+
+ buffer = lib_get_tempbuffer(PATH_MAX);
+ if (buffer == NULL)
{
- /* Return the mountpoint information.
- * NOTE that the last path to the link target
- * was already set by _inode_linktarget().
- */
-
- inode = newnode;
- above = desc->parent;
- left = desc->peer;
- ret = OK;
-
- if (*desc->relpath != '\0')
- {
- FAR char *buffer = NULL;
-
- buffer = lib_get_tempbuffer(PATH_MAX);
- if (buffer == NULL)
- {
- ret = -ENOMEM;
- }
- else
- {
- snprintf(buffer, PATH_MAX, "%s/%s",
- desc->relpath, name);
- lib_put_tempbuffer(desc->buffer);
- desc->buffer = buffer;
- relpath = buffer;
- ret = OK;
- }
- }
- else
- {
- relpath = name;
- }
-
- break;
+ lib_put_tempbuffer(rest);
+ ret = -ENOMEM;
}
-
- /* Continue from this new inode. */
-
- inode = newnode;
+ else
+ {
+ snprintf(buffer, PATH_MAX, "%s/%s",
+ desc->relpath, rest);
+ lib_put_tempbuffer(rest);
+ lib_put_tempbuffer(desc->buffer);
+ desc->buffer = buffer;
+ relpath = buffer;
+ }
+ }
+ else
+ {
+ lib_put_tempbuffer(desc->buffer);
Review Comment:
Done: the mountpoint case and the continue case now share the buffer swap.
--
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]
