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

   ## Summary
   
   `fstatat()` takes `AT_EMPTY_PATH`, which means the file of `dirfd` itself. 
`fchmodat()` and `fchownat()` look up the empty path and fail with `ENOENT`.
   
   With an empty path and `AT_EMPTY_PATH`, this PR makes `fchmodat()` call 
`fchmod()` on `dirfd` and `fchownat()` call `fchown()`, as `fstatat()` calls 
`fstat()`. With `AT_FDCWD` they operate on the current working directory. The 
doc comments name the flags.
   
   ## Impact
   
   libc only, so all build modes and architectures. A call with an empty path 
and `AT_EMPTY_PATH` now works. Any other call does not change: an empty path 
without the flag still fails with `ENOENT`. This adds to the behaviour of two 
flat-build functions, and no existing correct call changes. No Documentation 
change: nothing in `Documentation/` describes these flags.
   
   ## Testing
   
   Test program, on a file in tmpfs: `fchmodat(fd, "", 0600, AT_EMPTY_PATH)`, 
`fchownat(fd, "", uid, gid, AT_EMPTY_PATH)`, `fstatat(fd, "", &st, 
AT_EMPTY_PATH)` must see the new mode, and `fchmodat(fd, "", 0644, 0)` must 
fail with `ENOENT`. It is not in apps; a regression guard would need an apps PR.
   
   | Config | master bf029a2ef5d | this branch |
   |---|---|---|
   | `qemu-armv8a:nsh` (flat), HVF | 3 failed, ostest status 0 | 0 failed, 
ostest status 0 |
   | `qemu-armv8a:knsh` (kernel), HVF | 3 failed, ostest status 0 | 0 failed, 
ostest status 0 |
   | `mps2-an500:knsh` (protected), TCG | 3 failed, ostest status 0 | 0 failed, 
ostest status 0 |
   
   Master, the same in all three:
   
   ```
   atempty: chmod   FAIL (errno 2)
   atempty: chown   FAIL (errno 2)
   atempty: stat    FAIL (errno 0)
   atempty: noflag  PASS (errno 2)
   ```
   
   The `stat` case fails on master because the mode did not change. Options: 
`FS_TMPFS`, `SCHED_USER_IDENTITY`, `PSEUDOFS_ATTRIBUTES`, `FS_PERMISSION`. 
tmpfs has `chstat` only with `FS_PERMISSION`; without it `fchmod()` returns 
`ENOSYS`. `mps2-an500:knsh` also has `TLS_LOG2_MAXSTACK=15`, for the stack of 
the test. Not run: the `AT_FDCWD` path, and other file systems. Compilers: 
aarch64 GCC 14.2, arm-none-eabi GCC 15.3.
   
   `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