[gnome-initial-setup/wip/pwithnall/misc-fixes: 58/70] driver: detect when in live mode with persistence




commit bbdc574f361cab03b8118dd9578e5b71cc8b8fce
Author: Daniel Drake <drake endlessm com>
Date:   Fri Oct 4 11:46:52 2019 +0800

    driver: detect when in live mode with persistence
    
    When /run/eos-live is a mount point, it implies that we are using
    our new "persistent live" setup where the overlayfses that permit
    live modifications actually have persistent storage that surivives
    over reboots.
    
    Detect this case and make it available via an accessor.
    
    (Rebase 3.38: Fix minor rebase conflicts.)
    
    https://phabricator.endlessm.com/T27772

 gnome-initial-setup/gis-driver.c | 37 +++++++++++++++++++++++++++++++++++++
 gnome-initial-setup/gis-driver.h |  2 ++
 2 files changed, 39 insertions(+)
---
diff --git a/gnome-initial-setup/gis-driver.c b/gnome-initial-setup/gis-driver.c
index 1f48ccf8..a551deb4 100644
--- a/gnome-initial-setup/gis-driver.c
+++ b/gnome-initial-setup/gis-driver.c
@@ -27,6 +27,7 @@
 #include <locale.h>
 #include <stdlib.h>
 #include <webkit2/webkit2.h>
+#include <gio/gunixmounts.h>
 
 #include "cc-common-language.h"
 #include "gis-assistant.h"
@@ -63,6 +64,7 @@ typedef enum {
   PROP_MODE = 1,
   PROP_LIVE_SESSION,
   PROP_LIVE_DVD,
+  PROP_LIVE_PERSISTENCE,
   PROP_USERNAME,
   PROP_PASSWORDLESS,
   PROP_SMALL_SCREEN,
@@ -99,6 +101,7 @@ struct _GisDriverPrivate {
   gboolean is_live_session;
   gboolean is_live_dvd;
   gboolean is_reformatter;
+  gboolean has_live_persistence;
 
   GisDriverMode mode;
   UmAccountMode account_mode;
@@ -173,6 +176,23 @@ check_live_session (GisDriver   *driver,
     }
 }
 
+static void
+check_live_persistence (GisDriver *driver)
+{
+  GisDriverPrivate *priv = gis_driver_get_instance_private (driver);
+  g_autoptr(GUnixMountEntry) entry = NULL;
+
+  if (priv->is_live_session)
+    {
+      entry = g_unix_mount_at ("/run/eos-live", NULL);
+      priv->has_live_persistence = entry != NULL;
+    }
+  else
+    {
+      priv->has_live_persistence = FALSE;
+    }
+}
+
 #define EOS_IMAGE_VERSION_PATH "/sysroot"
 #define EOS_IMAGE_VERSION_ALT_PATH "/"
 
@@ -785,6 +805,13 @@ gis_driver_is_live_session (GisDriver *driver)
     return priv->is_live_session;
 }
 
+gboolean
+gis_driver_has_live_persistence (GisDriver *driver)
+{
+    GisDriverPrivate *priv = gis_driver_get_instance_private (driver);
+    return priv->has_live_persistence;
+}
+
 gboolean
 gis_driver_is_reformatter (GisDriver *driver)
 {
@@ -833,6 +860,9 @@ gis_driver_get_property (GObject      *object,
     case PROP_LIVE_SESSION:
       g_value_set_boolean (value, priv->is_live_session);
       break;
+    case PROP_LIVE_PERSISTENCE:
+      g_value_set_boolean (value, priv->has_live_persistence);
+      break;
     case PROP_LIVE_DVD:
       g_value_set_boolean (value, priv->is_live_dvd);
       break;
@@ -1106,8 +1136,10 @@ gis_driver_startup (GApplication *app)
   priv->product_name = get_product_from_image_version (image_version);
 
   check_live_session (driver, image_version);
+  check_live_persistence (driver);
   g_object_notify_by_pspec (G_OBJECT (driver), obj_props[PROP_LIVE_SESSION]);
   g_object_notify_by_pspec (G_OBJECT (driver), obj_props[PROP_LIVE_DVD]);
+  g_object_notify_by_pspec (G_OBJECT (driver), obj_props[PROP_LIVE_PERSISTENCE]);
 
   priv->is_reformatter = image_is_reformatter (image_version);
 
@@ -1169,6 +1201,11 @@ gis_driver_class_init (GisDriverClass *klass)
                           FALSE,
                           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
 
+  obj_props[PROP_LIVE_PERSISTENCE] =
+    g_param_spec_boolean ("live-persistence", "", "",
+                          FALSE,
+                          G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
   obj_props[PROP_LIVE_DVD] =
     g_param_spec_boolean ("live-dvd", "", "",
                           FALSE,
diff --git a/gnome-initial-setup/gis-driver.h b/gnome-initial-setup/gis-driver.h
index f8a2ac59..65035983 100644
--- a/gnome-initial-setup/gis-driver.h
+++ b/gnome-initial-setup/gis-driver.h
@@ -124,6 +124,8 @@ GisDriverMode gis_driver_get_mode (GisDriver *driver);
 
 gboolean gis_driver_is_live_session (GisDriver *driver);
 
+gboolean gis_driver_has_live_persistence (GisDriver *driver);
+
 gboolean gis_driver_is_reformatter (GisDriver *driver);
 
 gboolean gis_driver_is_small_screen (GisDriver *driver);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]