casaroli opened a new pull request, #20593:
URL: https://github.com/apache/nuttx/pull/20593

   ## Summary
   
   The 9P server does not walk through a symbolic link and does not open one. 
On a v9fs mount, a path with a link in it was not found, a link to a file could 
not be opened, and `readlink()` and `lstat()` were not supported. Also, every 
failed lookup left a fid in the client's fid table.
   
   This PR has three commits:
   
   - Free the fid of a walk that does not reach the last name. The server 
creates the new fid only when it walks all names.
   - Follow symbolic links. When a walk ends at a link, the client reads it 
with `Treadlink`, puts the target in place of the link and walks again, up to 
`SYMLOOP_MAX` links (then `ELOOP`). The server walks the `.` and `..` names of 
the target inside the exported tree. Links on the way are always followed; the 
last name is followed by `open()` (unless `O_NOFOLLOW`), `opendir()`, `stat()` 
and `chstat()`, and not by `unlink()`, `rmdir()` and `rename()`, which act on 
the link. An absolute target names a file outside of the file system and is not 
found. `open()` now returns the error of the walk, such as `ELOOP`, instead of 
`ENOENT`, and creates a file only when the walk did not find it.
   - With `CONFIG_FS_LINKS`, add `readlink()` and `lstat()`.
   
   ## Impact
   
   v9fs mounts with symbolic links work. `rm` of a link removes the link, not 
its target. No change for shares without links.
   
   ## 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 on Apple M4, a 9P share 
(`security_model=none`) with links made on the host:
   
   ```
   cat flink                 (flink -> d/sub/f.txt)          hello
   cat dlink/sub/f.txt       (dlink -> d)                    hello
   cat chain                 (chain -> flink)                hello
   cat uplink                (uplink -> ../lt/d/sub/f.txt)   hello
   cat dlink/sublink/f.txt   (d/sublink -> sub)              hello
   cat loop1                 (loop1 -> loop2 -> loop1)       Too many symbolic 
links encountered
   cat abslink               (abslink -> /etc/hosts)         No such file or 
directory
   rm rmlink; cat target.txt (rmlink -> target.txt)          keep (the link is 
gone, the target stays)
   wc -l < tools/syscall_64.tbl  (link to ../../../scripts/syscall.tbl)  414
   readlink flink dlink uplink   d/sub/f.txt d ../lt/d/sub/f.txt
   test -L flink, test -L target.txt   link, not a link
   ls -l flink; stat -c %F flink; stat -L -c %F flink   lrwxr-xr-x, symbolic 
link, regular file
   ```
   
   Builds with `-Wno-cpp -Werror`: `qemu-armv8a:netnsh`, `qemu-armv8a:netnsh` 
with `CONFIG_FS_LINKS=y`, `qemu-armv8a:fastboot`. `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]

Reply via email to