# How do I make my device driver respond to lseek?



## EMBAUD (Dec 2, 2017)

Hi,

  I've been trying to figure out how to make my device driver respond to lseek.  There doesn't seem to be an appropriate entry in the cdevsw structure (in src/sys/sys/conf.h).

  Obviously I can make an ioctl call for this, but I'd like to do it it the right way.

  FWIW, this is a device driver interface to a SPI flash in my custom embedded system. I need 
to be able to locate to a point in the flash to read and write my app config info, without 
disturbing my boot loader.

  I want to be able to write code like this:


```
int fd = open ("/dev/my_spi_flash0", O_RDWR);
    lseek(fd, 0x10000, SEEK_SET);
    write(fd, buf, 100);
    close(fd);
```
  Does anyone know the proper way to implement lseek? 

  Thank you


----------



## ronaldlees (Dec 3, 2017)

Hi: 

Your best bet is to use the developer's mailing list:

_https://lists.freebsd.org/mailman/listinfo_

This forum is typically meant for user issues and IT issues and such.  You won't see much code here, other than scripts.   Developers stop by here, but they'll be more likely to answer questions on one of the lists.  Be sure to pick the right architecture.

BTW:  Welcome to the forums!


----------



## EMBAUD (Dec 3, 2017)

ronaldlees said:


> BTW:  Welcome to the forums!



Thanks!  I'll try there.  If anyone sees this and wants to comment, I'm still checking the forum too.


----------

