All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@zip.com.au>
To: lkml <linux-kernel@vger.kernel.org>, Alan Cox <alan@lxorguk.ukuu.org.uk>
Subject: scsi BLKGETSIZE breakage in -pre2
Date: Fri, 09 Nov 2001 23:34:23 -0800	[thread overview]
Message-ID: <3BECD87F.F53234B2@zip.com.au> (raw)

sd_ioctl() was changed to pass BLKGETSIZE off to blk_ioctl(),
but blk_ioctl() doesn't implement it.

So `cfdisk /dev/sda' is failing.

Simply copying the -ac version of blkpg.c across fixes
it for me.


--- linux-2.4.15-pre2/drivers/block/blkpg.c	Mon Oct 15 13:27:42 2001
+++ linux-akpm/drivers/block/blkpg.c	Fri Nov  9 23:14:23 2001
@@ -195,8 +195,13 @@ int blkpg_ioctl(kdev_t dev, struct blkpg
 
 int blk_ioctl(kdev_t dev, unsigned int cmd, unsigned long arg)
 {
+	struct gendisk *g;
+	u64 ullval = 0;
 	int intval;
 
+	if (!dev)
+		return -EINVAL;
+
 	switch (cmd) {
 		case BLKROSET:
 			if (!capable(CAP_SYS_ADMIN))
@@ -212,7 +217,7 @@ int blk_ioctl(kdev_t dev, unsigned int c
 		case BLKRASET:
 			if(!capable(CAP_SYS_ADMIN))
 				return -EACCES;
-			if(!dev || arg > 0xff)
+			if(arg > 0xff)
 				return -EINVAL;
 			read_ahead[MAJOR(dev)] = arg;
 			return 0;
@@ -224,8 +229,6 @@ int blk_ioctl(kdev_t dev, unsigned int c
 		case BLKFLSBUF:
 			if(!capable(CAP_SYS_ADMIN))
 				return -EACCES;
-			if (!dev)
-				return -EINVAL;
 			fsync_dev(dev);
 			invalidate_buffers(dev);
 			return 0;
@@ -235,18 +238,16 @@ int blk_ioctl(kdev_t dev, unsigned int c
 			intval = get_hardsect_size(dev);
 			return put_user(intval, (int *) arg);
 
-#if 0
 		case BLKGETSIZE:
-			/* Today get_gendisk() requires a linear scan;
-			   add this when dev has pointer type. */
-			/* add BLKGETSIZE64 too */
+		case BLKGETSIZE64:
 			g = get_gendisk(dev);
-			if (!g)
-				ulongval = 0;
+			if (g)
+				ullval = g->part[MINOR(dev)].nr_sects;
+
+			if (cmd == BLKGETSIZE)
+				return put_user((unsigned long)ullval, (unsigned long *)arg);
 			else
-				ulongval = g->part[MINOR(dev)].nr_sects;
-			return put_user(ulongval, (unsigned long *) arg);
-#endif
+				return put_user(ullval, (u64 *)arg);
 #if 0
 		case BLKRRPART: /* Re-read partition tables */
 			if (!capable(CAP_SYS_ADMIN))

             reply	other threads:[~2001-11-10  7:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-10  7:34 Andrew Morton [this message]
2001-11-10 13:57 ` scsi BLKGETSIZE breakage in -pre2 Alan Cox
2001-11-10 14:05 ` Anton Altaparmakov

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=3BECD87F.F53234B2@zip.com.au \
    --to=akpm@zip.com.au \
    --cc=alan@lxorguk.ukuu.org.uk \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.