|
Lines 49-54
Link Here
|
| 49 |
#include "udiskslinuxblock.h" |
49 |
#include "udiskslinuxblock.h" |
| 50 |
#include "udiskslinuxblockobject.h" |
50 |
#include "udiskslinuxblockobject.h" |
| 51 |
#include "udiskslinuxdriveobject.h" |
51 |
#include "udiskslinuxdriveobject.h" |
|
|
52 |
#include "udiskslinuxdrive.h" |
| 52 |
#include "udisksdaemon.h" |
53 |
#include "udisksdaemon.h" |
| 53 |
#include "udisksstate.h" |
54 |
#include "udisksstate.h" |
| 54 |
#include "udisksprivate.h" |
55 |
#include "udisksprivate.h" |
|
Lines 220-239
find_block_device_by_sysfs_path (GDBusObjectManagerServer *object_manager,
Link Here
|
| 220 |
|
221 |
|
| 221 |
/* ---------------------------------------------------------------------------------------------------- */ |
222 |
/* ---------------------------------------------------------------------------------------------------- */ |
| 222 |
|
223 |
|
|
|
224 |
typedef struct |
| 225 |
{ |
| 226 |
UDisksDaemon *daemon; |
| 227 |
gchar *obj_path; |
| 228 |
} PingDriveData; |
| 229 |
|
| 230 |
static void |
| 231 |
free_ping_drive_data (gpointer user_data) |
| 232 |
{ |
| 233 |
PingDriveData *data = user_data; |
| 234 |
|
| 235 |
g_free (data->obj_path); |
| 236 |
g_free (data); |
| 237 |
} |
| 238 |
|
| 239 |
static gboolean |
| 240 |
ping_drive_idle_cb (gpointer user_data) |
| 241 |
{ |
| 242 |
PingDriveData *data = user_data; |
| 243 |
UDisksObject *object; |
| 244 |
UDisksDrive *drive; |
| 245 |
|
| 246 |
object = udisks_daemon_find_object (data->daemon, data->obj_path); |
| 247 |
drive = object ? udisks_object_get_drive (object) : NULL; |
| 248 |
if (object && drive) |
| 249 |
{ |
| 250 |
udisks_linux_drive_recalculate_nvme_size (UDISKS_LINUX_DRIVE (drive), |
| 251 |
UDISKS_LINUX_DRIVE_OBJECT (object)); |
| 252 |
} |
| 253 |
g_clear_object (&object); |
| 254 |
g_clear_object (&drive); |
| 255 |
|
| 256 |
return G_SOURCE_REMOVE; |
| 257 |
} |
| 258 |
|
| 223 |
static gchar * |
259 |
static gchar * |
| 224 |
find_drive (GDBusObjectManagerServer *object_manager, |
260 |
find_drive (UDisksDaemon *daemon, |
| 225 |
GUdevDevice *block_device, |
261 |
GUdevDevice *block_device, |
| 226 |
UDisksDrive **out_drive) |
262 |
gboolean update_size, |
|
|
263 |
UDisksDrive **out_drive) |
| 227 |
{ |
264 |
{ |
|
|
265 |
GDBusObjectManagerServer *object_manager; |
| 228 |
GUdevDevice *whole_disk_block_device; |
266 |
GUdevDevice *whole_disk_block_device; |
| 229 |
const gchar *whole_disk_block_device_sysfs_path; |
267 |
const gchar *whole_disk_block_device_sysfs_path; |
| 230 |
gchar **nvme_ctrls = NULL; |
268 |
gchar **nvme_ctrls = NULL; |
| 231 |
gchar *ret; |
269 |
gchar *ret = NULL; |
| 232 |
GList *objects = NULL; |
270 |
GList *objects = NULL; |
| 233 |
GList *l; |
271 |
GList *l; |
| 234 |
|
272 |
|
| 235 |
ret = NULL; |
|
|
| 236 |
|
| 237 |
if (g_strcmp0 (g_udev_device_get_devtype (block_device), "disk") == 0) |
273 |
if (g_strcmp0 (g_udev_device_get_devtype (block_device), "disk") == 0) |
| 238 |
whole_disk_block_device = g_object_ref (block_device); |
274 |
whole_disk_block_device = g_object_ref (block_device); |
| 239 |
else |
275 |
else |
|
Lines 267-272
find_drive (GDBusObjectManagerServer *object_manager,
Link Here
|
| 267 |
g_clear_object (&parent_device); |
303 |
g_clear_object (&parent_device); |
| 268 |
} |
304 |
} |
| 269 |
|
305 |
|
|
|
306 |
object_manager = udisks_daemon_get_object_manager (daemon); |
| 270 |
objects = g_dbus_object_manager_get_objects (G_DBUS_OBJECT_MANAGER (object_manager)); |
307 |
objects = g_dbus_object_manager_get_objects (G_DBUS_OBJECT_MANAGER (object_manager)); |
| 271 |
for (l = objects; l != NULL; l = l->next) |
308 |
for (l = objects; l != NULL; l = l->next) |
| 272 |
{ |
309 |
{ |
|
Lines 283-301
find_drive (GDBusObjectManagerServer *object_manager,
Link Here
|
| 283 |
UDisksLinuxDevice *drive_device = UDISKS_LINUX_DEVICE (j->data); |
320 |
UDisksLinuxDevice *drive_device = UDISKS_LINUX_DEVICE (j->data); |
| 284 |
const gchar *drive_sysfs_path; |
321 |
const gchar *drive_sysfs_path; |
| 285 |
|
322 |
|
|
|
323 |
/* See if the drive object encloses our block device. |
| 324 |
* For NVMe, see if the drive object representing a NVMe controller |
| 325 |
* provides our namespace. |
| 326 |
*/ |
| 286 |
drive_sysfs_path = g_udev_device_get_sysfs_path (drive_device->udev_device); |
327 |
drive_sysfs_path = g_udev_device_get_sysfs_path (drive_device->udev_device); |
| 287 |
if (g_strcmp0 (whole_disk_block_device_sysfs_path, drive_sysfs_path) == 0 || |
328 |
if (g_strcmp0 (whole_disk_block_device_sysfs_path, drive_sysfs_path) == 0 || |
| 288 |
(nvme_ctrls && g_strv_contains ((const gchar * const *) nvme_ctrls, drive_sysfs_path))) |
329 |
(nvme_ctrls && g_strv_contains ((const gchar * const *) nvme_ctrls, drive_sysfs_path))) |
| 289 |
{ |
330 |
{ |
| 290 |
if (out_drive != NULL) |
331 |
const gchar *obj_path; |
| 291 |
*out_drive = udisks_object_get_drive (UDISKS_OBJECT (object)); |
332 |
|
| 292 |
ret = g_strdup (g_dbus_object_get_object_path (G_DBUS_OBJECT (object))); |
333 |
/* FIXME: An NVMe namespace may be provided by multiple controllers within |
| 293 |
g_list_free_full (drive_devices, g_object_unref); |
334 |
* an NVMe subsystem, however the org.freedesktop.UDisks2.Block.Drive |
| 294 |
/* FIXME: NVMe namespace may be provided by multiple controllers within |
335 |
* property may only contain a single object path. |
| 295 |
* a NVMe subsystem, however the org.freedesktop.UDisks2.Block.Drive |
|
|
| 296 |
* property may only contain single object path. |
| 297 |
*/ |
336 |
*/ |
| 298 |
goto out; |
337 |
if (out_drive != NULL && *out_drive == NULL) |
|
|
338 |
*out_drive = udisks_object_get_drive (UDISKS_OBJECT (object)); |
| 339 |
obj_path = g_dbus_object_get_object_path (G_DBUS_OBJECT (object)); |
| 340 |
if (! ret) |
| 341 |
ret = g_strdup (obj_path); |
| 342 |
if (!nvme_ctrls || !update_size) |
| 343 |
{ |
| 344 |
g_list_free_full (drive_devices, g_object_unref); |
| 345 |
goto out; |
| 346 |
} |
| 347 |
else |
| 348 |
{ |
| 349 |
if (!udisks_linux_device_nvme_tnvmcap_supported (drive_device)) |
| 350 |
{ |
| 351 |
PingDriveData *data; |
| 352 |
|
| 353 |
/* ping the drive object to recalculate controller size |
| 354 |
* from all attached namespaces |
| 355 |
*/ |
| 356 |
data = g_new0 (PingDriveData, 1); |
| 357 |
data->daemon = daemon; |
| 358 |
data->obj_path = g_strdup (obj_path); |
| 359 |
g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, |
| 360 |
ping_drive_idle_cb, |
| 361 |
data, |
| 362 |
free_ping_drive_data); |
| 363 |
} |
| 364 |
} |
| 299 |
} |
365 |
} |
| 300 |
} |
366 |
} |
| 301 |
g_list_free_full (drive_devices, g_object_unref); |
367 |
g_list_free_full (drive_devices, g_object_unref); |
|
Lines 1135-1141
udisks_linux_block_update (UDisksLinuxBlock *block,
Link Here
|
| 1135 |
* TODO: if this is slow we could have a cache or ensure that we |
1201 |
* TODO: if this is slow we could have a cache or ensure that we |
| 1136 |
* only do this once or something else |
1202 |
* only do this once or something else |
| 1137 |
*/ |
1203 |
*/ |
| 1138 |
drive_object_path = find_drive (object_manager, device->udev_device, &drive); |
1204 |
drive_object_path = find_drive (daemon, device->udev_device, TRUE, &drive); |
| 1139 |
if (drive_object_path != NULL) |
1205 |
if (drive_object_path != NULL) |
| 1140 |
{ |
1206 |
{ |
| 1141 |
udisks_block_set_drive (iface, drive_object_path); |
1207 |
udisks_block_set_drive (iface, drive_object_path); |
|
Lines 1991-1997
update_block_fstab (UDisksDaemon *daemon,
Link Here
|
| 1991 |
|
2057 |
|
| 1992 |
/* hints take fstab records in the calculation */ |
2058 |
/* hints take fstab records in the calculation */ |
| 1993 |
device = udisks_linux_block_object_get_device (object); |
2059 |
device = udisks_linux_block_object_get_device (object); |
| 1994 |
drive_object_path = find_drive (udisks_daemon_get_object_manager (daemon), device->udev_device, &drive); |
2060 |
drive_object_path = find_drive (daemon, device->udev_device, FALSE, &drive); |
| 1995 |
update_hints (daemon, block, device, drive); |
2061 |
update_hints (daemon, block, device, drive); |
| 1996 |
g_free (drive_object_path); |
2062 |
g_free (drive_object_path); |
| 1997 |
g_clear_object (&device); |
2063 |
g_clear_object (&device); |