From: Tejun Heo <tj@kernel.org>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Jens Axboe <jens.axboe@oracle.com>,
Thomas Gleixner <tglx@linutronix.de>,
Yinghai Lu <yinghai@kernel.org>
Subject: [PATCH] block: add partition attribute for partition number
Date: Mon, 13 Oct 2008 20:07:34 +0900 [thread overview]
Message-ID: <48F32BF6.8010109@kernel.org> (raw)
In-Reply-To: <48F3113F.7090905@kernel.org>
With extended devt, finding out the partition number becomes a bit
more challenging as subtracting the minor number from that of the
parent device doesn't work anymore. The only thing left is parsing
the partition name which is brittle and not exactly universal (some
have '-' between the device name and partition number while others
don't). This patch introduced partition attribute which contains the
partition number of the device. This should make finding partitions
and its index easier.
This problem and solution were suggested by H. Peter Anvin.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
---
fs/partitions/check.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 7408227..4684a49 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -195,6 +195,14 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
return ERR_PTR(res);
}
+static ssize_t part_partition_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct hd_struct *p = dev_to_part(dev);
+
+ return sprintf(buf, "%d\n", p->partno);
+}
+
static ssize_t part_start_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -260,6 +268,7 @@ ssize_t part_fail_store(struct device *dev,
}
#endif
+static DEVICE_ATTR(partition, S_IRUGO, part_partition_show, NULL);
static DEVICE_ATTR(start, S_IRUGO, part_start_show, NULL);
static DEVICE_ATTR(size, S_IRUGO, part_size_show, NULL);
static DEVICE_ATTR(stat, S_IRUGO, part_stat_show, NULL);
@@ -269,6 +278,7 @@ static struct device_attribute dev_attr_fail =
#endif
static struct attribute *part_attrs[] = {
+ &dev_attr_partition.attr,
&dev_attr_start.attr,
&dev_attr_size.attr,
&dev_attr_stat.attr,
next prev parent reply other threads:[~2008-10-13 11:10 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-10 20:30 [bug] latest -git boot hang Ingo Molnar
2008-10-10 20:40 ` Ingo Molnar
2008-10-10 20:56 ` Ingo Molnar
2008-10-10 21:10 ` Linus Torvalds
2008-10-11 0:50 ` Tejun Heo
2008-10-11 1:42 ` H. Peter Anvin
2008-10-13 9:13 ` Tejun Heo
2008-10-13 11:07 ` Tejun Heo [this message]
2008-10-13 11:27 ` [PATCH] block: add partition attribute for partition number Jens Axboe
2008-10-11 7:11 ` [bug] latest -git boot hang Jens Axboe
2008-10-11 7:19 ` Ingo Molnar
2008-10-11 14:08 ` Jens Axboe
2008-10-11 14:33 ` Ingo Molnar
2008-10-11 14:39 ` Jens Axboe
2008-10-11 14:58 ` Ingo Molnar
2008-10-11 17:58 ` Jens Axboe
2008-10-13 6:41 ` [PATCH] block: add BIG FAT WARNING to CONFIG_DEBUG_BLOCK_EXT_DEVT Tejun Heo
2008-10-13 8:46 ` Jens Axboe
2008-10-14 15:15 ` Christoph Hellwig
2008-10-14 17:31 ` Tejun Heo
2008-10-14 15:07 ` [bug] latest -git boot hang Stephen Smalley
2008-10-14 15:12 ` Ingo Molnar
2008-10-14 15:24 ` Stephen Smalley
2008-10-15 1:48 ` Casey Schaufler
2008-10-13 8:41 ` Takashi Iwai
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=48F32BF6.8010109@kernel.org \
--to=tj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=yinghai@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