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

   ## Summary
   
   * `pseudorename()` handles an existing target that is not a directory by
     removing it and moving the old inode into its place, even when the old
     inode is a directory. POSIX requires `rename()` to fail with `ENOTDIR`
     when the old path names a directory and the new path names an existing
     file. `mountptrename()` already returns `ENOTDIR` in this case.
   * Return `-ENOTDIR` in `pseudorename()` too. `isdir` is now needed outside
     `CONFIG_FS_NOTIFY`, so its declaration is no longer conditional.
   
   ## Impact
   
   * New or changed feature: NO new feature. Changed behavior: renaming a
     pseudo file system directory onto an existing pseudo file now fails with
     `ENOTDIR` instead of replacing the file with the directory.
   * Impact on user: only callers relying on that non-POSIX replacement.
   * Impact on build: NO.
   * Impact on hardware: NO.
   * Impact on documentation: NO.
   * Impact on security: NO.
   * Impact on compatibility: aligns the pseudo file system with POSIX and with
     mount points.
   
   ## Testing
   
   I confirm that changes are verified on local setup and works as intended:
   * Build Host: Ubuntu 22.04 x86_64, gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0
   * Target: `sim:nsh` (`CONFIG_PSEUDOFS_FILE`), master 26adb69b76 (master is 
now 18767f5318; no new commit touches
     fs/vfs/fs_rename.c). Verified on sim
     only.
   
   `/pd` is a pseudo directory with a child `sub`, `/pf` a pseudo file holding
   `hello`.
   
   Testing logs before change:
   
   ```
   nsh> mv /pd /pf
   nsh> ls -l /pf
   /pf:
    drwxrwxrwx           0 2026-11-13 08:34 sub/
   nsh> cat /pf
   (the directory's binary contents)
   ```
   
   Testing logs after change:
   
   ```
   nsh> mv /pd /pf
   nsh: mv: rename failed: 20
   nsh> ls -l /pf
    -rw-rw-rw-           6 2026-11-13 08:34 /pf
   nsh> cat /pf
   hello
   ```
   
   Renaming a file onto a file, a directory onto a directory and a file onto
   a directory give the same output before and after the change.
   
   * `./tools/checkpatch.sh -m -g master..HEAD`: all checks pass.
   * Make and CMake builds pass with no new warnings; `ostest` exits with
     status 0.
   
   ## PR verification Self-Check
   
   * [x] This PR introduces only one functional change.
   * [x] I have updated all required description fields above.
   * [x] My PR adheres to Contributing Guidelines and Documentation (git commit
     title and message, coding standard, etc).
   * [ ] My PR is still work in progress (not ready for review).
   * [x] My PR is ready for review and can be safely merged into a codebase.
   


-- 
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