diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2016-09-28 19:46:12 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2016-09-29 15:43:05 +0200 |
commit | 58c955f5f23e874e4f8c2a4b389e46c0775e7f07 (patch) | |
tree | 568f004df95780b881d22284d642f93e5673221c /src/mm-context.c | |
parent | ae9ede926a1747216b54e22398edde203ec9a03c (diff) |
core: allow building and running without udev
Instead of relying on the udev daemon and GUDev to manage the devices reported
by the kernel, we can now run ModemManager relying solely on the kernel events
reported via the new ReportKernelEvent() API. Therefore, the '--no-auto-scan'
option is implicit for the ModemManager daemon when udev is disabled in the
build.
Additionally, a new custom implementation of the kernel device object is
provided, which uses sysfs to load the properties and attributes required in
each kernel device, instead of using a GUdevDevice.
The udev rule files are kept in place, and a simple custom parser is provided
which preloads all rules in memory once and then applies them to the different
kernel objects reported via ReportKernelEvent(), e.g. to set port type hints.
A simple unit test setup is prepared to validate the udev rules during the
`check' Makefile target.
Diffstat (limited to 'src/mm-context.c')
-rw-r--r-- | src/mm-context.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/mm-context.c b/src/mm-context.c index cf8025bc..c00fa544 100644 --- a/src/mm-context.c +++ b/src/mm-context.c @@ -13,6 +13,7 @@ * Copyright (C) 2012 Aleksander Morgado <aleksander@gnu.org> */ +#include <config.h> #include <stdlib.h> #include "mm-context.h" @@ -20,14 +21,20 @@ /*****************************************************************************/ /* Application context */ -static gboolean version_flag; -static gboolean debug; +static gboolean version_flag; +static gboolean debug; static const gchar *log_level; static const gchar *log_file; -static gboolean show_ts; -static gboolean rel_ts; +static gboolean show_ts; +static gboolean rel_ts; + +#if WITH_UDEV +static gboolean no_auto_scan = FALSE; +#else +static gboolean no_auto_scan = TRUE; +#endif + static const gchar *initial_kernel_events; -static gboolean no_auto_scan; static const GOptionEntry entries[] = { { "version", 'V', 0, G_OPTION_ARG_NONE, &version_flag, "Print version", NULL }, @@ -36,8 +43,14 @@ static const GOptionEntry entries[] = { { "log-file", 0, 0, G_OPTION_ARG_FILENAME, &log_file, "Path to log file", "[PATH]" }, { "timestamps", 0, 0, G_OPTION_ARG_NONE, &show_ts, "Show timestamps in log output", NULL }, { "relative-timestamps", 0, 0, G_OPTION_ARG_NONE, &rel_ts, "Use relative timestamps (from MM start)", NULL }, +#if WITH_UDEV { "no-auto-scan", 0, 0, G_OPTION_ARG_NONE, &no_auto_scan, "Don't auto-scan looking for devices", NULL }, - { "initial-kernel-events", 0, 0, G_OPTION_ARG_FILENAME, &initial_kernel_events, "Path to initial kernel events file (requires --no-auto-scan)", "[PATH]" }, +#else + /* Keep the option when udev disabled, just so that the unit test setup can + * unconditionally use --no-auto-scan */ + { "no-auto-scan", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &no_auto_scan, NULL, NULL }, +#endif + { "initial-kernel-events", 0, 0, G_OPTION_ARG_FILENAME, &initial_kernel_events, "Path to initial kernel events file", "[PATH]" }, { NULL } }; @@ -176,8 +189,10 @@ mm_context_init (gint argc, print_version (); /* Initial kernel events processing may only be used if autoscan is disabled */ +#if WITH_UDEV if (!no_auto_scan && initial_kernel_events) { g_warning ("error: --initial-kernel-events must be used only if --no-auto-scan is also used"); exit (1); } +#endif } |