Sepehr Ganji commented: 
https://gitlab.rtems.org/groups/rtems/-/work_items/25#note_129286


I've wrapped up the tests by fixing the `fsformat` and `fserror` test:

1. **Fixed Parameter Structure Mismatch in Formatting**  
   The test suite used a custom `mkfs_parm` structure with mismatched fields 
compared to FatFS’s `MKFS_PARM`. This caused parameter corruption when calling 
`f_mkfs()`. I wrote a conversion function in `fatfs_format_disk()` to translate 
between the two structures, handling field mapping and unit conversions 
correctly.

2. **Removed Invalid Parameter Test Expectation**  
   The tests expected FatFS to reject invalid parameters (e.g., `num_fat=7`), 
but FatFS clamps invalid values instead of failing. This mismatch caused 
assertion errors. I removed the invalid parameter test and added documentation 
clarifying FatFS’s actual behavior.

3. **Corrected Hardcoded Block Size in RTEMS Wrapper**  
   The wrapper always set `st_blksize = 512`, ignoring FatFS’s actual cluster 
size. This caused cluster-related assertions to fail. I fixed this by reading 
the cluster size from `fs_info->fatfs.csize` and calculating the correct values 
for both `st_blksize` and `st_blocks`.

4. **Aligned Test Expectations with FatFS Defaults**  
   The tests assumed specific default cluster sizes, but FatFS determines them 
dynamically based on volume size and constraints. For example, the test 
expected 8 sectors/cluster but FatFS chose 4. I updated the test expectations 
to match FatFS’s real behavior, ensuring consistency.

5. **Enabled Large Volume Formatting**  
   The tests tried formatting volumes up to 128GB using `FM_FAT` (FAT12/16), 
which is invalid because FAT16 only supports up to ~2GB. FatFS returned 
`FR_MKFS_ABORTED` for larger volumes. I changed the format type to `FM_ANY`, 
allowing FatFS to automatically select the appropriate FAT type (12/16/32), 
enabling successful formatting of all volumes.

6. **Fixed Incorrect Error on Invalid Path Traversal**  
   When unlinking a path like `"tmp/file/dir"` where `"file"` was not a 
directory, the test expected `ENOTDIR` but got `EACCES`. The issue was in 
`rtems_fatfs_eval_token()`, which attempted to traverse through regular files. 
I added a check to validate directory nodes before traversal, returning 
`ENOTDIR` immediately when invalid, achieving POSIX compliance.

7. **Implemented Proper lseek() EOVERFLOW Handling**  
   The `lseek()` test with extremely large offsets expected `EOVERFLOW` but 
returned `EINVAL` due to integer overflow during arithmetic. I fixed this by 
adding proactive overflow checks before performing calculations in both 
`SEEK_CUR` and `SEEK_END`. Now operations that would exceed the maximum 
representable offset correctly return `EOVERFLOW`.

-- 
View it on GitLab: 
https://gitlab.rtems.org/groups/rtems/-/work_items/25#note_129286
You're receiving this email because of your account on gitlab.rtems.org.


_______________________________________________
bugs mailing list
[email protected]
http://lists.rtems.org/mailman/listinfo/bugs

Reply via email to