lkml.org 
[lkml]   [2000]   [Sep]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Bug in block device read/write!
On Fri, Sep 08, 2000 at 03:41:27AM +0100, Anton Altaparmakov wrote:

> [kernel-2.4.0-test3 to kernel-2.4.0-test8-pre6, bug present in those two,
> didn't try others]
>
> I have been trying to get the linear md driver to work with NTFS volumes
> for several months and it never worked. - I was suspecting the NTFS driver
> (after having fixed linear md and verified that at least that worked fine)
> but today I finally found why it doesn't work:
>
> There is a bug in reading/writing to block devices. - It manifests itself
> in the form that partitions are too small by exactly one sector!
>
> Even though a cfdisk shows that a partition has a certain number of
> sectors, you can never seek + read and/or write to the last sector (doing
> file i/o using read/write(2) [also tried fread/fwrite(3), same result]. -
> Last sector doesn't seem to exist. However reading the actual hd (/dev/hdb
> or /dev/sda, ie. affects both IDE and SCSI) instead of the partition
> (/dev/hdb7 or whatever) the sector does exist and contains the expected
> information!

The size of a partition (as seen by fdisk) is a number of 512-byte sectors.
The size of a partition (as seen by the kernel, for reading and writing)
is a number of 1024-byte blocks. This number is 1 for an extended partition
(just enough to put LILO there) and number_of_sectors/2 otherwise.

[see fs/partitions/check.c:grok_partitions()
dev->sizes[i] = dev->part[i].nr_sects >> (BLOCK_SIZE_BITS - 9);
]

Thus, indeed, if the number of sectors in the partition is odd
you are presently unable to read the last sector by accessing
the partition, but you can access it via the whole-disk device.


Andries
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:38    [W:0.044 / U:6.716 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site