gvfs/udisks2-Do-not-create-cdda-volumes-when-backend-is-d.patch

119 lines
4.3 KiB
Diff

From cf4a82c388e97230219fc99620e504c86f479ef2 Mon Sep 17 00:00:00 2001
From: Ondrej Holy <oholy@redhat.com>
Date: Tue, 28 May 2024 10:19:14 +0200
Subject: [PATCH] udisks2: Do not create cdda volumes when backend is disabled
Currently, the udisks2 volume monitor creates volumes for audio CDs
regardless of the fact the cdda backend is disabled using the
`-Dcdda=false` build option and thus there is no way to mount them.
Let's ignore audio CDs in this case instead.
Related: https://issues.redhat.com/browse/RHEL-38130
---
meson.build | 2 ++
monitor/udisks2/gvfsudisks2volume.c | 2 ++
monitor/udisks2/gvfsudisks2volumemonitor.c | 31 ++++++++++++++++++----
3 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/meson.build b/meson.build
index 4bb9ca3e..a7d15201 100644
--- a/meson.build
+++ b/meson.build
@@ -416,6 +416,8 @@ if enable_cdda
libcdio_paranoia_dep = dependency('libcdio_paranoia', version: '>= 0.78.2')
config_h.set('HAVE_PARANOIA_NEW_INCLUDES', cc.has_header('cdio/paranoia/paranoia.h', dependencies: libcdio_paranoia_dep))
+
+ config_h.set('HAVE_CDDA', enable_cdda)
endif
# *** Check if we should build with Google backend ***
diff --git a/monitor/udisks2/gvfsudisks2volume.c b/monitor/udisks2/gvfsudisks2volume.c
index 30078846..9af6c3da 100644
--- a/monitor/udisks2/gvfsudisks2volume.c
+++ b/monitor/udisks2/gvfsudisks2volume.c
@@ -386,11 +386,13 @@ update_volume (GVfsUDisks2Volume *volume)
g_free (volume->name);
volume->name = g_strdup (media_desc);
}
+#ifdef HAVE_CDDA
else if (volume->activation_root != NULL && g_file_has_uri_scheme (volume->activation_root, "cdda"))
{
g_free (volume->name);
volume->name = g_strdup (_("Audio Disc"));
}
+#endif
volume->icon = media_icon != NULL ? g_object_ref (media_icon) : NULL;
volume->symbolic_icon = media_symbolic_icon != NULL ? g_object_ref (media_symbolic_icon) : NULL;
diff --git a/monitor/udisks2/gvfsudisks2volumemonitor.c b/monitor/udisks2/gvfsudisks2volumemonitor.c
index 618f35b7..e6fe2944 100644
--- a/monitor/udisks2/gvfsudisks2volumemonitor.c
+++ b/monitor/udisks2/gvfsudisks2volumemonitor.c
@@ -973,6 +973,25 @@ should_include_drive (GVfsUDisks2VolumeMonitor *monitor,
return ret;
}
+static gboolean
+should_include_disc (GVfsUDisks2VolumeMonitor *monitor,
+ UDisksDrive *drive)
+{
+ gboolean ret = FALSE;
+
+ /* only consider blank and audio discs */
+
+ if (udisks_drive_get_optical_blank (drive))
+ ret = TRUE;
+
+#ifdef HAVE_CDDA
+ if (udisks_drive_get_optical_num_audio_tracks (drive) > 0)
+ ret = TRUE;
+#endif
+
+ return ret;
+}
+
/* ---------------------------------------------------------------------------------------------------- */
static gint
@@ -1830,9 +1849,7 @@ update_discs (GVfsUDisks2VolumeMonitor *monitor,
if (!should_include_drive (monitor, udisks_drive))
continue;
- /* only consider blank and audio discs */
- if (!(udisks_drive_get_optical_blank (udisks_drive) ||
- udisks_drive_get_optical_num_audio_tracks (udisks_drive) > 0))
+ if (!should_include_disc (monitor, udisks_drive))
continue;
block = udisks_client_get_block_for_drive (monitor->client, udisks_drive, FALSE);
@@ -1881,19 +1898,23 @@ update_discs (GVfsUDisks2VolumeMonitor *monitor,
udisks_drive = udisks_client_get_drive_for_block (monitor->client, block);
if (udisks_drive != NULL)
{
- gchar *uri;
+ gchar *uri = NULL;
GFile *activation_root;
if (udisks_drive_get_optical_blank (udisks_drive))
{
uri = g_strdup ("burn://");
}
- else
+
+#ifdef HAVE_CDDA
+ if (udisks_drive_get_optical_num_audio_tracks (udisks_drive) > 0)
{
gchar *basename = g_path_get_basename (udisks_block_get_device (block));
uri = g_strdup_printf ("cdda://%s", basename);
g_free (basename);
}
+#endif
+
activation_root = g_file_new_for_uri (uri);
volume = gvfs_udisks2_volume_new (monitor,
block,
--
2.45.1