diff --git a/configure.ac b/configure.ac index 168e508..08e8819 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([usb_moded], [0.57]) +AC_INIT([usb_moded], [0.58]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AM_CONFIG_HEADER([config.h]) diff --git a/debian/changelog b/debian/changelog index 3bd56fd..51b0f60 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,16 @@ +usb-moded (0.58) unstable; urgency=low + + * Fix bug with ask mode since module loading failed + * Make sure mac is generated before kmod is initialized to be sure the random mac is used + * Always call clean-up first when modules get switched + + -- Philippe De Swert Fri, 01 Feb 2013 13:36:47 +0200 + usb-moded (0.57) unstable; urgency=low * Add random mac generator so host based network tools always get the same mac - -- Philippe De Swert Thu, 17 Jan 2013 19:50:37 +0200 + -- Philippe De Swert Thu, 17 Jan 2013 19:50:37 +0200 usb-moded (0.56) unstable; urgency=low @@ -10,7 +18,7 @@ usb-moded (0.56) unstable; urgency=low * Fix g_file_storage fallback which did not work anymore with kmod * Warn when using dbus methods to change mode when not connected - -- Philippe De Swert Fri, 11 Jan 2013 18:57:58 +0200 + -- Philippe De Swert Fri, 11 Jan 2013 18:57:58 +0200 usb-moded (0.55) unstable; urgency=low @@ -19,7 +27,7 @@ usb-moded (0.55) unstable; urgency=low * Add rescue mode * Add softconnect support - -- Philippe De Swert Wed, 12 Dec 2012 22:57:42 +0200 + -- Philippe De Swert Wed, 12 Dec 2012 22:57:42 +0200 usb-moded (0.54) unstable; urgency=low diff --git a/src/usb_moded-modules.c b/src/usb_moded-modules.c index 32bfb09..aa3a755 100644 --- a/src/usb_moded-modules.c +++ b/src/usb_moded-modules.c @@ -28,6 +28,7 @@ #include #include +#include #include @@ -73,9 +74,30 @@ int usb_moded_load_module(const char *module) #else const int probe_flags = KMOD_PROBE_APPLY_BLACKLIST; struct kmod_module *mod; - const char *charging_args = NULL; - - ret = kmod_module_new_from_name(ctx, module, &mod); + char *charging_args = NULL; + char *load = NULL; + + /* copy module to load as it might be modified if we're trying charging mode */ + load = strdup(module); + if(!strcmp(module, MODULE_CHARGING) || !strcmp(module, MODULE_CHARGE_FALLBACK)) + { + /* split the string in module name and argument, they are the same for MODULE_CHARGE_FALLBACK + so no need to handle them separately */ + gchar **strings; + + /* since the mass_storage module is the newer one and we check against it to avoid + loading failures we use it here, as we fall back to g_file_storage if g_mass_storage + fails to load */ + strings = g_strsplit(MODULE_CHARGE_FALLBACK, " ", 2); + log_debug("module args = %s, module = %s\n", strings[1], strings[0]); + charging_args = strdup(strings[1]); + /* load was already assigned. Free it to re-assign */ + free(load); + load = strdup(strings[0]); + g_strfreev(strings); + + } + ret = kmod_module_new_from_name(ctx, load, &mod); /* since kmod_module_new_from_name does not check if the module exists we test it's path in case we deal with the mass-storage one */ if(!strcmp(module, MODULE_MASS_STORAGE) && @@ -84,18 +106,16 @@ int usb_moded_load_module(const char *module) log_debug("Fallback on older g_file_storage\n"); ret = kmod_module_new_from_name(ctx, MODULE_FILE_STORAGE, &mod); } - if(!strcmp(module, MODULE_CHARGING) && (ret != 0)) - { - /* split the string in module name and arguments, if it still fails do the same - for MODULE_CHARGE_FALLBACK */ - } if(!charging_args) ret = kmod_module_probe_insert_module(mod, probe_flags, NULL, NULL, NULL, NULL); else + { ret = kmod_module_probe_insert_module(mod, probe_flags, charging_args, NULL, NULL, NULL); - + free(charging_args); + } kmod_module_unref(mod); + free(load); #endif /* NO_KMOD */ softconnect = get_soft_connect_path(); diff --git a/src/usb_moded.c b/src/usb_moded.c index 0331b15..623f347 100644 --- a/src/usb_moded.c +++ b/src/usb_moded.c @@ -473,6 +473,7 @@ static gboolean charging_fallback(gpointer data) * means a mode has been set */ if(strcmp(get_usb_mode(), MODE_ASK) != 0) return FALSE; + set_usb_mode(MODE_CHARGING); /* since this is the fallback, we keep an indication for the UI, as we are not really in charging mode.