I'm making a device driver. I've added code that is most relevant to read and llseek. I can enter and use read perfectly fine. But for some reason, llseek can't be entered. I have it listed in the file operations as llseek and match it to the function I want, the arguments appear to be good?
In dmesg, i get "inside READ" but no "inside SEEK" and no errors. Also no errors in terminal, or during compilation. I don't know c too well either.
main
int file = open("/dev/simple_char_driver", O_RDWR);
//read example, this works fine
printf("Enter how many bytes you want to read: \n");
int len[10];
scanf("%d", len);
char *ptr = malloc(*len * sizeof(char));
read(file, ptr, *len);
//llseek example, doesn't enter
int offset [10];
int whence [10];
scanf("%d",offset);
printf("Enter a value for whence: \n");
scanf("%d",whence);
llseek(file, offset, whence);
In my device driver:
loff_t simple_char_driver_seek (struct file *pfile, loff_t offset, int whence)
{
printk(KERN_ALERT "Inside SEEK");
return 0;
}
ssize_t simple_char_driver_read (struct file *pfile, char __user *buffer, size_t length, loff_t *offset)
{
printk(KERN_ALERT "Inside READ");
return 0;
}
struct file_operations simple_char_driver_file_operations = {
.owner = THIS_MODULE,
.open = simple_char_driver_open,
.release = simple_char_driver_close,
.read = simple_char_driver_read,
.write = simple_char_driver_write,
.llseek = simple_char_driver_seek,
};