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

David Balažic
Sat Jan 11 14:10:00 GMT 2020


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck-s
Type: application/octet-stream
Size: 12161 bytes
Desc: not available
URL: <>
-------------- next part --------------

Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list