From: Phillip Susi <psusi@cfl.rr.com>
To: vgoyal@redhat.com
Cc: joe@perches.com, kzak@redhat.com, linux-kernel@vger.kernel.org,
jaxboe@fusionio.com, psusi@cfl.rr.com
Subject: [PATCH 2/2] Add BLKPG_GET_PARTITION operation
Date: Mon, 12 Dec 2011 19:16:22 -0500 [thread overview]
Message-ID: <1323735382-5972-2-git-send-email-psusi@cfl.rr.com> (raw)
In-Reply-To: <1323735382-5972-1-git-send-email-psusi@cfl.rr.com>
Add a new operation to the BLKPG ioctl to read the partition.
This allows user space to find the current start and length
of a partition without having to open the partition and use
the long depreciated HDIO_GETGEO ioctl.
Signed-off-by: Phillip Susi <psusi@cfl.rr.com>
---
block/ioctl.c | 15 +++++++++++++++
include/linux/blkpg.h | 1 +
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/block/ioctl.c b/block/ioctl.c
index e4e9198..c84a949 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -139,6 +139,21 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
disk_put_part(part);
mutex_unlock(&bdev->bd_mutex);
return 0;
+ case BLKPG_GET_PARTITION:
+ mutex_lock(&bdev->bd_mutex);
+ part = disk_get_part(disk, partno);
+ if (!part)
+ {
+ mutex_unlock(&bdev->bd_mutex);
+ return -ENXIO;
+ }
+ p.start = part->start_sect << 9;
+ p.length = part->nr_sects << 9;
+ disk_put_part(part);
+ mutex_unlock(&bdev->bd_mutex);
+ if (copy_to_user(a.data, &p, sizeof(struct blkpg_partition)))
+ return -EFAULT;
+ return 0;
default:
return -EINVAL;
}
diff --git a/include/linux/blkpg.h b/include/linux/blkpg.h
index a851944..72bf5e2 100644
--- a/include/linux/blkpg.h
+++ b/include/linux/blkpg.h
@@ -41,6 +41,7 @@ struct blkpg_ioctl_arg {
#define BLKPG_ADD_PARTITION 1
#define BLKPG_DEL_PARTITION 2
#define BLKPG_RESIZE_PARTITION 3
+#define BLKPG_GET_PARTITION 4
/* Sizes of name fields. Unused at present. */
#define BLKPG_DEVNAMELTH 64
--
1.7.5.4
next prev parent reply other threads:[~2011-12-13 0:16 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1322709471.git.psusi@cfl.rr.com>
2011-12-01 3:23 ` [PATCH 1/2] Add partition resize function to BLKPG ioctl Phillip Susi
2011-12-08 12:30 ` Karel Zak
2011-12-08 14:22 ` Phillip Susi
2011-12-08 15:16 ` Karel Zak
2011-12-08 15:25 ` Phillip Susi
2011-12-08 15:58 ` Vivek Goyal
2011-12-08 16:06 ` Phillip Susi
2011-12-08 16:28 ` Vivek Goyal
2011-12-08 16:55 ` Phillip Susi
2011-12-09 2:53 ` Phillip Susi
2011-12-12 14:53 ` Vivek Goyal
2011-12-12 17:43 ` Phillip Susi
2011-12-12 17:49 ` Joe Perches
2011-12-12 18:04 ` Vivek Goyal
2011-12-13 0:15 ` Phillip Susi
2011-12-13 0:16 ` Phillip Susi
2011-12-13 0:16 ` Phillip Susi [this message]
2011-12-19 20:25 ` Vivek Goyal
2011-12-21 1:53 ` Phillip Susi
2011-12-21 1:54 ` Phillip Susi
2011-12-21 1:54 ` [PATCH 2/2] Add BLKPG_GET_PARTITION operation Phillip Susi
2011-12-21 20:46 ` [PATCH 1/2] Add partition resize function to BLKPG ioctl Vivek Goyal
2011-12-24 21:36 ` Phillip Susi
2011-12-24 22:21 ` Phillip Susi
2011-12-24 22:21 ` [PATCH 2/2] Add BLKPG_GET_PARTITION operation Phillip Susi
2011-12-01 3:23 ` Phillip Susi
2011-12-08 12:35 ` Karel Zak
2011-12-08 14:25 ` Phillip Susi
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=1323735382-5972-2-git-send-email-psusi@cfl.rr.com \
--to=psusi@cfl.rr.com \
--cc=jaxboe@fusionio.com \
--cc=joe@perches.com \
--cc=kzak@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=vgoyal@redhat.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;
as well as URLs for NNTP newsgroup(s).