void storage_volume_group_update_block (StorageVolumeGroup *self, StorageBlock *block) { GUdevDevice *device; StorageLogicalVolume *volume; const gchar *block_vg_name; const gchar *block_lv_name; GVariant *pv_info; device = storage_block_get_udev (block); if (device) { block_vg_name = g_udev_device_get_property (device, "DM_VG_NAME"); block_lv_name = g_udev_device_get_property (device, "DM_LV_NAME"); if (g_strcmp0 (block_vg_name, storage_volume_group_get_name (self)) == 0) { volume = g_hash_table_lookup (self->logical_volumes, block_lv_name); storage_block_update_lv (block, volume); } g_object_unref (device); } pv_info = g_hash_table_lookup (self->physical_volumes, storage_block_get_device (block)); if (!pv_info) { const gchar *const *symlinks; int i; symlinks = storage_block_get_symlinks (block); for (i = 0; symlinks[i]; i++) { pv_info = g_hash_table_lookup (self->physical_volumes, symlinks[i]); if (pv_info) break; } } if (pv_info) { storage_block_update_pv (block, self, pv_info); } else { LvmPhysicalVolumeBlock *pv = storage_block_get_physical_volume_block (block); if (pv && g_strcmp0 (lvm_physical_volume_block_get_volume_group (pv), storage_volume_group_get_object_path (self)) == 0) storage_block_update_pv (block, NULL, NULL); } }
void storage_block_trigger_uevent (StorageBlock *self) { GUdevDevice *device; gchar* path = NULL; gint fd = -1; g_return_if_fail (STORAGE_IS_BLOCK (self)); /* TODO: would be nice with a variant to wait until the request uevent has been received by ourselves */ device = storage_block_get_udev (self); if (device == NULL) { g_debug ("skipping trigger of udev event for block object"); return; } path = g_strconcat (g_udev_device_get_sysfs_path (device), "/uevent", NULL); g_debug ("trigerring udev event '%s' for %s", "change", g_udev_device_get_name (device)); g_object_unref (device); fd = open (path, O_WRONLY); if (fd < 0) { g_message ("Error opening %s: %m", path); goto out; } if (write (fd, "change", sizeof "change" - 1) != sizeof "change" - 1) { g_message ("Error writing 'change' to file %s: %m", path); goto out; } out: if (fd >= 0) close (fd); g_free (path); }