Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.


  Search this Thread
Old 06-07-2010, 11:31 PM   #1
LQ Newbie
Registered: May 2010
Posts: 24

Rep: Reputation: 0
How can I make device driver for llseek.

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)
    return count;

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;

    return count;


lseek function

    switch (whence)
        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");
            return -EINVAL;

int ram_emul_get_partition_size(uint32_t partition_id)

    return BUFF_SIZE;
Old 06-09-2010, 04:15 PM   #2
Senior Member
Registered: Apr 2009
Posts: 1,526

Rep: Reputation: 137Reputation: 137
In read/write function, 'offset' parameter is your current position.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make device driver built-in in initial ramdisk suo Linux - Kernel 2 08-12-2008 05:25 PM
Change network device driver code to make it default stevebeiko Programming 6 07-31-2008 05:16 AM
How to make use of a USB device driver? rockballad Programming 6 01-22-2008 07:59 PM
how can i make device driver diskette? mrship Linux - Hardware 0 06-21-2004 02:02 AM
Trouble running make to compile example scull device driver taillefer Programming 3 03-23-2004 01:53 AM > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 02:13 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration