Skip to content

Commit

Permalink
- Update changelog and configuration for kernel command line support
Browse files Browse the repository at this point in the history
- Fix small memory leak in kernel command line handling

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed May 17, 2013
1 parent 9381692 commit db65942
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
10 changes: 8 additions & 2 deletions debian/changelog
@@ -1,9 +1,15 @@
usb-moded (0.61) unstable; urgency=low

* Add basic version of usb_moded_util to not having to remember dbus-send commands
* Fix small bug in the android mode setting
* Add kernel command line support. Thank you Reto Zingg!

-- Philippe De Swert <philippe.deswert@jollamobile.com> Fri, 17 May 2013 14:23:34 +0300

usb-moded (0.60) unstable; urgency=low

* Add dedicated charger tracking
* Config file merging support
* Add basic version of usb_moded_util to not having to remember dbus-send commands
* Fix small bug in the android mode setting

-- Philippe De Swert <philippe.deswert@jollamobile.com> Fri, 10 May 2013 15:56:03 +0300

Expand Down
6 changes: 4 additions & 2 deletions docs/usb_moded-doc.txt
Expand Up @@ -119,13 +119,15 @@ for exmaple:

dbus-send --system --type=method_call --print-reply --dest=com.meego.usb_moded /com/meego/usb_moded com.meego.usb_moded.net_config string:'ip' string:'192.168.2.15'



Usb_moded will generate a random mac address for the g_ether driver. Thus when plugging in the device repeatedly the mac address will not
change and udev rules / network manager etc will not think it is a new device each time.
This mac is stored using the default modprobe configuration and thus will be in /etc/modprobe.d/g_ether.conf
If this file exits usb_moded will assume there is a default mac set and will not do anything.

It is possible to set the configuration on the kernel command line also. Just add a valid keypair in the kernel command line.

for example : ip=192.168.2.15 gateway=192.168.2.2 mode=developer_mode

Functional overview
--------------------

Expand Down
18 changes: 12 additions & 6 deletions src/usb_moded-config.c
Expand Up @@ -239,33 +239,39 @@ static const char * get_kcmdline_string(const char *entry)
GError *optErr = NULL;
int i;

if ((fd = open("/proc/cmdline", O_RDONLY)) < 0){
if ((fd = open("/proc/cmdline", O_RDONLY)) < 0)
{
log_debug("could not read /proc/cmdline");
return(ret);
}

len = read(fd, cmdLine, sizeof(cmdLine) - 1);
close(fd);

if (len <= 0){
if (len <= 0)
{
log_debug("kernel command line was empty");
return(ret);
}

cmdLine[len] = '\0';

if (!g_shell_parse_argv(cmdLine, &argc, &argv, &optErr)) {
if (!g_shell_parse_argv(cmdLine, &argc, &argv, &optErr))
{
g_error_free(optErr);
return(ret);
}

for (i=0; i < argc; i++) {
for (i=0; i < argc; i++)
{
gchar ** arg_tokens;
arg_tokens = g_strsplit(argv[i], "=", 2);
if (!g_ascii_strcasecmp(arg_tokens[0], entry)){
if (!g_ascii_strcasecmp(arg_tokens[0], entry))
{
log_debug("use '%s' for '%s' from kernel command line", arg_tokens[1], entry);
return(arg_tokens[1]);
ret = g_strdup(arg_tokens[1]);
}
g_strfreev(arg_tokens);
}

return(ret);
Expand Down

0 comments on commit db65942

Please sign in to comment.