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

Enrique Perez-Terron enrique@perezterron.net
Sat Jan 11 20:24:00 GMT 2020


Den 2020-01-11 15:10, skrev David Balažic:
> pread on /dev/sda fails with Illegal seek.

Confirmed on windows 10, 64-bit.

My code:
$ cat t.c
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <fcntl.h>

int main(int argc, char *argv[])
{
         int fd = open("/dev/sda", O_RDONLY, 0);
         if (fd < 0) {
                 fprintf(stderr, "%s. open /dev/sda: %m\n", argv[0]);
                 exit(1);
         }
         char *buffer = malloc(512);
         if (!buffer) {
                 fprintf(stderr, "%s: Out of memory\n", argv[0]);
                 exit(1);
         }
         int result = pread(fd, buffer, 512, 0);
         if (result < 0) {
                 fprintf(stderr, "%s: pread: %m\n", argv[0]);
                 exit(1);
         }
         printf("All right!\n");
         return 0;
}

Running in a mintty as Administrator:
$ ./t
./t: pread: Illegal seek

$ uname -a
CYGWIN_NT-10.0 panter 3.1.2(0.340/5/3) 2019-12-21 15:25 x86_64 Cygwin

$ cc --version
cc (GCC) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.


Regards,
Enrique Perez-Terron
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0xD6B3CEE5.asc
Type: application/pgp-keys
Size: 3107 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20200111/27438f71/attachment.bin>
-------------- next part --------------

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list