diff --git a/ueventd/ueventd_firmware_handler.c b/ueventd/ueventd_firmware_handler.c index 69578eeeffa506dd9c3c9fe9262cda9dcd83109e..db85c08ecd7505ee87143021ffa234cf8c83fe5b 100644 --- a/ueventd/ueventd_firmware_handler.c +++ b/ueventd/ueventd_firmware_handler.c @@ -15,11 +15,32 @@ #include "ueventd_firmware_handler.h" +#include +#include +#include +#include #include "ueventd.h" #define INIT_LOG_TAG "ueventd" #include "init_log.h" +#include "securec.h" void HandleFimwareDeviceEvent(const struct Uevent *uevent) { - INIT_LOGI("Firmware handler not implemented yet."); + char fwLoadingPath[PATH_MAX] = {}; + + if (snprintf_s(fwLoadingPath, PATH_MAX, PATH_MAX - 1, "/sys%s/loading", uevent->syspath) == -1) { + INIT_LOGE("Failed to build firmware loading path"); + return; + } + + int fd = open(fwLoadingPath, O_WRONLY | O_CLOEXEC); + if (fd < 0) { + INIT_LOGE("Failed to open %s, err = %d", fwLoadingPath, errno); + return; + } + + char *endCode = "-1"; + (void)write(fd, "-1", strlen(endCode)); + close(fd); + fd = -1; }