Article 55T9W kernel_write function fails when appending to big file

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?latest?d=yIl2AUoC8zA latest?i=Xg8RE6WZgMg:wygIrdchw7I:F7zBnMy latest?i=Xg8RE6WZgMg:wygIrdchw7I:V_sGLiP latest?d=qj6IDK7rITs latest?i=Xg8RE6WZgMg:wygIrdchw7I:gIN9vFwXg8RE6WZgMg
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments