Il 09/05/2012 15:40, Kevin Wolf ha scritto: >> > +#ifndef SEEK_DATA >> > +#define SEEK_DATA 3 >> > +#endif >> > +#ifndef SEEK_HOLE >> > +#define SEEK_HOLE 4 >> > +#endif > How is that going to be portable? You assume that on non-Linux you'll > get -EINVAL, but what does guarantee that 3 or 4 aren't already used for > the standard SEEK_* constants or for a different non-standard extension?
While SEEK_* is not guaranteed by POSIX to be 0/1/2, the values is so old that there may still exist programs that hard-code the values (similar to O_RDONLY/O_WRONLY/O_RDWR, though probably not any other O_* constant). It would be quite unwise to define them to something else. Even MS-DOS reused the values! AFAIK this is the only extension of lseek that's ever been added. It was done on Solaris first and then in Linux and the BSDs. It used 3/4 there too, see for example http://bugs.python.org/msg119551 (Solaris) and http://mail-index.netbsd.org/tech-kern/2011/08/17/msg011231.html (NetBSD). Paolo