-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allocating file with size (IDFGH-12035) #13100
Comments
Could you please provide more information about the issue you faced: version of ESP-IDF, the code to reproduce the issue, log output (if any), sdkconfig. Thanks in advance. |
i was using esp-rs with esp-idf version of 5.1.2 i got error maybe this is just because of my logging settings the message doesn't make any sense but i think it's just that there's something wrong handling esp-idf error i tried to track down where did this message came from but couldn't find it however it seems straightforward that fatfs will not truncate to extend the file length, instead return Permission error esp-idf/components/fatfs/vfs/vfs_fat.c Lines 1036 to 1042 in 7cbee80
|
Hello. You should be able to use
However I am not very familiar with Rust, so I don't know is this API is exposed to you. |
@adokitkat it seems to extend the file length and a lot faster than writing zeros |
Is your feature request related to a problem?
sometimes i have to create a file of certain size (for fseek)
it's not a major problem on conventional OSs since posix's ftruncate supports extending, iirc windows has similar feature too
If fildes refers to a regular file, the ftruncate() function shall cause the size of the file to be truncated to length. If the size of the file previously exceeded length, the extra data shall no longer be available to reads on the file. If the file previously was smaller than this size, ftruncate() shall increase the size of the file. If the file size is increased, the extended area shall appear as if it were zero-filled.
linux even supports fallocate() which creates a file without initialization
even if filesystem doesn't have a way to do this effectively it should just fill zero to ensure consistency
i found fatfs will reject if i try to extend the file using ftruncate
i don't know if it's also the case for other filesystems
Describe the solution you'd like.
support extending file with ftruncate for fatfs and other filesystems
better if we can get fallocate support
Describe alternatives you've considered.
extending file using such apis will be faster than writing zeros to the file
also preventing fragmentations
Additional context.
https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html
https://man7.org/linux/man-pages/man2/fallocate.2.html
The text was updated successfully, but these errors were encountered: