From: "Malcolm H. Teas" <mhteas@btech.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: alan@redhat.com
Subject: [PATCH] Ramdisk ioctl bug fix, kernel 2.4.14
Date: Mon, 12 Nov 2001 20:39:22 -0600 [thread overview]
Message-ID: <3BF087DA.2010908@btech.com> (raw)
The patch below makes the ramdisk return the actual size that is currently
allocated instead of returning the max size we can possibly allocate. Affects
system calls ioctl(filedes, BLKGETSIZE) and ioctl(filedes, BLKGETSIZE64) for
ramdisk devices.
Malcolm Teas
mhteas@btech.com
http://www.btech.com
Austin, TX USA
--- linux-2.4.14/drivers/block/rd.c Thu Oct 25 15:58:35 2001
+++ linux/drivers/block/rd.c Mon Nov 12 20:15:16 2001
@@ -40,6 +40,9 @@
*
* Make block size and block size shift for RAM disks a global macro
* and set blk_size for -ENOSPC, Werner Fink <werner@suse.de>, Apr '99
+ *
+ * Make BLKGETSIZE and BLKGETSIZE64 return the actual allocated size, not
+ * the max possible allocated size - Malcolm Teas Nov 2001
*/
#include <linux/config.h>
@@ -349,6 +352,7 @@
{
int error = -EINVAL;
unsigned int minor;
+
unsigned long size;
if (!inode || !inode->i_rdev)
goto out;
@@ -373,10 +377,12 @@
case BLKGETSIZE: /* Return device size */
if (!arg)
break;
-
error = put_user(rd_kbsize[minor] << 1, (unsigned long *) arg);
+
size = (rd_bdev[minor]->bd_inode->i_mapping->nrpages * PAGE_SIZE) >> 9;
+
error = put_user(size, (unsigned long *) arg);
break;
case BLKGETSIZE64:
-
error = put_user((u64)rd_kbsize[minor]<<10, (u64*)arg);
+
size = rd_bdev[minor]->bd_inode->i_mapping->nrpages;
+
error = put_user((u64) (size * PAGE_SIZE), (u64*)arg);
break;
case BLKROSET:
case BLKROGET:
next reply other threads:[~2001-11-13 2:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-11-13 2:39 Malcolm H. Teas [this message]
2001-11-13 9:16 ` [PATCH] Ramdisk ioctl bug fix, kernel 2.4.14 Alan Cox
2001-11-13 14:04 ` Malcolm H. Teas
2001-11-13 16:56 ` Alan Cox
2001-11-13 20:15 ` Malcolm H. Teas
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=3BF087DA.2010908@btech.com \
--to=mhteas@btech.com \
--cc=alan@redhat.com \
--cc=linux-kernel@vger.kernel.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