From: Christopher N. Hesse Date: Wed, 24 Jan 2018 01:14:45 +0000 (+0100) Subject: wifiloader: Make sure WiFi firmware path is writable X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=56508259a620a1b5f5f2178ce7a2bf4c9135c1b5;p=GitHub%2FLineageOS%2Fandroid_hardware_samsung.git wifiloader: Make sure WiFi firmware path is writable Change-Id: Ib0ae2a004d4207a4ccb3d551c9a6a092920595ca --- diff --git a/wifiloader/Android.mk b/wifiloader/Android.mk index 32b80b1..9d27fb7 100644 --- a/wifiloader/Android.mk +++ b/wifiloader/Android.mk @@ -9,6 +9,9 @@ LOCAL_SRC_FILES := \ LOCAL_SHARED_LIBRARIES := \ libcutils liblog libutils +LOCAL_C_INCLUDES := \ + system/core/include + ifneq ($(WIFI_DRIVER_MODULE_NAME),) LOCAL_CFLAGS += -DWIFI_DRIVER_MODULE_NAME=\"$(WIFI_DRIVER_MODULE_NAME)\" endif @@ -17,6 +20,10 @@ ifneq ($(WIFI_DRIVER_MODULE_PATH),) LOCAL_CFLAGS += -DWIFI_DRIVER_MODULE_PATH=\"$(WIFI_DRIVER_MODULE_PATH)\" 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_TAGS := optional diff --git a/wifiloader/wifiloader.c b/wifiloader/wifiloader.c index c827aea..0aeec3e 100644 --- a/wifiloader/wifiloader.c +++ b/wifiloader/wifiloader.c @@ -28,6 +28,8 @@ #include #include +#include + #define DEFERRED_INITCALLS "/proc/deferred_initcalls" #ifndef WIFI_DRIVER_MODULE_NAME @@ -38,6 +40,10 @@ #define WIFI_DRIVER_MODULE_PATH "/system/lib/modules/" WIFI_DRIVER_MODULE_NAME ".ko" #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) @@ -84,6 +90,14 @@ static int load_module(char const *path) 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 ALOGV("Successfully loaded WLAN module: %s", WIFI_DRIVER_MODULE_NAME); property_set("wlan.driver.status", "ok");