* question about pread() while reading /dev/sdb
@ 2017-06-06 17:27 joso
2017-06-07 9:34 ` Corinna Vinschen
0 siblings, 1 reply; 2+ messages in thread
From: joso @ 2017-06-06 17:27 UTC (permalink / raw)
To: cygwin
Hello, I'm porting tool from Linux envirmnment to Windows Cygwin.
I'm unable to get correct data from pread() while reading /dev/sdx
On Linux it works as expected, under Cygwin I receive uncorrect data.
I have isolated the problem with the following program:
#include stdio.h
#include sys/types.h
#include sys/stat.h
#include fcntl.h
#include unistd.h
int main(int argc, char *argv[])
{
unsigned char sbuff[512];
int f1;
f1=open(argv[1], O_RDWR);
pread(f1, sbuff, 512, 0);
for(int i=0; i 512; i++) printf("%x ",sbuff[i]);
close(f1);
}
If the argument is regular file it works. But if the argument is /dev/sdb it does not provide correct data. The shell is run under Administrator permission.
Thank you for your opinion.
Josef
--
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: question about pread() while reading /dev/sdb
2017-06-06 17:27 question about pread() while reading /dev/sdb joso
@ 2017-06-07 9:34 ` Corinna Vinschen
0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2017-06-07 9:34 UTC (permalink / raw)
To: cygwin
[-- Attachment #1: Type: text/plain, Size: 1150 bytes --]
On Jun 6 19:27, joso@post.cz wrote:
> Hello, I'm porting tool from Linux envirmnment to Windows Cygwin.
> I'm unable to get correct data from pread() while reading /dev/sdx
> On Linux it works as expected, under Cygwin I receive uncorrect data.
>
> I have isolated the problem with the following program:
>
> #include stdio.h
> #include sys/types.h
> #include sys/stat.h
> #include fcntl.h
> #include unistd.h
>
> int main(int argc, char *argv[])
> {
> unsigned char sbuff[512];
> int f1;
> f1=open(argv[1], O_RDWR);
> pread(f1, sbuff, 512, 0);
> for(int i=0; i 512; i++) printf("%x ",sbuff[i]);
> close(f1);
> }
>
> If the argument is regular file it works. But if the argument is /dev/sdb it does not provide correct data. The shell is run under Administrator permission.
> Thank you for your opinion.
Cygwin's pread is only implemented for regular files at the moment,
for all other objects it returns -1 with errno set to ESPIPE.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-07 9:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-06 17:27 question about pread() while reading /dev/sdb joso
2017-06-07 9:34 ` Corinna Vinschen
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).