static gboolean
filesystem_check (StoragedObject *object)
{
    StoragedLinuxBlockObject *block_object = STORAGED_LINUX_BLOCK_OBJECT (object);
    gboolean ret = FALSE;
    gboolean detected_as_filesystem = FALSE;
    StoragedMountType mount_type;

    /* if blkid(8) has detected the device as a filesystem, trust that */
    if (g_strcmp0 (storaged_block_get_id_usage (block_object->iface_block_device), "filesystem") == 0)
    {
        detected_as_filesystem = TRUE;
        /* except, if we are a whole-disk device and the kernel has already partitioned us...
         * in that case, don't pretend we're a filesystem
         *
         * (see partition_table_check() above for the similar case where we don't pretend
         * to be a partition table)
         */
        if (g_strcmp0 (g_udev_device_get_devtype (block_object->device->udev_device), "disk") == 0 &&
                disk_is_partitioned_by_kernel (block_object->device->udev_device))
        {
            detected_as_filesystem = FALSE;
        }
    }

    if (drive_does_not_detect_media_change (block_object) ||
            detected_as_filesystem ||
            (storaged_mount_monitor_is_dev_in_use (block_object->mount_monitor,
                    g_udev_device_get_device_number (block_object->device->udev_device),
                    &mount_type) &&
             mount_type == STORAGED_MOUNT_TYPE_FILESYSTEM))
        ret = TRUE;

    return ret;
}
Пример #2
0
static void
uevent_cb (GUdevClient *client, const char *action, GUdevDevice *device, RBRemovableMediaManager *mgr)
{
	RBRemovableMediaManagerPrivate *priv = GET_PRIVATE (mgr);
	GUdevDeviceNumber devnum;
	devnum = g_udev_device_get_device_number (device);
	rb_debug ("%s event for %s (%x)", action, g_udev_device_get_sysfs_path (device), devnum);

	if (g_str_equal (action, "add")) {
		RBSource *source = NULL;

		/* probably need to filter out devices related to things we've already seen.. */
		if (g_hash_table_lookup (priv->device_mapping, GINT_TO_POINTER (devnum)) != NULL) {
			rb_debug ("already have a source for this device");
			return;
		}

		g_signal_emit (mgr, rb_removable_media_manager_signals[CREATE_SOURCE_DEVICE], 0, device, &source);
		if (source != NULL) {
			rb_debug ("created a source for this device");
			g_hash_table_insert (priv->device_mapping, GINT_TO_POINTER (devnum), source);
			rb_removable_media_manager_append_media_source (mgr, source);
		}
	} else if (g_str_equal (action, "remove")) {
		RBSource *source;

		source = g_hash_table_lookup (priv->device_mapping, GINT_TO_POINTER (devnum));
		if (source) {
			rb_debug ("removing the source created for this device");
			rb_source_delete_thyself (source);
		}
	}
}
Пример #3
0
static gboolean
is_recorded_as_physical_volume (UDisksDaemon      *daemon,
                                UDisksLinuxDevice *device)
{
  UDisksObject *object = udisks_daemon_find_block (daemon, g_udev_device_get_device_number (device->udev_device));
  return object && udisks_object_peek_physical_volume (object) != NULL;
}
static void
on_mount_monitor_mount_removed (StoragedMountMonitor  *monitor,
                                StoragedMount         *mount,
                                gpointer               user_data)
{
    StoragedLinuxBlockObject *object = STORAGED_LINUX_BLOCK_OBJECT (user_data);
    if (storaged_mount_get_dev (mount) == g_udev_device_get_device_number (object->device->udev_device))
        storaged_linux_block_object_uevent (object, NULL, NULL);
}
Пример #5
0
static void
on_mount_monitor_mount_removed (UDisksMountMonitor  *monitor,
                                UDisksMount         *mount,
                                gpointer             user_data)
{
  UDisksLinuxBlockObject *object = UDISKS_LINUX_BLOCK_OBJECT (user_data);
  if (udisks_mount_get_dev (mount) == g_udev_device_get_device_number (object->device->udev_device))
    udisks_linux_block_object_uevent (object, NULL, NULL);
}
Пример #6
0
static gboolean
swapspace_check (UDisksLinuxBlockObject *object)
{
  gboolean ret;
  UDisksMountType mount_type;

  ret = FALSE;
  if ((g_strcmp0 (udisks_block_get_id_usage (object->iface_block_device), "other") == 0 &&
       g_strcmp0 (udisks_block_get_id_type (object->iface_block_device), "swap") == 0)
      || (udisks_mount_monitor_is_dev_in_use (object->mount_monitor,
                                              g_udev_device_get_device_number (object->device->udev_device),
                                              &mount_type)
          && mount_type == UDISKS_MOUNT_TYPE_SWAP))
    ret = TRUE;

  return ret;
}
static gboolean
swapspace_check (StoragedObject *object)
{
    StoragedLinuxBlockObject *block_object = STORAGED_LINUX_BLOCK_OBJECT (object);
    gboolean ret;
    StoragedMountType mount_type;

    ret = FALSE;
    if ((g_strcmp0 (storaged_block_get_id_usage (block_object->iface_block_device), "other") == 0 &&
            g_strcmp0 (storaged_block_get_id_type (block_object->iface_block_device), "swap") == 0)
            || (storaged_mount_monitor_is_dev_in_use (block_object->mount_monitor,
                    g_udev_device_get_device_number (block_object->device->udev_device),
                    &mount_type)
                && mount_type == STORAGED_MOUNT_TYPE_SWAP))
        ret = TRUE;

    return ret;
}
static void
uevent_cb (GUdevClient *client, const char *action, GUdevDevice *device, RBRemovableMediaManager *mgr)
{
	RBRemovableMediaManagerPrivate *priv = GET_PRIVATE (mgr);
	guint64 devnum;

	devnum = (guint64) g_udev_device_get_device_number (device);
	rb_debug ("%s event for %s (%"G_GINT64_MODIFIER"x)", action,
                  g_udev_device_get_sysfs_path (device), devnum);

	if (g_str_equal (action, "add")) {
		RBSource *source = NULL;

		/* probably need to filter out devices related to things we've already seen.. */
		if (g_hash_table_lookup (priv->device_mapping, &devnum) != NULL) {
			rb_debug ("already have a source for this device");
		} else {
			g_signal_emit (mgr, rb_removable_media_manager_signals[CREATE_SOURCE_DEVICE], 0, device, &source);
			if (source != NULL) {
				guint64 *key = g_new0 (guint64, 1);
				rb_debug ("created a source for this device");
				key[0] = devnum;
				g_hash_table_insert (priv->device_mapping, key, source);
				rb_removable_media_manager_append_media_source (mgr, source);
			}
		}
	} else if (g_str_equal (action, "remove")) {
		RBSource *source;

		source = g_hash_table_lookup (priv->device_mapping, &devnum);
		if (source) {
			rb_debug ("removing the source created for this device");
			rb_display_page_delete_thyself (RB_DISPLAY_PAGE (source));
		}
	}
}