From: Alberto Bertogli <albertogli@telpin.com.ar>
To: axboe@suse.de
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Export disk->policy to sysfs
Date: Thu, 9 Dec 2004 04:18:10 -0300 [thread overview]
Message-ID: <20041209071621.GA8868@telpin.com.ar> (raw)
[-- Attachment #1: Type: text/plain, Size: 277 bytes --]
Hi!
This small patch against 2.6.10-rc3 exports the disk->policy variable to
sysfs as /sys/block/DEVICE/read_only.
It can be useful for people or scripts wanting to check the state of a
device, specially now that USB storage has write protect detection.
Thanks,
Alberto
[-- Attachment #2: sysfs-block_read_only.patch --]
[-- Type: text/plain, Size: 987 bytes --]
--- linux-2.6.10-rc3/drivers/block/genhd.c.orig 2004-12-09 03:39:20.000000000 -0300
+++ linux-2.6.10-rc3/drivers/block/genhd.c 2004-12-09 03:48:44.000000000 -0300
@@ -384,6 +384,10 @@
jiffies_to_msecs(disk_stat_read(disk, io_ticks)),
jiffies_to_msecs(disk_stat_read(disk, time_in_queue)));
}
+static ssize_t disk_read_only_read(struct gendisk * disk, char *page)
+{
+ return sprintf(page, "%d\n", disk->policy);
+}
static struct disk_attribute disk_attr_dev = {
.attr = {.name = "dev", .mode = S_IRUGO },
.show = disk_dev_read
@@ -404,6 +408,10 @@
.attr = {.name = "stat", .mode = S_IRUGO },
.show = disk_stats_read
};
+static struct disk_attribute disk_attr_read_only = {
+ .attr = {.name = "read_only", .mode = S_IRUGO },
+ .show = disk_read_only_read
+};
static struct attribute * default_attrs[] = {
&disk_attr_dev.attr,
@@ -411,6 +419,7 @@
&disk_attr_removable.attr,
&disk_attr_size.attr,
&disk_attr_stat.attr,
+ &disk_attr_read_only.attr,
NULL,
};
reply other threads:[~2004-12-09 7:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20041209071621.GA8868@telpin.com.ar \
--to=albertogli@telpin.com.ar \
--cc=axboe@suse.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome