Skip to contentSkip to conversation

9p: send uevent after adding/removing mount_tag attribute

PATCH In review Michael Marineau 2 participants 2 messages Aug 11, 2013 9P file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 9p: send uevent after adding/removing mount_tag attribute

This driver adds an attribute to the existing virtio device so a CHANGE event is required in order udev rules to make use of it. The ADD event happens before this driver is probed and unlike a more typical driver like a block device there isn't a higher level device to watch for.

---
 net/9p/trans_virtio.c | 5 +++++
 1 file changed, 5 insertions(+)
net/9p/trans_virtio.c +5 -0
index e1c26b1..990afab 100644
@@ -577,6 +577,10 @@ static int p9_virtio_probe(struct virtio_device *vdev)
 	mutex_lock(&virtio_9p_lock);
 	list_add_tail(&chan->chan_list, &virtio_chan_list);
 	mutex_unlock(&virtio_9p_lock);
+
+	/* Let udev rules use the new mount_tag attribute. */
+	kobject_uevent(&(vdev->dev.kobj), KOBJ_CHANGE);
+
 	return 0;
 
 out_free_tag:
@@ -654,6 +658,7 @@ static void p9_virtio_remove(struct virtio_device *vdev)
 	list_del(&chan->chan_list);
 	mutex_unlock(&virtio_9p_lock);
 	sysfs_remove_file(&(vdev->dev.kobj), &dev_attr_mount_tag.attr);
+	kobject_uevent(&(vdev->dev.kobj), KOBJ_CHANGE);
 	kfree(chan->tag);
 	kfree(chan->vc_wq);
 	kfree(chan);
Signature · 1 line
1.8.1.5
Acked-by on v1 1/1
#1 lore raw
Quoted 15 lines · Michael Marineau

This driver adds an attribute to the existing virtio device so a CHANGE event is required in order udev rules to make use of it. The ADD event happens before this driver is probed and unlike a more typical driver like a block device there isn't a higher level device to watch for.

---
 net/9p/trans_virtio.c | 5 +++++
 1 file changed, 5 insertions(+)
net/9p/trans_virtio.c +0 -0
index e1c26b1..990afab 100644

net/9p/trans_virtio.c static int p9_virtio_probe(struct virtio_device *vdev) · line 582

Quoted 6 lines
net/9p/trans_virtio.c +3 -0
@@ -577,6 +577,10 @@ static int p9_virtio_probe(struct virtio_device *vdev)
 	mutex_lock(&virtio_9p_lock);
 	list_add_tail(&chan->chan_list, &virtio_chan_list);
 	mutex_unlock(&virtio_9p_lock);
+
+	/* Let udev rules use the new mount_tag attribute. */
+	kobject_uevent(&(vdev->dev.kobj), KOBJ_CHANGE);

Ick, this is due to the sysfs file being added to the device after udev was told the device was present.

I'm working on cleaning all of this up, to keep stuff like this from happening in the first place, by creating all of the needed files before userspace is told about the object, but it's a long slog, and will take a year or so to get it all right, the first pieces of this are going to be showing up in 3.12 or .13 at the earliest.

For now, I have no objection to this patch at all, especially as it solves the problem for you.