From: Patrick Mansfield <patmans@us.ibm.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: [PATCH] udev - create all partitions of blockdevice
Date: Sun, 22 Feb 2004 23:03:27 +0000 [thread overview]
Message-ID: <20040222150327.A2545@beaverton.ibm.com> (raw)
In-Reply-To: <20040216033452.GA3523@vrfy.org>
On Fri, Feb 20, 2004 at 04:47:00PM -0800, Greg KH wrote:
> On Mon, Feb 16, 2004 at 06:25:35PM -0800, Patrick Mansfield wrote:
> > Should we export the scsi 'removable' flag via sysfs attribute for
> > use with all_partitions? Kernel patch is a trivial:
>
> <snip patch>
>
> Yes, this is a good idea.
More general patch below.
> Then we can just trigger off of this, right? Will this flag always be
> correct, even for the very cheap flash readers on the market?
Yes for the first question.
And it should not matter for the second:
If a device gets it wrong and says media is not removable, the user would
have to manually recheck partitions - maybe by removing (via software or
hardware) and adding the device or via fdisk. Then udev would get hotplugs
for the partitions. So such borken devices will interact OK way with udev.
> > So you could have rules such as:
> >
> > KERNEL="sd*", BUS="scsi", SYSFS{removable}="1", NAME{all_partitions}="%k"
> > KERNEL="sd*", BUS="scsi", SYSFS{removable}="0", NAME="%k"
> >
> > AFAIUI CD-ROM never wants all_partitions even though they are marked
> > removable. Tape is also removable. So, the KERNEL="sd*".
>
> Yeah, that would make sense.
>
> > Though it won't help for non-scsi (implies non-usb mass storage) media.
>
> Do you know of any? Old zip drives use scsi, right? What about floppy
> drives?
No, but I know less about linux and non-scsi removable media than the
little I know about scsi removable media, though I'm learning.
Here is a better patch to have the block layer export an attribute based
on the gd->flags GENHD_FL_REMOVABLE. Then it can be used for all block
devices. I'm not sure if non-ide floppy drivers set it. Jens or others
need to OK this.
But a simple udev rule will not stop hd cdrom's (and you can't use
KERNEL="sd*" with this method), but st won't have the field.
I ran with this patch:
diff -uprN -X /home/patman/dontdiff base-2.6/drivers/block/genhd.c blk-attr-2.6/drivers/block/genhd.c
--- base-2.6/drivers/block/genhd.c Fri Feb 20 07:36:56 2004
+++ blk-attr-2.6/drivers/block/genhd.c Sun Feb 22 13:55:48 2004
@@ -352,6 +352,12 @@ static ssize_t disk_range_read(struct ge
{
return sprintf(page, "%d\n", disk->minors);
}
+static ssize_t disk_removable_read(struct gendisk * disk, char *page)
+{
+ return sprintf(page, "%d\n",
+ (disk->flags & GENHD_FL_REMOVABLE ? 1 : 0));
+
+}
static ssize_t disk_size_read(struct gendisk * disk, char *page)
{
return sprintf(page, "%llu\n", (unsigned long long)get_capacity(disk));
@@ -394,6 +400,10 @@ static struct disk_attribute disk_attr_r
.attr = {.name = "range", .mode = S_IRUGO },
.show = disk_range_read
};
+static struct disk_attribute disk_attr_removable = {
+ .attr = {.name = "removable", .mode = S_IRUGO },
+ .show = disk_removable_read
+};
static struct disk_attribute disk_attr_size = {
.attr = {.name = "size", .mode = S_IRUGO },
.show = disk_size_read
@@ -406,6 +416,7 @@ static struct disk_attribute disk_attr_s
static struct attribute * default_attrs[] = {
&disk_attr_dev.attr,
&disk_attr_range.attr,
+ &disk_attr_removable.attr,
&disk_attr_size.attr,
&disk_attr_stat.attr,
NULL,
And then I see:
[root@laptop root]# for i in /sys/block/*; do echo $i removable is $(cat $i/removable); done
/sys/block/fd0 removable is 1
/sys/block/hda removable is 0
/sys/block/hdc removable is 1
/sys/block/sda removable is 1
hda is my boot/root disk. hdc my cd drive.
For sda, both my fairly cheap dazzle xd card reader and my olympus c750
give the same result.
(The ide floppy is the bay thing on my laptop, though it has a cd drive in
it.)
-- Patrick Mansfield
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id\x1356&alloc_id438&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
next prev parent reply other threads:[~2004-02-22 23:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-16 3:34 [PATCH] udev - create all partitions of blockdevice Kay Sievers
2004-02-16 21:59 ` Greg KH
2004-02-17 2:25 ` Patrick Mansfield
2004-02-21 0:47 ` Greg KH
2004-02-22 23:03 ` Patrick Mansfield [this message]
2004-03-07 14:01 ` Olaf Hering
2004-03-07 17:41 ` Olaf Hering
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=20040222150327.A2545@beaverton.ibm.com \
--to=patmans@us.ibm.com \
--cc=linux-hotplug@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 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).