提交 8d948a8b 编写于 作者: S sun_fan

init: fix codedex

Signed-off-by: Nsun_fan <sun_fan1@hoperun.com>
上级 f88b96f4
...@@ -13,16 +13,11 @@ ...@@ -13,16 +13,11 @@
* limitations under the License. * limitations under the License.
*/ */
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
#include <ctype.h> #include <ctype.h>
#include <stdio.h>
#include <fcntl.h> #include <fcntl.h>
#include <limits.h>
#include <libgen.h> #include <libgen.h>
#include <limits.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>
#include <sys/mount.h> #include <sys/mount.h>
...@@ -33,6 +28,12 @@ extern "C" { ...@@ -33,6 +28,12 @@ extern "C" {
#include "init_utils.h" #include "init_utils.h"
#include "securec.h" #include "securec.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
struct FsManagerFlags { struct FsManagerFlags {
char *name; char *name;
unsigned int flags; unsigned int flags;
...@@ -89,7 +90,7 @@ static void AddToFstab(Fstab *fstab, FstabItem *item) ...@@ -89,7 +90,7 @@ static void AddToFstab(Fstab *fstab, FstabItem *item)
void ReleaseFstabItem(FstabItem *item) void ReleaseFstabItem(FstabItem *item)
{ {
if (item != NULL) { if (item != NULL) {
if (item->deviceName != NULL) { if (item->deviceName != NULL) {
free(item->deviceName); free(item->deviceName);
item->deviceName = NULL; item->deviceName = NULL;
...@@ -111,7 +112,7 @@ void ReleaseFstabItem(FstabItem *item) ...@@ -111,7 +112,7 @@ void ReleaseFstabItem(FstabItem *item)
} }
free(item); free(item);
item = NULL; item = NULL;
} }
} }
void ReleaseFstab(Fstab *fstab) void ReleaseFstab(Fstab *fstab)
...@@ -238,14 +239,14 @@ Fstab *ReadFstabFromFile(const char *file, bool procMounts) ...@@ -238,14 +239,14 @@ Fstab *ReadFstabFromFile(const char *file, bool procMounts)
} }
// If one line in fstab file parsed with a failure. just give a warning // If one line in fstab file parsed with a failure. just give a warning
// and skip it. // and skip it.
printf("[fs_manager][warning] Cannot parse file \" %s \" at line %u. skip it\n", file, ln); printf("[fs_manager][warning] Cannot parse file \" %s \" at line %zu. skip it\n", file, ln);
continue; continue;
} }
} }
if (line != NULL) { if (line != NULL) {
free(line); free(line);
} }
fclose(fp); (void)fclose(fp);
fp = NULL; fp = NULL;
return fstab; return fstab;
} }
...@@ -312,7 +313,8 @@ static const struct MountFlags mountFlags[] = { ...@@ -312,7 +313,8 @@ static const struct MountFlags mountFlags[] = {
{ "defaults", 0 }, { "defaults", 0 },
}; };
static bool IsDefaultMountFlags(const char *str) { static bool IsDefaultMountFlags(const char *str)
{
bool isDefault = false; bool isDefault = false;
if (str != NULL) { if (str != NULL) {
...@@ -330,7 +332,7 @@ static unsigned long ParseDefaultMountFlag(const char *str) ...@@ -330,7 +332,7 @@ static unsigned long ParseDefaultMountFlag(const char *str)
unsigned long flags = 0; unsigned long flags = 0;
if (str != NULL) { if (str != NULL) {
for (size_t i = 0; i < ARRAY_LENGTH(mountFlags); i++) { for (size_t i = 0; i < ARRAY_LENGTH(mountFlags); i++) {
if (strcmp(str, mountFlags[i].name) == 0) { if (strcmp(str, mountFlags[i].name) == 0) {
flags = mountFlags[i].flags; flags = mountFlags[i].flags;
break; break;
...@@ -340,11 +342,11 @@ static unsigned long ParseDefaultMountFlag(const char *str) ...@@ -340,11 +342,11 @@ static unsigned long ParseDefaultMountFlag(const char *str)
return flags; return flags;
} }
unsigned long GetMountFlags(char *mountFlags, char *fsSpecificData, size_t fsSpecificDataSize) unsigned long GetMountFlags(char *flags, char *fsSpecificData, size_t fsSpecificDataSize)
{ {
unsigned long flags = 0; unsigned long flags = 0;
if (mountFlags == NULL || fsSpecificData == NULL) { if (flags == NULL || fsSpecificData == NULL) {
return 0; return 0;
} }
...@@ -356,7 +358,7 @@ unsigned long GetMountFlags(char *mountFlags, char *fsSpecificData, size_t fsSpe ...@@ -356,7 +358,7 @@ unsigned long GetMountFlags(char *mountFlags, char *fsSpecificData, size_t fsSpe
// If the item configured in fstab contains flag over than 15, // If the item configured in fstab contains flag over than 15,
// @SplitStringExt can handle it and parse them all. but the parse function will drop it. // @SplitStringExt can handle it and parse them all. but the parse function will drop it.
const int maxCount = 15; const int maxCount = 15;
char **flagsVector = SplitStringExt(mountFlags, ",", &flagCount, maxCount); char **flagsVector = SplitStringExt(flags, ",", &flagCount, maxCount);
if (flagsVector == NULL || flagCount == 0) { if (flagsVector == NULL || flagCount == 0) {
// No flags or something wrong in SplitStringExt,just return. // No flags or something wrong in SplitStringExt,just return.
......
...@@ -13,11 +13,6 @@ ...@@ -13,11 +13,6 @@
* limitations under the License. * limitations under the License.
*/ */
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -33,7 +28,15 @@ extern "C" { ...@@ -33,7 +28,15 @@ extern "C" {
#include "init_utils.h" #include "init_utils.h"
#include "securec.h" #include "securec.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
#define FS_MANAGER_BUFFER_SIZE 512 #define FS_MANAGER_BUFFER_SIZE 512
#define BLOCK_SIZE_BUFFER (64)
bool IsSupportedFilesystem(const char *fsType) bool IsSupportedFilesystem(const char *fsType)
{ {
static const char *supportedFilesystem[] = {"ext4", "f2fs", NULL}; static const char *supportedFilesystem[] = {"ext4", "f2fs", NULL};
...@@ -84,7 +87,6 @@ int DoFormat(const char *devPath, const char *fsType) ...@@ -84,7 +87,6 @@ int DoFormat(const char *devPath, const char *fsType)
return -1; return -1;
} }
int ret = 0; int ret = 0;
#define BLOCK_SIZE_BUFFER (64)
char blockSizeBuffer[BLOCK_SIZE_BUFFER] = {0}; char blockSizeBuffer[BLOCK_SIZE_BUFFER] = {0};
if (strcmp(fsType, "ext4") == 0) { if (strcmp(fsType, "ext4") == 0) {
const unsigned int blockSize = 4096; const unsigned int blockSize = 4096;
...@@ -106,7 +108,6 @@ int DoFormat(const char *devPath, const char *fsType) ...@@ -106,7 +108,6 @@ int DoFormat(const char *devPath, const char *fsType)
char **argv = (char **)formatCmds; char **argv = (char **)formatCmds;
ret = ExecCommand(argc, argv); ret = ExecCommand(argc, argv);
} }
#undef BLOCK_SIZE_BUFFER
return ret; return ret;
} }
...@@ -148,7 +149,7 @@ MountStatus GetMountStatusForMountPoint(const char *mp) ...@@ -148,7 +149,7 @@ MountStatus GetMountStatusForMountPoint(const char *mp)
} else if (feof(fp) > 0) { } else if (feof(fp) > 0) {
status = MOUNT_UMOUNTED; status = MOUNT_UMOUNTED;
} }
fclose(fp); (void)fclose(fp);
fp = NULL; fp = NULL;
return status; return status;
} }
...@@ -260,7 +261,7 @@ int UmountAllWithFstabFile(const char *fstabFile) ...@@ -260,7 +261,7 @@ int UmountAllWithFstabFile(const char *fstabFile)
Fstab *fstab = NULL; Fstab *fstab = NULL;
if ((fstab = ReadFstabFromFile(fstabFile, false)) == NULL) { if ((fstab = ReadFstabFromFile(fstabFile, false)) == NULL) {
printf("[fs_manager][error] Read fstab file \" %s \" failed\n", fstabFile); printf("[fs_manager][error] Read fstab file \" %s \" failed\n", fstabFile);
return -1;; return -1;
} }
FstabItem *item = NULL; FstabItem *item = NULL;
......
...@@ -16,12 +16,13 @@ ...@@ -16,12 +16,13 @@
#ifndef STARTUP_FS_MANAGER_H #ifndef STARTUP_FS_MANAGER_H
#define STARTUP_FS_MANAGER_H #define STARTUP_FS_MANAGER_H
#include <stdbool.h>
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
extern "C" { extern "C" {
#endif #endif
#endif #endif
#include <stdbool.h>
/* Fs manager flags definition */ /* Fs manager flags definition */
#define FS_MANAGER_CHECK 0x00000001 #define FS_MANAGER_CHECK 0x00000001
...@@ -45,7 +46,7 @@ typedef struct FstabItem { ...@@ -45,7 +46,7 @@ typedef struct FstabItem {
char *deviceName; // Block device name char *deviceName; // Block device name
char *mountPoint; // Mount point char *mountPoint; // Mount point
char *fsType; // File system type char *fsType; // File system type
char * mountOptions; // File system mount options. readonly, rw, remount etc. char *mountOptions; // File system mount options. readonly, rw, remount etc.
unsigned int fsManagerFlags; // flags defined by fs manager. unsigned int fsManagerFlags; // flags defined by fs manager.
struct FstabItem *next; struct FstabItem *next;
} FstabItem; } FstabItem;
...@@ -65,7 +66,7 @@ int MountOneItem(FstabItem *item); ...@@ -65,7 +66,7 @@ int MountOneItem(FstabItem *item);
MountStatus GetMountStatusForMountPoint(const char *mp); MountStatus GetMountStatusForMountPoint(const char *mp);
int MountAllWithFstabFile(const char *file, bool required); int MountAllWithFstabFile(const char *file, bool required);
int UmountAllWithFstabFile(const char *file); int UmountAllWithFstabFile(const char *file);
unsigned long GetMountFlags(char *mountFlags, char *fsSpecificFlags, size_t fsSpecificFlagSize); unsigned long GetMountFlags(char *flags, char *fsSpecificFlags, size_t fsSpecificFlagSize);
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
} }
......
...@@ -13,7 +13,9 @@ ...@@ -13,7 +13,9 @@
* limitations under the License. * limitations under the License.
*/ */
#ifndef INIT_SWITCH_ROOT_H #ifndef INIT_SWITCH_ROOT_H
#define INIT_SWITCH_ROOT_H #define INIT_SWITCH_ROOT_H
int SwitchRoot(const char *newRoot);
#endif // INIT_SWITCH_ROOT_H int SwitchRoot(const char *newRoot);
\ No newline at end of file
#endif // INIT_SWITCH_ROOT_H
\ No newline at end of file
...@@ -37,7 +37,7 @@ void SystemInit(void) ...@@ -37,7 +37,7 @@ void SystemInit(void)
void LogInit(void) void LogInit(void)
{ {
return;
} }
void SystemPrepare(void) void SystemPrepare(void)
......
...@@ -12,11 +12,13 @@ ...@@ -12,11 +12,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "init_cmds.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "init.h" #include "init.h"
#include "init_cmds.h"
#include "init_log.h" #include "init_log.h"
#include "init_utils.h" #include "init_utils.h"
#include "securec.h" #include "securec.h"
......
...@@ -20,6 +20,7 @@ static const pid_t INIT_PROCESS_PID = 1; ...@@ -20,6 +20,7 @@ static const pid_t INIT_PROCESS_PID = 1;
int main(int argc, char* const argv[]) int main(int argc, char* const argv[])
{ {
int isSecondStage = 0; int isSecondStage = 0;
// Number of command line parameters is 2
if (argc == 2 && (strcmp(argv[1], "--second-stage") == 0)) { if (argc == 2 && (strcmp(argv[1], "--second-stage") == 0)) {
isSecondStage = 1; isSecondStage = 1;
} }
......
...@@ -91,7 +91,7 @@ static void StartInitSecondStage(void) ...@@ -91,7 +91,7 @@ static void StartInitSecondStage(void)
char *const args[] = { char *const args[] = {
"/bin/init", "/bin/init",
"--second-stage", "--second-stage",
NULL, NULL,
}; };
if (execv("/bin/init", args) != 0) { if (execv("/bin/init", args) != 0) {
INIT_LOGE("Failed to exec \"/bin/init\", err = %d", errno); INIT_LOGE("Failed to exec \"/bin/init\", err = %d", errno);
......
...@@ -32,13 +32,13 @@ ...@@ -32,13 +32,13 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
#include "fs_manager/fs_manager.h"
#include "init.h" #include "init.h"
#include "init_jobs.h" #include "init_jobs.h"
#include "init_log.h" #include "init_log.h"
#include "init_param.h" #include "init_param.h"
#include "init_service_manager.h" #include "init_service_manager.h"
#include "init_utils.h" #include "init_utils.h"
#include "fs_manager/fs_manager.h"
#include "securec.h" #include "securec.h"
int GetParamValue(const char *symValue, unsigned int symLen, char *paramValue, unsigned int paramLen) int GetParamValue(const char *symValue, unsigned int symLen, char *paramValue, unsigned int paramLen)
......
...@@ -54,14 +54,15 @@ static void FreeOldRoot(DIR *dir, dev_t dev) ...@@ -54,14 +54,15 @@ static void FreeOldRoot(DIR *dir, dev_t dev)
if (S_ISDIR(st.st_mode)) { if (S_ISDIR(st.st_mode)) {
int fd = openat(dfd, de->d_name, O_RDONLY | O_DIRECTORY); int fd = openat(dfd, de->d_name, O_RDONLY | O_DIRECTORY);
isDir = true; isDir = true;
if (fd >= 0) { if (fd < 0) {
DIR *subDir = fdopendir(fd); continue;
if (subDir != NULL) { }
FreeOldRoot(subDir, dev); DIR *subDir = fdopendir(fd);
closedir(subDir); if (subDir != NULL) {
} else { FreeOldRoot(subDir, dev);
close(fd); closedir(subDir);
} } else {
close(fd);
} }
} }
} }
......
...@@ -20,6 +20,14 @@ ...@@ -20,6 +20,14 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#ifdef OHOS_LITE
#include "hilog/log.h"
#else
#ifdef INIT_AGENT
#include "hilog/log.h"
#endif
#endif
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
extern "C" { extern "C" {
...@@ -45,7 +53,6 @@ void SetInitLogLevel(InitLogLevel logLevel); ...@@ -45,7 +53,6 @@ void SetInitLogLevel(InitLogLevel logLevel);
#endif #endif
#ifdef OHOS_LITE #ifdef OHOS_LITE
#include "hilog/log.h"
#undef LOG_DOMAIN #undef LOG_DOMAIN
#define LOG_DOMAIN 0xD000719 #define LOG_DOMAIN 0xD000719
...@@ -79,7 +86,6 @@ void InitToHiLog(InitLogLevel logLevel, const char *fmt, ...); ...@@ -79,7 +86,6 @@ void InitToHiLog(InitLogLevel logLevel, const char *fmt, ...);
#define LABEL "ParamAgent" #define LABEL "ParamAgent"
#endif #endif
#include "hilog/log.h"
#define PARAM_AGENT_LOG_PATH "/data/init_agent/init_agent.log" #define PARAM_AGENT_LOG_PATH "/data/init_agent/init_agent.log"
#define STARTUP_LOGD(LABEL, fmt, ...) \ #define STARTUP_LOGD(LABEL, fmt, ...) \
......
...@@ -314,7 +314,7 @@ int ParamTimerStart(ParamTaskPtr timer, uint64_t timeout, uint64_t repeat) ...@@ -314,7 +314,7 @@ int ParamTimerStart(ParamTaskPtr timer, uint64_t timeout, uint64_t repeat)
return -1; return -1;
} }
int ParamServiceStart() int ParamServiceStart(void)
{ {
if (uv_default_loop() == NULL) { if (uv_default_loop() == NULL) {
return -1; return -1;
......
...@@ -112,7 +112,7 @@ static void ExeuteCmdParamRead(int argc, char *argv[], int start) ...@@ -112,7 +112,7 @@ static void ExeuteCmdParamRead(int argc, char *argv[], int start)
SystemSetParameter("test.randrom.test.start", "1"); SystemSetParameter("test.randrom.test.start", "1");
char buffer[PARAM_NAME_LEN_MAX] = {0}; char buffer[PARAM_NAME_LEN_MAX] = {0};
printf("SystemGetParameter start \n"); printf("SystemGetParameter start \n");
srand((unsigned)time(NULL)); (void)srand((unsigned)time(NULL));
while (1) { while (1) {
int wait = rand() / READ_DURATION + READ_DURATION; // 100ms int wait = rand() / READ_DURATION + READ_DURATION; // 100ms
uint32_t size = PARAM_NAME_LEN_MAX; uint32_t size = PARAM_NAME_LEN_MAX;
...@@ -170,17 +170,6 @@ int RunParamCommand(int argc, char *argv[]) ...@@ -170,17 +170,6 @@ int RunParamCommand(int argc, char *argv[])
space->securityLabel->cred.gid = testUid; space->securityLabel->cred.gid = testUid;
} }
#endif #endif
if ((strcmp(argv[0], "./paramset") == 0) || (strcmp(argv[0], "paramset") == 0)) {
if (argc == (MIN_ARGC + 1)) {
ExeuteCmdParamSet(argc, argv, 1);
} else {
printf("param set key value \n");
}
return 0;
} else if ((strcmp(argv[0], "./paramget") == 0) || (strcmp(argv[0], "paramget") == 0)) {
ExeuteCmdParamSet(argc, argv, 1);
return 0;
}
if (argc < MIN_ARGC) { if (argc < MIN_ARGC) {
printf("usage: \n"); printf("usage: \n");
for (size_t i = 0; i < sizeof(paramCmds) / sizeof(paramCmds[0]); i++) { for (size_t i = 0; i < sizeof(paramCmds) / sizeof(paramCmds[0]); i++) {
......
...@@ -104,7 +104,7 @@ typedef struct { ...@@ -104,7 +104,7 @@ typedef struct {
} ParamStreamInfo; } ParamStreamInfo;
int ParamServiceStop(void); int ParamServiceStop(void);
int ParamServiceStart(); int ParamServiceStart(void);
int ParamTaskClose(ParamTaskPtr stream); int ParamTaskClose(ParamTaskPtr stream);
int ParamServerCreate(ParamTaskPtr *server, const ParamStreamInfo *info); int ParamServerCreate(ParamTaskPtr *server, const ParamStreamInfo *info);
......
...@@ -43,7 +43,7 @@ static void AddTestTrigger(const TriggerWorkSpace *workSpace) ...@@ -43,7 +43,7 @@ static void AddTestTrigger(const TriggerWorkSpace *workSpace)
static void TestTimerCallback(ParamTaskPtr timer, void *context) static void TestTimerCallback(ParamTaskPtr timer, void *context)
{ {
srand((unsigned)time(NULL)); (void)srand((unsigned)time(NULL));
char buffer[32] = { 0 }; char buffer[32] = { 0 };
static int index = 0; static int index = 0;
index++; index++;
...@@ -54,7 +54,7 @@ static void TestTimerCallback(ParamTaskPtr timer, void *context) ...@@ -54,7 +54,7 @@ static void TestTimerCallback(ParamTaskPtr timer, void *context)
int count = 0; int count = 0;
while (count < MAX_COUNT) { while (count < MAX_COUNT) {
int wait = rand() / READ_DURATION + READ_DURATION; // 100ms int wait = rand() / READ_DURATION + READ_DURATION; // 100ms
sprintf_s(buffer, sizeof(buffer), "%u", value); (void)sprintf_s(buffer, sizeof(buffer), "%u", value);
PARAM_LOGI("set param name: %s, value %s", TEST_PARAM_NAME, buffer); PARAM_LOGI("set param name: %s, value %s", TEST_PARAM_NAME, buffer);
SystemWriteParam(TEST_PARAM_NAME, buffer); SystemWriteParam(TEST_PARAM_NAME, buffer);
usleep(wait); usleep(wait);
......
...@@ -73,7 +73,10 @@ private: ...@@ -73,7 +73,10 @@ private:
DISALLOW_COPY_AND_MOVE(DeathRecipient); DISALLOW_COPY_AND_MOVE(DeathRecipient);
void OnRemoteDied(const wptr<IRemoteObject> &remote) final; void OnRemoteDied(const wptr<IRemoteObject> &remote) final;
}; };
sptr<IRemoteObject::DeathRecipient> GetDeathRecipient() { return deathRecipient_; } sptr<IRemoteObject::DeathRecipient> GetDeathRecipient()
{
return deathRecipient_;
}
private: private:
void SetParamWatcher(const std::string &keyPrefix, ParamWatcherKitPtr watcher); void SetParamWatcher(const std::string &keyPrefix, ParamWatcherKitPtr watcher);
......
...@@ -173,7 +173,7 @@ char **SplitStringExt(char *buffer, const char *del, int *returnCount, int maxIt ...@@ -173,7 +173,7 @@ char **SplitStringExt(char *buffer, const char *del, int *returnCount, int maxIt
int count = 0; int count = 0;
while (p != NULL) { while (p != NULL) {
if (count > itemCounts - 1) { if (count > itemCounts - 1) {
itemCounts += (itemCounts / 2) + 1; itemCounts += (itemCounts / 2) + 1; // Request to increase the original memory by half.
INIT_LOGD("Too many items,expand size"); INIT_LOGD("Too many items,expand size");
char **expand = (char **)(realloc(items, sizeof(char *) * itemCounts)); char **expand = (char **)(realloc(items, sizeof(char *) * itemCounts));
if (expand == NULL) { if (expand == NULL) {
......
...@@ -221,32 +221,37 @@ static void DoTrigger(const char *ueventPath, int sockFd) ...@@ -221,32 +221,37 @@ static void DoTrigger(const char *ueventPath, int sockFd)
static void Trigger(const char *path, int sockFd) static void Trigger(const char *path, int sockFd)
{ {
if (path == NULL) {
return;
}
DIR *dir = opendir(path); DIR *dir = opendir(path);
if (dir != NULL) { if (dir == NULL) {
struct dirent *dirent = NULL; return;
while ((dirent = readdir(dir)) != NULL) { }
if (dirent->d_name[0] == '.') { struct dirent *dirent = NULL;
continue; while ((dirent = readdir(dir)) != NULL) {
} if (dirent->d_name[0] == '.') {
if (dirent->d_type == DT_DIR) { continue;
char pathBuffer[PATH_MAX]; }
if (snprintf_s(pathBuffer, PATH_MAX, PATH_MAX - 1, "%s/%s", path, dirent->d_name) == -1) { if (dirent->d_type == DT_DIR) {
continue; char pathBuffer[PATH_MAX];
} if (snprintf_s(pathBuffer, PATH_MAX, PATH_MAX - 1, "%s/%s", path, dirent->d_name) == -1) {
Trigger(pathBuffer, sockFd); continue;
} else { }
if (!strcmp(dirent->d_name, "uevent")) { Trigger(pathBuffer, sockFd);
char ueventBuffer[PATH_MAX]; } else {
if (snprintf_s(ueventBuffer, PATH_MAX, PATH_MAX - 1, "%s/%s", path, "uevent") == -1) { if (strcmp(dirent->d_name, "uevent") != 0) {
INIT_LOGW("Cannnot build uevent path under %s", path); continue;
continue; }
} char ueventBuffer[PATH_MAX];
DoTrigger(ueventBuffer, sockFd); if (snprintf_s(ueventBuffer, PATH_MAX, PATH_MAX - 1, "%s/%s", path, "uevent") == -1) {
} INIT_LOGW("Cannnot build uevent path under %s", path);
} continue;
} }
closedir(dir); DoTrigger(ueventBuffer, sockFd);
}
} }
closedir(dir);
} }
static void RetriggerUevent(int sockFd) static void RetriggerUevent(int sockFd)
......
...@@ -304,7 +304,7 @@ static const char *GetDeviceName(char *sysPath, const char *deviceName) ...@@ -304,7 +304,7 @@ static const char *GetDeviceName(char *sysPath, const char *deviceName)
} }
if (deviceName != NULL && deviceName[0] != '\0') { if (deviceName != NULL && deviceName[0] != '\0') {
// if device name reported by kernel includes '/', skip it. // if device name reported by kernel includes '/', skip it.
// TODO: use entire device name reported by kernel // use entire device name reported by kernel
devName = basename((char *)deviceName); devName = basename((char *)deviceName);
char *p = strrchr(deviceName, '/'); char *p = strrchr(deviceName, '/');
if (p != NULL) { // device name includes slash if (p != NULL) { // device name includes slash
......
...@@ -13,17 +13,17 @@ ...@@ -13,17 +13,17 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ueventd_firmware_handler.h"
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "ueventd_firmware_handler.h"
#include "ueventd.h" #include "ueventd.h"
#define INIT_LOG_TAG "ueventd" #define INIT_LOG_TAG "ueventd"
#include "init_log.h" #include "init_log.h"
void HandleFimwareDeviceEvent(const struct Uevent *uevent) void HandleFimwareDeviceEvent(const struct Uevent *uevent)
{ {
// TODO, implement it later.
INIT_LOGI("Firmware handler not implemented yet."); INIT_LOGI("Firmware handler not implemented yet.");
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册