Skip to contentSkip to conversation

block: send disk "change" event for rescan_partitions()

PATCH New Kay Sievers 1 participant 1 message Mar 9, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: send disk "change" event for rescan_partitions()

From: Kay Sievers <[email protected]>
Subject: block: send disk "change" event for rescan_partitions()

Userspace likes to get notified that the disk may have changed, when rescan_partitions() is called after partitioning or media change. It will make it possible to update the state of the disk with the "change" event, before the following partition "add" events are handled.

---

fs/partitions/check.c +4 -0
index 03f808c..6149e4b 100644
@@ -473,6 +473,10 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
 		return 0;
 	if (IS_ERR(state))	/* I/O error reading the partition table */
 		return -EIO;
+
+	/* tell userspace that the media / partition table may have changed */
+	kobject_uevent(&disk->dev.kobj, KOBJ_CHANGE);
+
 	for (p = 1; p < state->limit; p++) {
 		sector_t size = state->parts[p].size;
 		sector_t from = state->parts[p].from;