Messages in this thread | | | Date | Wed, 22 Dec 1999 18:03:32 -0500 | Subject | Re: Ok, making ready for pre-2.4 and code-freeze.. | From | tytso@mit ... |
| |
Date: Tue, 21 Dec 1999 23:50:24 +0100 (MET) From: R.E.Wolff@bitwizard.nl (Rogier Wolff)
Yes, lseek takes a signed as an argument: You need to be able to seek to "10 bytes before where i'm now." and things like that.
lseek returns the resulting offset from the beginning of the file.
So, in this case it should return 0xc481ad8c, which is a negative number. So the library would set errno to 3b7e5274 and return -1. My guess is that lseek returns 0 in that case. So lseek is no longer conforming to the manpage which states that it will return the offset from the beginning.
This is why the Ext2 filesystem in 2.2 limits file sizes to 2 Gig in order to achieve POSIX compatibility. You aren't allowed to create a file bigger than 2 Gigs since that would sometimes force lseek() to return a negative value, which would cause a POSIX violation. Reiserfs ignored this constraint, which is why they could offer 4 gig support --- if you try to create file that big, though, the results could violate POSIX if you called lseek() with a big file, and your application might do something surprising as a result. (This issue goes away in 2.4 since the 64 bit LFS support is finally in the kernel.)
Linux is "breaking the rules" a bit to provide useful functionality. But in reality, it is not posix-compliant.
Well, ext2 doesn't allow you to "break the rules", since doing so definitely breaks POSIX compatibility and could break some applications. But you're right that it's on a per-filesystem basis, and some special devices, such as /dev/mem, do let you "break the rules". Fortunately the Posix Compliance Test Suite doesn't test lseek() on special device files. :-)
- Ted
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |