feat(dfs_lfs): Add RT_FIOFTRUNCATE functionality#31
Merged
Rbb666 merged 1 commit intoRT-Thread-packages:masterfrom Jan 26, 2026
Merged
feat(dfs_lfs): Add RT_FIOFTRUNCATE functionality#31Rbb666 merged 1 commit intoRT-Thread-packages:masterfrom
Rbb666 merged 1 commit intoRT-Thread-packages:masterfrom
Conversation
WalkthroughAdds an RT_FIOFTRUNCATE IOCTL case in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Collaborator
Author
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@dfs_lfs.c`:
- Around line 744-753: The code casts length (off_t) directly to lfs_off_t when
calling lfs_file_truncate (using dfs_lfs_fd->lfs and dfs_lfs_fd->u.file), which
can wrap on platforms where off_t is wider than lfs_off_t; before calling
lfs_file_truncate, validate that length is within the lfs_off_t range
(non-negative and <= the maximum representable value for lfs_off_t, e.g.
(lfs_off_t)UINT32_MAX or an LFS-provided max) and return -EINVAL if out of
range, then perform the cast only after the check.
- Around line 731-752: The handler currently calls lfs_file_truncate without
checking the open mode; add an access-control check on the incoming file before
calling lfs_file_truncate: inspect file->flags (the same flags used when the
descriptor was opened) to ensure the descriptor was opened for writing (e.g.,
O_WRONLY or O_RDWR / RT_FOPEN_FLAG_WRONLY/RT_FOPEN_FLAG_RDWR), and if not return
an appropriate error (e.g., -EACCES or -EBADF) instead of calling
lfs_file_truncate on dfs_lfs_fd_t->u.file.
d6ffc7e to
265d692
Compare
Rbb666
approved these changes
Jan 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.