Re: BLKGETSIZE64 (bytes or sectors?)

Tim Pepper (tpepper@vato.org)
Thu, 17 Jan 2002 13:12:45 -0800


On Thu 17 Jan at 14:28:52 -0600 Matt_Domsch@Dell.com done said:
> 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.

I was just in the process of writing a post for the same thing. Wouldn't it
be better to do the following (against 2.4.17).

Tim

-- 
*********************************************************
*  tpepper@vato dot org             * Venimus, Vidimus, *
*  http://www.vato.org/~tpepper     * Dolavimus         *
*********************************************************

--- linux-2.4.17-orig/blkpg.c Thu Jan 17 13:02:19 2002 +++ linux-2.4.17/blkpg.c Thu Jan 17 13:06:33 2002 @@ -246,8 +246,14 @@ if (cmd == BLKGETSIZE) return put_user((unsigned long)ullval, (unsigned long *)arg); - else + else { + if (hardsect_size[MAJOR(dev)][MINOR(dev)]) { + ullval *= hardsect_size[MAJOR(dev)][MINOR(dev)]; + } else { + ullval *= 512; + } return put_user(ullval, (u64 *)arg); + } #if 0 case BLKRRPART: /* Re-read partition tables */ if (!capable(CAP_SYS_ADMIN)) - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/