aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@suse.de>2005-10-01 08:49:43 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-10-28 12:52:51 -0400
commita7fd67062efc5b0fc9a61368c607fa92d1d57f9e (patch)
tree8b91f198640608bd99f4e4764394e5134220abcf /fs
parentd8539d81aeee4dbdc0624a798321e822fb2df7ae (diff)
[PATCH] add sysfs attr to re-emit device hotplug event
A "coldplug + udevstart" can be simple like this: for i in /sys/block/*/*/uevent; do echo 1 > $i; done for i in /sys/class/*/*/uevent; do echo 1 > $i; done for i in /sys/bus/*/devices/*/uevent; do echo 1 > $i; done Signed-off-by: Kay Sievers <kay.sievers@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/partitions/check.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 77e178f13162..d95a110293fa 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -192,6 +192,7 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
192struct part_attribute { 192struct part_attribute {
193 struct attribute attr; 193 struct attribute attr;
194 ssize_t (*show)(struct hd_struct *,char *); 194 ssize_t (*show)(struct hd_struct *,char *);
195 ssize_t (*store)(struct hd_struct *,const char *, size_t);
195}; 196};
196 197
197static ssize_t 198static ssize_t
@@ -201,14 +202,33 @@ part_attr_show(struct kobject * kobj, struct attribute * attr, char * page)
201 struct part_attribute * part_attr = container_of(attr,struct part_attribute,attr); 202 struct part_attribute * part_attr = container_of(attr,struct part_attribute,attr);
202 ssize_t ret = 0; 203 ssize_t ret = 0;
203 if (part_attr->show) 204 if (part_attr->show)
204 ret = part_attr->show(p,page); 205 ret = part_attr->show(p, page);
206 return ret;
207}
208static ssize_t
209part_attr_store(struct kobject * kobj, struct attribute * attr,
210 const char *page, size_t count)
211{
212 struct hd_struct * p = container_of(kobj,struct hd_struct,kobj);
213 struct part_attribute * part_attr = container_of(attr,struct part_attribute,attr);
214 ssize_t ret = 0;
215
216 if (part_attr->store)
217 ret = part_attr->store(p, page, count);
205 return ret; 218 return ret;
206} 219}
207 220
208static struct sysfs_ops part_sysfs_ops = { 221static struct sysfs_ops part_sysfs_ops = {
209 .show = part_attr_show, 222 .show = part_attr_show,
223 .store = part_attr_store,
210}; 224};
211 225
226static ssize_t part_uevent_store(struct hd_struct * p,
227 const char *page, size_t count)
228{
229 kobject_hotplug(&p->kobj, KOBJ_ADD);
230 return count;
231}
212static ssize_t part_dev_read(struct hd_struct * p, char *page) 232static ssize_t part_dev_read(struct hd_struct * p, char *page)
213{ 233{
214 struct gendisk *disk = container_of(p->kobj.parent,struct gendisk,kobj); 234 struct gendisk *disk = container_of(p->kobj.parent,struct gendisk,kobj);
@@ -229,6 +249,10 @@ static ssize_t part_stat_read(struct hd_struct * p, char *page)
229 p->reads, (unsigned long long)p->read_sectors, 249 p->reads, (unsigned long long)p->read_sectors,
230 p->writes, (unsigned long long)p->write_sectors); 250 p->writes, (unsigned long long)p->write_sectors);
231} 251}
252static struct part_attribute part_attr_uevent = {
253 .attr = {.name = "uevent", .mode = S_IWUSR },
254 .store = part_uevent_store
255};
232static struct part_attribute part_attr_dev = { 256static struct part_attribute part_attr_dev = {
233 .attr = {.name = "dev", .mode = S_IRUGO }, 257 .attr = {.name = "dev", .mode = S_IRUGO },
234 .show = part_dev_read 258 .show = part_dev_read
@@ -247,6 +271,7 @@ static struct part_attribute part_attr_stat = {
247}; 271};
248 272
249static struct attribute * default_attrs[] = { 273static struct attribute * default_attrs[] = {
274 &part_attr_uevent.attr,
250 &part_attr_dev.attr, 275 &part_attr_dev.attr,
251 &part_attr_start.attr, 276 &part_attr_start.attr,
252 &part_attr_size.attr, 277 &part_attr_size.attr,