Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
ff5fc57f
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
接近 2 年 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ff5fc57f
编写于
2月 21, 2022
作者:
X
xionglei6
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add bootchart
Signed-off-by:
N
xionglei6
<
xionglei6@huawei.com
>
上级
95d8cd81
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
52 addition
and
49 deletion
+52
-49
services/init/include/init_group_manager.h
services/init/include/init_group_manager.h
+1
-1
services/init/lite/init_reboot.c
services/init/lite/init_reboot.c
+1
-1
services/init/standard/init_plugin_manager.c
services/init/standard/init_plugin_manager.c
+1
-1
services/init/standard/init_reboot.c
services/init/standard/init_reboot.c
+10
-6
services/plugin/bootchart/bootchart.c
services/plugin/bootchart/bootchart.c
+38
-37
services/plugin/bootchart/bootchart.h
services/plugin/bootchart/bootchart.h
+1
-3
未找到文件。
services/init/include/init_group_manager.h
浏览文件 @
ff5fc57f
...
...
@@ -87,7 +87,7 @@ HashMapHandle GetGroupHashMap(int type);
#ifdef STARTUP_INIT_TEST
InitWorkspace
*
GetInitWorkspace
(
void
);
#endif
int
GetBootModeFromMisc
();
int
GetBootModeFromMisc
(
void
);
#ifdef __cplusplus
#if __cplusplus
}
...
...
services/init/lite/init_reboot.c
浏览文件 @
ff5fc57f
...
...
@@ -29,7 +29,7 @@ void ExecReboot(const char *value)
return
;
}
int
GetBootModeFromMisc
()
int
GetBootModeFromMisc
(
void
)
{
return
0
;
}
services/init/standard/init_plugin_manager.c
浏览文件 @
ff5fc57f
...
...
@@ -315,7 +315,7 @@ static int PluginCmdUninstall(int id, const char *name, int argc, const char **a
return
0
;
}
static
int
LoadPluginCfg
()
static
int
LoadPluginCfg
(
void
)
{
char
*
fileBuf
=
ReadFileToBuf
(
DEFAULT_PLUGIN_CFG
);
INIT_ERROR_CHECK
(
fileBuf
!=
NULL
,
return
-
1
,
"Failed to read file content %s"
,
DEFAULT_PLUGIN_CFG
);
...
...
services/init/standard/init_reboot.c
浏览文件 @
ff5fc57f
...
...
@@ -65,12 +65,16 @@ static int RBMiscWriteUpdaterMessage(const char *path, const struct RBMiscUpdate
static
int
RBMiscReadUpdaterMessage
(
const
char
*
path
,
struct
RBMiscUpdateMessage
*
boot
)
{
char
*
realPath
=
GetRealPath
(
path
);
INIT_ERROR_CHECK
(
realPath
!=
NULL
,
return
-
1
,
"Failed to get realpath %s"
,
path
);
int
ret
=
0
;
FILE
*
fp
=
fopen
(
realPath
,
"rb"
);
free
(
realPath
);
realPath
=
NULL
;
FILE
*
fp
=
NULL
;
char
*
realPath
=
GetRealPath
(
path
);
if
(
realPath
!=
NULL
)
{
fp
=
fopen
(
realPath
,
"rb"
);
free
(
realPath
);
realPath
=
NULL
;
}
else
{
fp
=
fopen
(
path
,
"rb"
);
}
if
(
fp
!=
NULL
)
{
size_t
readLen
=
fread
(
boot
,
1
,
sizeof
(
struct
RBMiscUpdateMessage
),
fp
);
(
void
)
fclose
(
fp
);
...
...
@@ -83,7 +87,7 @@ static int RBMiscReadUpdaterMessage(const char *path, struct RBMiscUpdateMessage
return
ret
;
}
int
GetBootModeFromMisc
()
int
GetBootModeFromMisc
(
void
)
{
char
miscFile
[
PATH_MAX
]
=
{
0
};
int
ret
=
GetBlockDevicePath
(
"/misc"
,
miscFile
,
PATH_MAX
);
...
...
services/plugin/bootchart/bootchart.c
浏览文件 @
ff5fc57f
...
...
@@ -18,6 +18,7 @@
#include <dirent.h>
#include <stdint.h>
#include <sys/utsname.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
...
...
@@ -32,7 +33,7 @@
static
BootchartCtrl
*
g_bootchartCtrl
=
NULL
;
static
PluginInterface
*
g_pluginInterface
=
NULL
;
static
uint64_t
GetJiffies
()
static
uint64_t
GetJiffies
(
void
)
{
struct
timespec
time1
=
{
0
};
clock_gettime
(
CLOCK_MONOTONIC
,
&
time1
);
...
...
@@ -62,48 +63,48 @@ char *ReadFileToBuffer(const char *fileName, char *buffer, uint32_t bufferSize)
return
(
readLen
>
0
)
?
buffer
:
NULL
;
}
static
void
BootchartLogHeader
()
static
void
BootchartLogHeader
(
void
)
{
char
date
[
32
];
// 32 data size
time_t
now_t
=
time
(
NULL
);
struct
tm
now
=
*
localtime
(
&
now_t
);
strftime
(
date
,
sizeof
(
date
),
"%F %T"
,
&
now
);
time_t
tm
=
time
(
NULL
);
PLUGIN_CHECK
(
tm
>=
0
,
return
,
"Failed to get time"
);
struct
tm
*
now
=
localtime
(
&
tm
);
PLUGIN_CHECK
(
now
!=
NULL
,
return
,
"Failed to get local time"
);
size_t
size
=
strftime
(
date
,
sizeof
(
date
),
"%F %T"
,
now
);
PLUGIN_CHECK
(
size
>=
0
,
return
,
"Failed to strftime"
);
struct
utsname
uts
;
if
(
uname
(
&
uts
)
==
-
1
)
{
return
;
}
char
finger
[
PARAM_VALUE_LEN_MAX
]
=
{};
uint32_t
size
=
sizeof
(
finger
);
char
release
[
PARAM_VALUE_LEN_MAX
]
=
{};
uint32_t
len
=
sizeof
(
release
);
if
(
g_pluginInterface
->
systemReadParam
!=
NULL
)
{
g_pluginInterface
->
systemReadParam
(
"const.build.fingerprint"
,
finger
,
&
size
);
(
void
)
g_pluginInterface
->
systemReadParam
(
"hw_sc.build.os.releasetype"
,
release
,
&
len
);
}
/*if (strlen(finger) == 0) {
return;
}*/
char
*
cmdLine
=
ReadFileToBuffer
(
"/proc/cmdline"
,
g_bootchartCtrl
->
buffer
,
g_bootchartCtrl
->
bufferSize
);
PLUGIN_CHECK
(
cmdLine
!=
NULL
,
return
,
"Failed to open file /data/bootchart/header"
);
FILE
*
file
=
fopen
(
"/data/bootchart/header"
,
"we"
);
PLUGIN_CHECK
(
file
!=
NULL
,
return
,
"Failed to open file /data/bootchart/header"
);
fprintf
(
file
,
"version = openharmony init
\n
"
);
fprintf
(
file
,
"title = Boot chart for openharmony (%s)
\n
"
,
date
);
fprintf
(
file
,
"system.uname = %s %s %s %s
\n
"
,
uts
.
sysname
,
uts
.
release
,
uts
.
version
,
uts
.
machine
);
//fprintf(file, "system.release = %s\n", finger);
fprintf
(
file
,
"system.cpu = %s
\n
"
,
uts
.
machine
);
fprintf
(
file
,
"system.kernel.options = %s
\n
"
,
cmdLine
);
fclose
(
file
);
(
void
)
fprintf
(
file
,
"version = openharmony init
\n
"
);
(
void
)
fprintf
(
file
,
"title = Boot chart for openharmony (%s)
\n
"
,
date
);
(
void
)
fprintf
(
file
,
"system.uname = %s %s %s %s
\n
"
,
uts
.
sysname
,
uts
.
release
,
uts
.
version
,
uts
.
machine
);
if
(
strlen
(
release
)
>
0
)
{
(
void
)
fprintf
(
file
,
"system.release = %s
\n
"
,
release
);
}
(
void
)
fprintf
(
file
,
"system.cpu = %s
\n
"
,
uts
.
machine
);
(
void
)
fprintf
(
file
,
"system.kernel.options = %s
\n
"
,
cmdLine
);
(
void
)
fclose
(
file
);
}
static
void
bootchartLogFile
(
FILE
*
log
,
const
char
*
procfile
)
{
fprintf
(
log
,
"%lld
\n
"
,
GetJiffies
());
(
void
)
fprintf
(
log
,
"%lld
\n
"
,
GetJiffies
());
char
*
data
=
ReadFileToBuffer
(
procfile
,
g_bootchartCtrl
->
buffer
,
g_bootchartCtrl
->
bufferSize
);
if
(
data
!=
NULL
)
{
fprintf
(
log
,
"%s
\n
"
,
data
);
(
void
)
fprintf
(
log
,
"%s
\n
"
,
data
);
}
}
...
...
@@ -135,21 +136,20 @@ static void bootchartLogProcessStat(FILE *log, pid_t pid)
}
if
(
end
!=
NULL
)
{
stat
[
start
-
stat
+
1
]
=
'\0'
;
fputs
(
stat
,
log
);
fputs
(
name
,
log
);
fputs
(
end
,
log
);
(
void
)
fputs
(
stat
,
log
);
(
void
)
fputs
(
name
,
log
);
(
void
)
fputs
(
end
,
log
);
}
else
{
fputs
(
stat
,
log
);
(
void
)
fputs
(
stat
,
log
);
}
}
else
{
fputs
(
stat
,
log
);
(
void
)
fputs
(
stat
,
log
);
}
}
static
void
bootchartLogProcess
(
FILE
*
log
)
{
fprintf
(
log
,
"%lld
\n
"
,
GetJiffies
());
(
void
)
fprintf
(
log
,
"%lld
\n
"
,
GetJiffies
());
DIR
*
pDir
=
opendir
(
"/proc"
);
PLUGIN_CHECK
(
pDir
!=
NULL
,
return
,
"Read dir /proc failed.%d"
,
errno
);
struct
dirent
*
entry
;
...
...
@@ -161,7 +161,7 @@ static void bootchartLogProcess(FILE *log)
bootchartLogProcessStat
(
log
,
pid
);
}
closedir
(
pDir
);
fputc
(
'\n'
,
log
);
(
void
)
fputc
(
'\n'
,
log
);
}
static
void
*
BootchartThreadMain
(
void
*
data
)
...
...
@@ -200,21 +200,21 @@ static void *BootchartThreadMain(void *data)
if
(
statFile
!=
NULL
)
{
(
void
)
fflush
(
statFile
);
fclose
(
statFile
);
(
void
)
fclose
(
statFile
);
}
if
(
procFile
!=
NULL
)
{
(
void
)
fflush
(
procFile
);
fclose
(
procFile
);
(
void
)
fclose
(
procFile
);
}
if
(
diskFile
!=
NULL
)
{
(
void
)
fflush
(
diskFile
);
fclose
(
diskFile
);
(
void
)
fclose
(
diskFile
);
}
PLUGIN_LOGI
(
"bootcharting stop"
);
return
NULL
;
}
static
void
BootchartDestory
()
static
void
BootchartDestory
(
void
)
{
pthread_mutex_destroy
(
&
(
g_bootchartCtrl
->
mutex
));
pthread_cond_destroy
(
&
(
g_bootchartCtrl
->
cond
));
...
...
@@ -222,7 +222,7 @@ static void BootchartDestory()
g_bootchartCtrl
=
NULL
;
}
static
int
DoBootchartStart
()
static
int
DoBootchartStart
(
void
)
{
if
(
g_pluginInterface
==
NULL
)
{
PLUGIN_LOGI
(
"Invalid bootchart plugin"
);
...
...
@@ -267,7 +267,7 @@ static int DoBootchartStart()
return
0
;
}
static
int
DoBootchartStop
()
static
int
DoBootchartStop
(
void
)
{
if
(
g_bootchartCtrl
==
NULL
||
!
g_bootchartCtrl
->
start
)
{
PLUGIN_LOGI
(
"bootcharting not start"
);
...
...
@@ -307,7 +307,8 @@ static int BootchartInit(void)
"Invalid install parameter"
);
for
(
int
i
=
0
;
i
<
(
int
)(
sizeof
(
g_bootchartCmds
)
/
sizeof
(
g_bootchartCmds
[
0
]));
i
++
)
{
g_bootchartCmds
[
i
].
index
=
g_pluginInterface
->
addCmdExecutor
(
g_bootchartCmds
[
i
].
name
,
g_bootchartCmds
[
i
].
cmdExecutor
);
g_bootchartCmds
[
i
].
index
=
g_pluginInterface
->
addCmdExecutor
(
g_bootchartCmds
[
i
].
name
,
g_bootchartCmds
[
i
].
cmdExecutor
);
PLUGIN_LOGI
(
"BootchartInit %d"
,
g_bootchartCmds
[
i
].
index
);
}
return
0
;
...
...
services/plugin/bootchart/bootchart.h
浏览文件 @
ff5fc57f
...
...
@@ -15,12 +15,10 @@
#ifndef _PLUGIN_BOOTCHART_H
#define _PLUGIN_BOOTCHART_H
#include <errno.h>
#include <pthread.h>
#include <stdint.h>
#include <sys/time.h>
#define DEFAULT_BUFFER
1024
#define DEFAULT_BUFFER
2048
typedef
struct
{
int
start
;
int
stop
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录