kernel_write function fails when appending to big file
by NoKernel from LinuxQuestions.org on (#55T9W)
The task is to create simple character device driver, which will copy all the data passed to the device into /tmp/output file.
Code: struct file* destFile;
size_t res;
char* filePath = "/tmp/output";
destFile = filp_open(filePath, O_CREAT|O_WRONLY|O_APPEND, 0666);
if (IS_ERR(destFile) || destFile == NULL) {
printk("Cannot open destination file");
return;
}
res = kernel_write(destFile, buf, size, offset);
printk("%ld", res);
filp_close(destFile, NULL);This code work fine in most cases. But when "/tmp/output" file size become bigger than 2.1GB, kernel_write function starts to return -27 (i.e File too large).
Can someone provide solution to this problem?


Code: struct file* destFile;
size_t res;
char* filePath = "/tmp/output";
destFile = filp_open(filePath, O_CREAT|O_WRONLY|O_APPEND, 0666);
if (IS_ERR(destFile) || destFile == NULL) {
printk("Cannot open destination file");
return;
}
res = kernel_write(destFile, buf, size, offset);
printk("%ld", res);
filp_close(destFile, NULL);This code work fine in most cases. But when "/tmp/output" file size become bigger than 2.1GB, kernel_write function starts to return -27 (i.e File too large).
Can someone provide solution to this problem?