title: Lseek SEEK_END not working?
body: <p>I'm working on a C program with joysticks and I'd like to get last event which is as the last line of js0 file. I'm trying to move my cursor before the last element but it doesn't seem working. Any idea why?</p>
  
  <pre><code>int fd = open ("/dev/input/js0", O_RDONLY);
  struct js_event e;
  lseek(fd, -(sizeof(e)), SEEK_END);    
  read (fd, &amp;e, sizeof(e));
  switch(e.type){
      case JS_EVENT_BUTTON: printf("btn\n");
      break;
      case JS_EVENT_AXIS: printf("axes\n");
      break;
      default: printf("smth else\n");
  }
  </code></pre>
  
  <p>I'm sure the file I'm reading is at least (sizeof(e)) long. Lseek returns me -1 so I got errno and it was 29 - Illegal seek: why should this be an illegal seek? I get the same results even if I use 0 as offset</p>
  
  <pre><code>  lseek(fd, 0, SEEK_END)
  </code></pre>
  
  <p>I'm using last version Ubuntu,
  thanks for your help</p>