public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* BLKGETSIZE64 (bytes or sectors?)
@ 2002-01-17 20:28 Matt Domsch
  2002-01-17 21:12 ` Tim Pepper
  2002-01-17 22:47 ` Benjamin LaHaise
  0 siblings, 2 replies; 7+ messages in thread
From: Matt Domsch @ 2002-01-17 20:28 UTC (permalink / raw)
  To: linux-kernel

Is the BLKGETSIZE64 ioctl supposed to return the size of the device in 
bytes (as the comment says, and is implemented in all places *except* 
blkpg.c), or in sectors (as is implemented in blkpg.c since 2.4.15)?

It would seem that blkpg.c gets it wrong, that it should be in bytes.  
Assuming that's the case, here's the patch to fix it against 2.4.18-pre4.

Thanks,
Matt

-- 
Matt Domsch
Sr. Software Engineer
Dell Linux Solutions www.dell.com/linux
#1 US Linux Server provider with 24.5% (IDC Dec 2001)
#2 Worldwide Linux Server provider with 18.2% (IDC Dec 2001)


--- linux-2.4.18-pre4/drivers/block/blkpg.c.orig	Thu Jan 17 14:24:24 2002
+++ linux-2.4.18-pre4/drivers/block/blkpg.c	Thu Jan 17 14:26:43 2002
@@ -247,7 +247,7 @@ int blk_ioctl(kdev_t dev, unsigned int c
 			if (cmd == BLKGETSIZE)
 				return put_user((unsigned long)ullval, (unsigned long *)arg);
 			else
-				return put_user(ullval, (u64 *)arg);
+				return put_user((u64)ullval << 9 , (u64 *)arg);
 #if 0
 		case BLKRRPART: /* Re-read partition tables */
 			if (!capable(CAP_SYS_ADMIN)) 


^ permalink raw reply	[flat|nested] 7+ messages in thread
* RE: BLKGETSIZE64 (bytes or sectors?)
@ 2002-01-17 22:34 Matt_Domsch
  2002-01-17 22:46 ` Tim Pepper
  0 siblings, 1 reply; 7+ messages in thread
From: Matt_Domsch @ 2002-01-17 22:34 UTC (permalink / raw)
  To: tpepper; +Cc: linux-kernel

> Wouldn't it be better to do the following (against 2.4.17).

Yes, I agree.

--
Matt Domsch
Sr. Software Engineer
Dell Linux Solutions www.dell.com/linux
#1 US Linux Server provider with 24.5% (IDC Dec 2001)
#2 Worldwide Linux Server provider with 18.2% (IDC Dec 2001)

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: BLKGETSIZE64 (bytes or sectors?)
@ 2002-01-17 23:48 Andries.Brouwer
  2002-01-18  0:21 ` Tim Pepper
  0 siblings, 1 reply; 7+ messages in thread
From: Andries.Brouwer @ 2002-01-17 23:48 UTC (permalink / raw)
  To: Matt_Domsch, tpepper; +Cc: linux-kernel

Matt_Domsch@dell.com wrote, and he is right:

    > Is the BLKGETSIZE64 ioctl supposed to return the size of the device in 
    > bytes (as the comment says, and is implemented in all places *except* 
    > blkpg.c), or in sectors (as is implemented in blkpg.c since 2.4.15)?

Yes, in bytes. blkpg.c has to be fixed.
Several people submitted patches. Sooner or later I suppose
this will be fixed.

Then Tim Pepper answered, and he is wrong:

    Wouldn't it be better to do the following (against 2.4.17).

    +            else {
    +                if (hardsect_size[MAJOR(dev)][MINOR(dev)]) {
    +                    ullval *= hardsect_size[MAJOR(dev)][MINOR(dev)];
    +                } else {
    +                    ullval *= 512;
    +                }
                     return put_user(ullval, (u64 *)arg);
    +            }

You see, the 512 here is 512, and has no relation to hardware
sector size. Multiplying with hardsect_size[][] is a bad bug.

Indeed, you can check this in fs/partitions/msdos.c, where
one reads
	int sector_size = get_hardsect_size(to_kdev_t(bdev->bd_dev)) / 512;
	...
	offs = START_SECT(p)*sector_size;
	size = NR_SECTS(p)*sector_size;
	...
	add_gd_partition(...);

So, indeed, we have already multiplied by hardsect_size, struct gendisk
uses sectors of size 512, independent of the hardware, and we must not
again multiply by hardsect_size.

Unfortunately Matt Domsch replied:

    > Yes, I agree.

but he meant: No!

Andries

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-01-18  0:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-01-17 20:28 BLKGETSIZE64 (bytes or sectors?) Matt Domsch
2002-01-17 21:12 ` Tim Pepper
2002-01-17 22:47 ` Benjamin LaHaise
  -- strict thread matches above, loose matches on Subject: below --
2002-01-17 22:34 Matt_Domsch
2002-01-17 22:46 ` Tim Pepper
2002-01-17 23:48 Andries.Brouwer
2002-01-18  0:21 ` Tim Pepper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox