cdmamodem: check for TUN/TAP devices in ConnMan atom.
authorBertrand Aygon <bertrand.aygon@intel.com>
Sun, 24 Jul 2011 03:32:42 +0000 (05:32 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Sun, 24 Jul 2011 14:45:14 +0000 (16:45 +0200)
drivers/cdmamodem/connman.c

index ce9a748..0df93eb 100644 (file)
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <errno.h>
+#include <sys/stat.h>
 
 #include <glib.h>
 
@@ -41,6 +42,8 @@
 
 #include "cdmamodem.h"
 
+#define TUN_SYSFS_DIR "/sys/devices/virtual/misc/tun"
+
 #define STATIC_IP_NETMASK "255.255.255.255"
 
 static const char *none_prefix[] = { NULL };
@@ -240,9 +243,15 @@ static int cdma_connman_probe(struct ofono_cdma_connman *cm,
 {
        GAtChat *chat = data;
        struct connman_data *cd;
+       struct stat st;
 
        DBG("");
 
+       if (stat(TUN_SYSFS_DIR, &st) < 0) {
+               ofono_error("Missing support for TUN/TAP devices");
+               return -ENODEV;
+       }
+
        cd = g_try_new0(struct connman_data, 1);
        if (cd == NULL)
                return -ENOMEM;