mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Martin K. Petersen" <mkp@mkp.net>
To: Andries.Brouwer@cwi.nl
Cc: michael_e_brown@dell.com, Matt_Domsch@exchange.dell.com,
	freitag@alancoxonachip.com, linux-kernel@vger.kernel.org
Subject: Re: block ioctl to read/write last sector
Date: 13 Feb 2001 14:24:50 -0500	[thread overview]
Message-ID: <yq1pugmwflp.fsf@jaguar.mkp.net> (raw)
In-Reply-To: <UTC200102132254.XAA98078.aeb@vlet.cwi.nl>
In-Reply-To: <UTC200102132254.XAA98078.aeb@vlet.cwi.nl>

[-- Attachment #1: Type: text/plain, Size: 508 bytes --]

>>>>> "Andries" == Andries Brouwer <Andries.Brouwer@cwi.nl> writes:

Andries> Anyway, an ioctl just to read the last sector is too silly.
Andries> An ioctl to change the blocksize is more reasonable.  

I actually sent you a patch implementing this some time ago, remember?
We need it for XFS...

Patch against 2.4.2-pre3 follows.

-- 
Martin K. Petersen, Principal Linux Consultant, Linuxcare, Inc.
mkp@linuxcare.com, http://www.linuxcare.com/
SGI XFS for Linux Developer, http://oss.sgi.com/projects/xfs/


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: blksetsize-2.4.2pre3.patch --]
[-- Type: text/x-patch, Size: 3978 bytes --]

diff -urN linux/arch/mips64/kernel/ioctl32.c linux-blksetsize/arch/mips64/kernel/ioctl32.c
--- linux/arch/mips64/kernel/ioctl32.c	Wed Nov 29 00:42:04 2000
+++ linux-blksetsize/arch/mips64/kernel/ioctl32.c	Tue Feb 13 14:15:20 2001
@@ -712,6 +712,7 @@
 	IOCTL32_HANDLER(BLKPG, blkpg_ioctl_trans),
 	IOCTL32_DEFAULT(BLKELVGET),
 	IOCTL32_DEFAULT(BLKELVSET),
+	IOCTL32_DEFAULT(BLKSETSIZE),
 
 	IOCTL32_DEFAULT(MTIOCTOP),			/* mtio.h ioctls  */
 	IOCTL32_HANDLER(MTIOCGET32, mt_ioctl_trans),
diff -urN linux/arch/sparc64/kernel/ioctl32.c linux-blksetsize/arch/sparc64/kernel/ioctl32.c
--- linux/arch/sparc64/kernel/ioctl32.c	Tue Feb 13 14:12:17 2001
+++ linux-blksetsize/arch/sparc64/kernel/ioctl32.c	Tue Feb 13 14:15:20 2001
@@ -3107,6 +3107,7 @@
 COMPATIBLE_IOCTL(BLKFRASET)
 COMPATIBLE_IOCTL(BLKSECTSET)
 COMPATIBLE_IOCTL(BLKSSZGET)
+COMPATIBLE_IOCTL(BLKSETSIZE)
 
 /* RAID */
 COMPATIBLE_IOCTL(RAID_VERSION)
diff -urN linux/drivers/block/blkpg.c linux-blksetsize/drivers/block/blkpg.c
--- linux/drivers/block/blkpg.c	Fri Oct 27 02:35:47 2000
+++ linux-blksetsize/drivers/block/blkpg.c	Tue Feb 13 14:15:20 2001
@@ -208,6 +208,7 @@
 int blk_ioctl(kdev_t dev, unsigned int cmd, unsigned long arg)
 {
 	int intval;
+	long longval;
 
 	switch (cmd) {
 		case BLKROSET:
@@ -258,6 +259,22 @@
 				longval = g->part[MINOR(dev)].nr_sects;
 			return put_user(longval, (long *) arg);
 #endif
+		case BLKSETSIZE:
+			/* Can be used to set block size from userland. */
+			if(!capable(CAP_SYS_ADMIN))
+				return -EACCES;
+
+			if(!dev || !arg)
+				return -EINVAL;
+
+			if (get_user(longval, (int *)(arg)))
+				return -EFAULT;
+
+			if (longval > PAGE_SIZE || longval < 512 || (longval & (longval-1)))
+				return -EINVAL;
+
+			set_blocksize(dev, longval);
+			return 0;
 #if 0
 		case BLKRRPART: /* Re-read partition tables */
 			if (!capable(CAP_SYS_ADMIN)) 
diff -urN linux/drivers/ide/ide.c linux-blksetsize/drivers/ide/ide.c
--- linux/drivers/ide/ide.c	Tue Feb 13 14:12:23 2001
+++ linux-blksetsize/drivers/ide/ide.c	Tue Feb 13 14:15:20 2001
@@ -2672,6 +2672,7 @@
 		case BLKPG:
 		case BLKELVGET:
 		case BLKELVSET:
+		case BLKSETSIZE:
 			return blk_ioctl(inode->i_rdev, cmd, arg);
 
 		default:
diff -urN linux/drivers/md/lvm.c linux-blksetsize/drivers/md/lvm.c
--- linux/drivers/md/lvm.c	Sun Jan 28 19:11:20 2001
+++ linux-blksetsize/drivers/md/lvm.c	Tue Feb 13 14:15:20 2001
@@ -910,6 +910,8 @@
 			return -EFAULT;
 		break;
 
+	case BLKSETSIZE:
+		return blk_ioctl(inode->i_rdev, command, a);
 
 	case BLKFLSBUF:
 		/* flush buffer cache */
diff -urN linux/drivers/md/md.c linux-blksetsize/drivers/md/md.c
--- linux/drivers/md/md.c	Tue Feb 13 14:12:24 2001
+++ linux-blksetsize/drivers/md/md.c	Tue Feb 13 14:15:20 2001
@@ -2511,6 +2511,9 @@
 						(long *) arg);
 			goto done;
 
+		case BLKSETSIZE:
+			return blk_ioctl(dev, cmd, (long *) arg);
+
 		case BLKFLSBUF:
 			fsync_dev(dev);
 			invalidate_buffers(dev);
diff -urN linux/drivers/scsi/sd.c linux-blksetsize/drivers/scsi/sd.c
--- linux/drivers/scsi/sd.c	Tue Feb 13 14:12:32 2001
+++ linux-blksetsize/drivers/scsi/sd.c	Tue Feb 13 14:15:21 2001
@@ -234,6 +234,7 @@
 		case BLKPG:
                 case BLKELVGET:
                 case BLKELVSET:
+                case BLKSETSIZE:
 			return blk_ioctl(inode->i_rdev, cmd, arg);
 
 		case BLKRRPART: /* Re-read partition tables */
diff -urN linux/include/linux/fs.h linux-blksetsize/include/linux/fs.h
--- linux/include/linux/fs.h	Tue Feb 13 14:12:42 2001
+++ linux-blksetsize/include/linux/fs.h	Tue Feb 13 14:15:21 2001
@@ -181,6 +181,7 @@
 #define BLKSECTSET _IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
 #define BLKSECTGET _IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
 #define BLKSSZGET  _IO(0x12,104)/* get block device sector size */
+#define BLKSETSIZE _IO(0x12,108)/* set device block size */
 #if 0
 #define BLKPG      _IO(0x12,105)/* See blkpg.h */
 #define BLKELVGET  _IOR(0x12,106,sizeof(blkelv_ioctl_arg_t))/* elevator get */

  reply	other threads:[~2001-02-14  0:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-13 22:54 Andries.Brouwer
2001-02-13 19:24 ` Martin K. Petersen [this message]
2001-02-14  5:51   ` Michael E Brown
2001-02-14 14:23     ` Martin K. Petersen
2001-02-13 23:37 ` Michael E Brown
2001-02-14  0:21   ` Manfred Spraul
2001-02-14  5:47     ` Michael E Brown
2001-02-13 23:49 Andries.Brouwer
2001-02-14 14:19 ` Michael E Brown
2001-02-14  1:00 Matt_Domsch
2001-02-14 12:31 David Balazic
2001-02-14 14:10 ` Michael E Brown
2001-02-17  7:29 ` Andre Hedrick
2001-02-14 13:26 Matt_Domsch
2001-02-14 15:43 Andries.Brouwer
2001-02-14 15:56 ` Michael E Brown
2001-02-14 15:59 ` Michael E Brown

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=yq1pugmwflp.fsf@jaguar.mkp.net \
    --to=mkp@mkp.net \
    --cc=Andries.Brouwer@cwi.nl \
    --cc=Matt_Domsch@exchange.dell.com \
    --cc=freitag@alancoxonachip.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael_e_brown@dell.com \
    /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

all inboxes | Powered by JetHome®