casaroli opened a new pull request, #20598: URL: https://github.com/apache/nuttx/pull/20598
## Summary In `inode_search()`, `name` points to the rest of the path, inside `desc->buffer`. When an intermediate node of the path is a soft link, `_inode_linktarget()` releases `desc->buffer` and sets it up again for the link target, usually with the same temporary buffer, so `name` then pointed into the link target. With `/bin` linked to `/mnt/bin`, `/bin/sh` was looked up as `/mnt/bin/bin` and failed with `ENOENT`. With `/usr/bin` linked to `/mnt/bin`, `/usr/bin/sh` worked only because the rest of that path lay beyond the end of the shorter link target. This PR copies the rest of the path before the link is followed and continues the search with the copy, which becomes `desc->buffer`. ## Impact A soft link in the middle of a path (`CONFIG_PSEUDOFS_SOFTLINKS`) resolves correctly, also when the link is directly under the root. ## Testing The run-time tests ran on a local branch that has this change and other pending changes on top of master; the builds are of this branch alone. qemu-armv8a, kernel build, QEMU 11 with HVF: after `ln -s /mnt/bin /bin` and `ln -s /mnt/bin /usr/bin` in NSH (a 9P share mounted at `/mnt`), `ls -l /bin/sh` shows the file and `/bin/sh -c 'echo sh-ok'` prints `sh-ok`, and scripts with `#!/bin/sh` and `#!/usr/bin/env` run. Before, `/bin/sh` failed with `ENOENT`. Builds with `-Wno-cpp -Werror`: `qemu-armv8a:nsh`, `qemu-armv8a:knsh`, `lm3s6965-ek:qemu-flat`. `tools/checkpatch.sh -c -u -m -g` passes. -- 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]
