This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: happily messing up with raw devices (aka: lseek problems)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Corinna Vinschen wrote:
> I really thought you know better.

But you know that using a "user" mailing list you can't resist to do
silly question ;-)
Except jokes, what I really forgot to tell is that the program is still
that small (119 lines) that would be a good testcase in itself (and for
now it is O_RDONLY so there is no probability it will do strange things
to the hard drive).

Seek error in file [/dev/sdb] (-1/22528): Invalid argument

That would be an error 22 aka EINVAL at line 93 of gagulator.c
(which should be downloadable from here: http://tinyurl.com/77jne )

> - What about a simple testcase(tm) to demonstrate the problem?

At the bare minumum it all boils down to:

% cat short.c
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#define GAG_OFFSET 0x59BD
main() {
  char sect[512];
  int dev, i;
  dev = open("/dev/sdb", O_RDONLY | O_BINARY, 0);
  if (dev < 0) perror("open");
  i = lseek(dev, GAG_OFFSET & (~0x1FF), SEEK_SET);
  if (i < 0) perror("seek");
}
% gcc -O -ggdb -o short short.c
% ./short
seek: Invalid argument

- --
L a p o   L u c h i n i
l a p o @ l a p o . i t
w w w . l a p o . i t /
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iEYEARECAAYFAkMfLW0ACgkQaJiCLMjyUvucyACg4Geer9+n3vT2y7BaiLncK1bO
XHkAoLbXI9BRkeVM8QZXBtMOzZ4yzkVW
=p98+
-----END PGP SIGNATURE-----

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]