From 02c17af4b3b2544018d218ddc047f5219d8c286c Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Thu, 27 Sep 2012 13:14:15 -0400 Subject: [PATCH] Make it work without requiring the kernel to be CONFIG_SWAP=y https://bugs.freedesktop.org/show_bug.cgi?id=50142 Signed-off-by: David Zeuthen --- src/udisksmountmonitor.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/udisksmountmonitor.c b/src/udisksmountmonitor.c index 36e1476..b56ed2a 100644 --- a/src/udisksmountmonitor.c +++ b/src/udisksmountmonitor.c @@ -322,7 +322,11 @@ udisks_mount_monitor_constructed (GObject *object) } else { - g_error ("No /proc/swaps file: %s", error->message); + if (!(error->domain == G_FILE_ERROR && error->code == G_FILE_ERROR_NOENT)) + { + udisks_warning ("Error opening /proc/swaps file: %s (%s, %d)", + error->message, g_quark_to_string (error->domain), error->code); + } g_error_free (error); } @@ -518,15 +522,25 @@ udisks_mount_monitor_get_swaps (UDisksMountMonitor *monitor, gchar *contents; gchar **lines; guint n; + GError *local_error = NULL; ret = FALSE; contents = NULL; lines = NULL; - if (!g_file_get_contents ("/proc/swaps", &contents, NULL, error)) + if (!g_file_get_contents ("/proc/swaps", &contents, NULL, &local_error)) { - g_prefix_error (error, "Error reading /proc/self/mountinfo: "); - goto out; + if (local_error->domain == G_FILE_ERROR && local_error->code == G_FILE_ERROR_NOENT) + { + g_clear_error (&local_error); + ret = TRUE; + goto out; + } + else + { + g_propagate_prefixed_error (error, local_error, "Error reading /proc/self/mountinfo: "); + goto out; + } } lines = g_strsplit (contents, "\n", 0); -- 2.7.4