lseek() fails to seek on /dev/fd0 ('\\.\A:')

Egor Duda deo@logos-m.ru
Tue Feb 27 05:05:00 GMT 2001


Hi!

Tuesday, 27 February, 2001 Corinna Vinschen cygwin-patches@cygwin.com wrote:

CV> On Tue, Feb 27, 2001 at 12:45:39PM +0300, Egor Duda wrote:
>> CV> Did you try that even on raw partitions (\\.\X:)? From the MSDN:
>> 
>> CV> "The IOCTL_DISK_GET_DRIVE_GEOMETRY control code retrieves information
>> CV>  about the physical disk's geometry"
>>  
>> CV> so I assume it will only work for raw harddisks (\\.\physicaldriveN).
>> 
>> Yep,    you're    right.    I    can    work    around    this    with
>> IOCTL_DISK_GET_PARTITION_INFO  ioctl,  but here comes the problem with
>> off_t  and  size_t being long int :(  So we won't be able to work with
>> drives  and  partitions  longer  then  2G  (which  are  very  frequent
>> nowadays). Should we return EINVAL in such cases?

CV> I have just checked on Linux kernel 2.2.x. For some reason it returns
CV> the following on partitions and physical drives:

CV> lseek (fd, 0, SEEK_END) = 0 and the file pointer is set to the
CV> beginning(!) of the raw device.

CV> lseek (fd, pos != 0, SEEK_END) = -1 (EINVAL)

CV> So if we want to be Linux compatible we could make our life very easy.

CV> Has somebody a 2.4 kernel to test the behaviour there?

i've just tested it under 2.4.0. it seeks correctly from the end of device
and returns device_size + offset.

 if  return  value > 2G, it returns -1 with EOVERFLOW. I feel EFBIG is
more appropriate here, but it's arguable.

Egor.            mailto:deo@logos-m.ru ICQ 5165414 FidoNet 2:5020/496.19
floppy-lseek.diff
floppy-lseek.ChangeLog

-------------- next part --------------
2001-02-26  Egor Duda  <deo@logos-m.ru>

	* fhandler_floppy.cc (fhandler_dev_floppy::lseek): Determine
	drive geometry to allow seeking from the end of raw floppy
	device. Don't allow reading past the end of media. Always return
	new file pointer position.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: floppy-lseek.diff
Type: text/x-diff
Size: 4881 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20010227/9ec2ee67/attachment.bin>


More information about the Cygwin-patches mailing list