Open
Description
I built the exfat module with the latest code on mainline.
I encountered a bug during the bellow experiment:
steps to reproduce:
- create 4G exfat filesystem.
- create a file and truncate to 3G.
- delete the file.
- repeat step 2 again.
- receive EIO, ftruncate failed.
Here is the script I used for testing:
#include <iostream>
#include <fcntl.h>
#include <unistd.h>
int main() {
const char* filename = "example_file";
off_t file_size = 3LL * 1024 * 1024 * 1024;
// Open the file or create it if it doesn't exist
int fd = open(filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if (fd == -1) {
std::cerr << "Error opening/creating the file" << std::endl;
return 1;
}
// Set the file size using ftruncate
if (ftruncate(fd, file_size) == -1) {
std::cerr << "Error setting file size using ftruncate" << std::endl;
close(fd);
return 1;
}
// Cleanup
close(fd);
return 0;
}
and this is a patch I wrote to fix the bug:
0001-fix-bug-ftruncate-failed.patch
Please help check if this modification is correct and necessary
Metadata
Metadata
Assignees
Labels
No labels