public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Enrique Perez-Terron <enrique@perezterron.net>
To: cygwin@cygwin.com
Subject: Re: pread() from /dev/sda fails with: Illegal seek
Date: Sat, 11 Jan 2020 20:24:00 -0000	[thread overview]
Message-ID: <9f7d495f0551f31b41b046db68ca59ae@perezterron.net> (raw)
In-Reply-To: <CAPJ9Yc-9SaxHRnTVHCFnbh1nuS9KV7ZJLqqB=ES=Ymnc9EaWSg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1118 bytes --]

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

[-- Attachment #2: 0xD6B3CEE5.asc --]
[-- Type: application/pgp-keys, Size: 3107 bytes --]

[-- Attachment #3: Type: text/plain, Size: 219 bytes --]


--
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

  reply	other threads:[~2020-01-11 20:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-11 14:10 David Balažic
2020-01-11 20:24 ` Enrique Perez-Terron [this message]
2020-01-12 16:59 ` Christian Franke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9f7d495f0551f31b41b046db68ca59ae@perezterron.net \
    --to=enrique@perezterron.net \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).