Skip to content

Commit

Permalink
[ifconfig] Query /sys/class/net instead of ifconfig
Browse files Browse the repository at this point in the history
Invoking ifconfig to check for interface existance is overkill,
instead check if the device exists in /sys/class/net

Signed-off-by: Christian Ratzenhofer <christian.ratzenhofer@cdnm.at>
Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Jul 6, 2015
1 parent 0bb1cc4 commit ca67fee
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/usb_moded-network.c
Expand Up @@ -81,11 +81,11 @@ static void free_ipforward_data (struct ipforward_data *ipforward)
/* This function checks if the configured interface exists */
static int check_interface(char *interface)
{
char command[32];
char path[25];
int ret = 0;

snprintf(command, 32, "ifconfig %s > /dev/null\n", interface );
ret = system(command);
snprintf(path, 25, "/sys/class/net/%s", interface );
ret = access(path, F_OK);

return(ret);
}
Expand Down

0 comments on commit ca67fee

Please sign in to comment.