I've made read/write function for device driver emulator like nvram or flash ram using memory buffer.(call it nvram emul driver)
Total buffer size is 1024
Total read/ total write is ok.
But, problem is llseek.
I don't know how I can use the specific positon for read/write function using llseek.
I think that offset is very important value for llseek.
But, I don't know or I don't understand how I can use it.
How can I use specific positon for llseek based on my read/write driver.
Do I need to fix ? or modify in detail?
#define BUFF_SIZE 1024
ssize_t ram_emul_read(uint32_t partition_id, char * buf, size_t count, loff_t offset)
ssize_t ram_emul_write( uint32_t partition_id, const char * buf, size_t count, loff_t offset)
if (BUFF_SIZE < count)
sz_data = BUFF_SIZE;
sz_data = count;
case 0: /* SEEK_SET */
newpos = off;
case 1: /* SEEK_CUR */
newpos = filep->f_pos + off;
case 2: /* SEEK_END */
newpos = ram_emul_get_partition_size(device->id) + off;
default: /* shouldn't happen */
// Unlock and return error
TRACE_END_ERR("Failed, invalid WHENCE parameter");
int ram_emul_get_partition_size(uint32_t partition_id)