pread() from /dev/sda fails with: Illegal seek

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

pread() from /dev/sda fails with: Illegal seek

David Balažic

I'm porting an app from Linux to Cygwin and stumbled on this problem:

pread on /dev/sda fails with Illegal seek.

The simplified code is:

#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main(int argc, char *argv[])
  unsigned int sector_size = 512;
  void *buf = calloc(sector_size,1);
  int fd = open("/dev/sda", O_DIRECT | O_RDONLY);
  if (-1 == pread(fd, buf, sector_size, 0)) {
    perror("pread failed");

# g++
# ./a  # run as adnministrator
pread failed: Illegal seek

Why is that?

cygcheck -s output attached.

Summary: cygwin 3.1.2-1  , Windows 8.1 , all 64 bit


Problem reports:
Unsubscribe info:

cygcheck-s (16K) Download Attachment