Skip to content

Instantly share code, notes, and snippets.

@petermolnar
Created December 21, 2022 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petermolnar/f757e0c01007e69f76a7084adca7310a to your computer and use it in GitHub Desktop.
Save petermolnar/f757e0c01007e69f76a7084adca7310a to your computer and use it in GitHub Desktop.
diff --git a/src/main.c b/src/main.c
index b4dbf9e0..51a73e6d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -41,6 +41,7 @@ static gboolean opt_no_sigint = FALSE;
static gboolean opt_disable_modules = FALSE;
static gboolean opt_force_load_modules = FALSE;
static gboolean opt_uninstalled = FALSE;
+extern gint opt_housekeeping;
static GOptionEntry opt_entries[] =
{
{"replace", 'r', 0, G_OPTION_ARG_NONE, &opt_replace, "Replace existing daemon", NULL},
@@ -50,6 +51,7 @@ static GOptionEntry opt_entries[] =
{"disable-modules", 0, 0, G_OPTION_ARG_NONE, &opt_disable_modules, "Do not load modules even when asked for it", NULL},
{"force-load-modules", 0, 0, G_OPTION_ARG_NONE, &opt_force_load_modules, "Activate modules on startup", NULL},
{"uninstalled", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &opt_uninstalled, "Load modules from build directory", NULL},
+ {"housekeeping", 'h', 0, G_OPTION_ARG_INT, &opt_housekeeping, "Housekeeping interval in minutes (0=no housekeeping). Default is 10.", NULL},
{NULL }
};
diff --git a/src/udiskslinuxprovider.c b/src/udiskslinuxprovider.c
index c1447bc7..b56441e7 100644
--- a/src/udiskslinuxprovider.c
+++ b/src/udiskslinuxprovider.c
@@ -40,6 +40,8 @@
#include "udisksdaemonutil.h"
#include "udisksconfigmanager.h"
+gint opt_housekeeping = 10;
+
/**
* SECTION:udiskslinuxprovider
* @title: UDisksLinuxProvider
@@ -720,12 +722,21 @@ udisks_linux_provider_start (UDisksProvider *_provider)
g_list_free_full (udisks_devices, g_object_unref);
udisks_info ("Initialization complete");
- /* schedule housekeeping for every 10 minutes */
- provider->housekeeping_timeout = g_timeout_add_seconds (10*60,
- on_housekeeping_timeout,
- provider);
- /* ... and also do an initial run */
- on_housekeeping_timeout (provider);
+ if (opt_housekeeping != 0)
+ {
+ udisks_notice ("Housekeeping set to %d minutes.", opt_housekeeping);
+ /* schedule housekeeping for every 'opt_housekeeping' minutes*/
+ provider->housekeeping_timeout = g_timeout_add_seconds (opt_housekeeping*60,
+ on_housekeeping_timeout,
+ provider);
+ /* ... and also do an initial run */
+ on_housekeeping_timeout (provider);
+ }
+ else
+ {
+ udisks_notice ("Housekeeping deactivated by user.");
+ provider->housekeeping_timeout = 0;
+ }
provider->coldplug = FALSE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment