wifiloader: Make sure WiFi firmware path is writable

Change-Id: Ib0ae2a004d4207a4ccb3d551c9a6a092920595ca
tirimbino
Christopher N. Hesse 7 years ago
parent 5b6ec5682e
commit 56508259a6
  1. 7
      wifiloader/Android.mk
  2. 14
      wifiloader/wifiloader.c

@ -9,6 +9,9 @@ LOCAL_SRC_FILES := \
LOCAL_SHARED_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \
libcutils liblog libutils libcutils liblog libutils
LOCAL_C_INCLUDES := \
system/core/include
ifneq ($(WIFI_DRIVER_MODULE_NAME),) ifneq ($(WIFI_DRIVER_MODULE_NAME),)
LOCAL_CFLAGS += -DWIFI_DRIVER_MODULE_NAME=\"$(WIFI_DRIVER_MODULE_NAME)\" LOCAL_CFLAGS += -DWIFI_DRIVER_MODULE_NAME=\"$(WIFI_DRIVER_MODULE_NAME)\"
endif endif
@ -17,6 +20,10 @@ ifneq ($(WIFI_DRIVER_MODULE_PATH),)
LOCAL_CFLAGS += -DWIFI_DRIVER_MODULE_PATH=\"$(WIFI_DRIVER_MODULE_PATH)\" LOCAL_CFLAGS += -DWIFI_DRIVER_MODULE_PATH=\"$(WIFI_DRIVER_MODULE_PATH)\"
endif endif
ifneq ($(WIFI_DRIVER_FW_PATH_PARAM),)
LOCAL_CFLAGS += -DWIFI_DRIVER_FW_PATH_PARAM=\"$(WIFI_DRIVER_FW_PATH_PARAM)\"
endif
LOCAL_MODULE := wifiloader LOCAL_MODULE := wifiloader
LOCAL_MODULE_TAGS := optional LOCAL_MODULE_TAGS := optional

@ -28,6 +28,8 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#include <private/android_filesystem_config.h>
#define DEFERRED_INITCALLS "/proc/deferred_initcalls" #define DEFERRED_INITCALLS "/proc/deferred_initcalls"
#ifndef WIFI_DRIVER_MODULE_NAME #ifndef WIFI_DRIVER_MODULE_NAME
@ -38,6 +40,10 @@
#define WIFI_DRIVER_MODULE_PATH "/system/lib/modules/" WIFI_DRIVER_MODULE_NAME ".ko" #define WIFI_DRIVER_MODULE_PATH "/system/lib/modules/" WIFI_DRIVER_MODULE_NAME ".ko"
#endif #endif
#ifndef WIFI_DRIVER_FW_PATH_PARAM
#define WIFI_DRIVER_FW_PATH_PARAM "/sys/module/wlan/parameters/fwpath"
#endif
#define finit_module(fd, params, flags) syscall(__NR_finit_module, fd, params, flags) #define finit_module(fd, params, flags) syscall(__NR_finit_module, fd, params, flags)
@ -84,6 +90,14 @@ static int load_module(char const *path)
return -errno; return -errno;
} }
// setup proper permissions for firmware change
if (chown(WIFI_DRIVER_FW_PATH_PARAM, AID_WIFI, AID_WIFI) != 0) {
ALOGE("Failed to chown firmware path %s - error: %s",
WIFI_DRIVER_FW_PATH_PARAM, strerror(errno));
close(fd);
return -errno;
}
// let wifi HAL know we succeeded // let wifi HAL know we succeeded
ALOGV("Successfully loaded WLAN module: %s", WIFI_DRIVER_MODULE_NAME); ALOGV("Successfully loaded WLAN module: %s", WIFI_DRIVER_MODULE_NAME);
property_set("wlan.driver.status", "ok"); property_set("wlan.driver.status", "ok");

Loading…
Cancel
Save