jingfei195887 opened a new pull request, #21728:
URL: https://github.com/apache/nuttx/pull/21728
## Summary
Fixes in unionfs found while exercising it on `sim:nsh`:
- `unionfs_open()` leaked the file container when the path failed to open
on both file systems.
- `unionfs_seek()`, `unionfs_read()` and `unionfs_write()` only moved the
lower file. `file_seek()` returns `filep->f_pos`, so `lseek()` reported
a stale offset and `pread()`/`pwrite()` restored the wrong position, so
the next `write()` landed at the wrong place.
- `unionfs_opendir()` returned OK after freeing the directory when
`strdup()` failed. It now returns -ENOMEM.
- `unionfs_statfs()` multiplied `f_blocks` into the block size ratio, so
the combined block counts were wrong when the two block sizes differ.
- A few comments named the wrong file system or operation.
## Impact
Behavior changes only where the old code was wrong. There is no API change.
## Testing
Host: Ubuntu x86_64, gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0, master
59cb24ea20 (rebased onto 59cb24ea20; no new
commit touches fs/unionfs), `sim:nsh` with `CONFIG_FS_TMPFS` and
`CONFIG_FS_UNIONFS`. tmpfs (512-byte blocks, 1 block) on `/ut` and hostfs
(4096-byte blocks, 240075524 blocks) on `/uh` are combined with
`mount -t unionfs -o fspath1=/ut,fspath2=/uh /u`. A small test program:
| step | master | this PR |
|---|---|---|
| 20 opens of a missing file: heap growth | 960 bytes | 0 |
| `write(10)`, then `lseek(SEEK_CUR)` | 0 | 10 |
| `lseek(2)` + `read(4)`, then `lseek(SEEK_CUR)` | 0 | 6 |
| `pread(2, offset 0)`, then `lseek(SEEK_CUR)` | 0 | 6 |
| `write("XY")`, then `pread(4, offset 5)` | "5678" | "5XY8" |
| `statfs("/u")` blocks (512-byte units; expected 1 + 240075524 * 8 =
1920604193) | 942719105 | 1920604193 |
The `opendir()` -ENOMEM path is covered by review only.
- `./tools/checkpatch.sh -g master..HEAD`: all checks pass.
- Make and CMake builds pass; `ostest` exits with status 0.
--
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]