Skip to content

Commit

Permalink
Finalize kmod migration, prep new release
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe De Swert <philippedeswert@gmail.com>
  • Loading branch information
philippedeswert committed Nov 13, 2012
1 parent b994561 commit 4a69943
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion configure.ac
@@ -1,4 +1,4 @@
AC_INIT([usb_moded], [0.53])
AC_INIT([usb_moded], [0.54])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])

AM_CONFIG_HEADER([config.h])
Expand Down
7 changes: 7 additions & 0 deletions debian/changelog
@@ -1,3 +1,10 @@
usb-moded (0.54) unstable; urgency=low

* Instead of spawning shells with system() use libkmod
* Make config file optional as defaults work for most

-- Philippe De Swert <philippedeswert@gmail.com> Tue. 13 Nov 2012 18:56:23 +0300

usb-moded (0.53) unstable; urgency=low

* Un-nokia to make usb_moded more generic
Expand Down
37 changes: 37 additions & 0 deletions src/usb_moded-modules.c
Expand Up @@ -126,12 +126,31 @@ int usb_moded_unload_module(const char *module)
return(ret);
}

/** Check which state a module is in
*
* @return 1 if loaded, 0 when not loaded
*/
static int module_state_check(const char *module)
{
int ret = 0;
struct kmod_module *mod;

kmod_module_new_from_name(ctx, module, &mod);
ret = kmod_module_get_initstate(mod);
kmod_module_unref(mod);
if( ret == KMOD_MODULE_LIVE)
return(1);
else
return(0);
}

/** find which module is loaded
*
* @return The name of the loaded module, or NULL if no modules are loaded.
*/
const char * usb_moded_find_module(void)
{
#ifdef NO_KMOD
FILE *stream = 0;
const char *result = 0;

Expand Down Expand Up @@ -183,6 +202,24 @@ const char * usb_moded_find_module(void)
}

return result;
#endif /* NO_KMOD */

if(module_state_check("g_nokia"))
return(MODULE_NETWORK);
else if(module_state_check("g_ether"))
return(MODULE_WINDOWS_NET);
else if(module_state_check("g_ncm"))
return("g_ncm");
else if(module_state_check("g_ffs"))
return(MODULE_MTP);
else if(module_state_check("g_mass_storage"))
return(MODULE_MASS_STORAGE);
else if(module_state_check("g_file_storage"))
return(MODULE_FILE_STORAGE);
else if(module_state_check(get_usb_module()))
return(get_usb_module());
/* no module loaded */
return(0);
}

/** clean up for modules when usb gets disconnected
Expand Down

0 comments on commit 4a69943

Please sign in to comment.