From: Andries.Brouwer@cwi.nl
To: Matt_Domsch@dell.com, tpepper@vato.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: BLKGETSIZE64 (bytes or sectors?)
Date: Thu, 17 Jan 2002 23:48:16 GMT [thread overview]
Message-ID: <UTC200201172348.XAA420548.aeb@cwi.nl> (raw)
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
next reply other threads:[~2002-01-17 23:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-17 23:48 Andries.Brouwer [this message]
2002-01-18 0:21 ` BLKGETSIZE64 (bytes or sectors?) Tim Pepper
-- 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 20:28 Matt Domsch
2002-01-17 21:12 ` Tim Pepper
2002-01-17 22:47 ` Benjamin LaHaise
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=UTC200201172348.XAA420548.aeb@cwi.nl \
--to=andries.brouwer@cwi.nl \
--cc=Matt_Domsch@dell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tpepper@vato.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox