public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Ramdisk ioctl bug fix, kernel 2.4.14
@ 2001-11-13  2:39 Malcolm H. Teas
  2001-11-13  9:16 ` Alan Cox
  0 siblings, 1 reply; 5+ messages in thread
From: Malcolm H. Teas @ 2001-11-13  2:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: alan

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:


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

end of thread, other threads:[~2001-11-13 20:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-11-13  2:39 [PATCH] Ramdisk ioctl bug fix, kernel 2.4.14 Malcolm H. Teas
2001-11-13  9:16 ` 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

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