Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
a08f1db7
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
1 年多 前同步成功
通知
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看板
提交
a08f1db7
编写于
1月 21, 2022
作者:
熊
熊磊
提交者:
Gitee
1月 21, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of gitee.com:openharmony/startup_init_lite into init119_3
Signed-off-by:
N
xionglei
<
xionglei6@huawei.com
>
上级
edac3c57
89111dec
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
31 addition
and
12 deletion
+31
-12
interfaces/innerkits/fs_manager/fstab_mount.c
interfaces/innerkits/fs_manager/fstab_mount.c
+1
-1
services/include/init_utils.h
services/include/init_utils.h
+3
-2
services/init/init_common_cmds.c
services/init/init_common_cmds.c
+19
-1
services/init/init_common_service.c
services/init/init_common_service.c
+1
-1
services/utils/init_utils.c
services/utils/init_utils.c
+7
-7
未找到文件。
interfaces/innerkits/fs_manager/fstab_mount.c
浏览文件 @
a08f1db7
...
...
@@ -297,7 +297,7 @@ int MountOneItem(FstabItem *item)
return
-
1
;
}
if
(
FM_MANAGER_WAIT_ENABLED
(
item
->
fsManagerFlags
))
{
WaitForFile
(
item
->
deviceName
,
WAIT_MAX_
COUNT
);
WaitForFile
(
item
->
deviceName
,
WAIT_MAX_
SECOND
);
}
if
(
strcmp
(
item
->
fsType
,
"f2fs"
)
==
0
&&
strcmp
(
item
->
mountPoint
,
"/data"
)
==
0
)
{
...
...
services/include/init_utils.h
浏览文件 @
a08f1db7
...
...
@@ -33,16 +33,17 @@ typedef struct {
#define BINARY_BASE 2
#define OCTAL_BASE 8
#define DECIMAL_BASE 10
#define WAIT_MAX_
COUNT 10
#define WAIT_MAX_
SECOND 5
#define MAX_BUFFER_LEN 256
#define ARRAY_LENGTH(array) (sizeof((array)) / sizeof((array)[0]))
uid_t
DecodeUid
(
const
char
*
name
);
char
*
ReadFileToBuf
(
const
char
*
configFile
);
int
GetProcCmdlineValue
(
const
char
*
name
,
const
char
*
buffer
,
char
*
value
,
int
length
);
char
*
ReadFileData
(
const
char
*
fileName
);
int
SplitString
(
char
*
srcPtr
,
const
char
*
del
,
char
**
dstPtr
,
int
maxNum
);
void
WaitForFile
(
const
char
*
source
,
unsigned
int
max
Count
);
void
WaitForFile
(
const
char
*
source
,
unsigned
int
max
Second
);
size_t
WriteAll
(
int
fd
,
const
char
*
buffer
,
size_t
size
);
char
*
GetRealPath
(
const
char
*
source
);
int
StringToInt
(
const
char
*
str
,
int
defaultValue
);
...
...
services/init/init_common_cmds.c
浏览文件 @
a08f1db7
...
...
@@ -177,6 +177,23 @@ static void DoSleep(const struct CmdArgs *ctx)
sleep
((
unsigned
int
)
sleepTime
);
}
static
void
DoWait
(
const
struct
CmdArgs
*
ctx
)
{
const
int
filePos
=
0
;
const
int
timePos
=
1
;
unsigned
long
waitSecond
=
WAIT_MAX_SECOND
;
if
(
ctx
->
argc
==
timePos
+
1
)
{
errno
=
0
;
waitSecond
=
strtoul
(
ctx
->
argv
[
timePos
],
NULL
,
DECIMAL_BASE
);
INIT_ERROR_CHECK
(
errno
==
0
,
return
,
"cannot covert sleep time in command
\"
wait
\"
"
);
}
INIT_LOGI
(
"Waiting %s %lu second(s)"
,
ctx
->
argv
[
filePos
],
waitSecond
);
WaitForFile
(
ctx
->
argv
[
filePos
],
waitSecond
);
}
static
void
DoStart
(
const
struct
CmdArgs
*
ctx
)
{
INIT_LOGV
(
"DoStart %s"
,
ctx
->
argv
[
0
]);
...
...
@@ -365,7 +382,7 @@ static int GetMountFlag(unsigned long *mountflag, const char *targetStr, const c
}
}
if
(
strncmp
(
targetStr
,
"wait"
,
strlen
(
"wait"
))
==
0
)
{
WaitForFile
(
source
,
WAIT_MAX_
COUNT
);
WaitForFile
(
source
,
WAIT_MAX_
SECOND
);
return
1
;
}
return
0
;
...
...
@@ -504,6 +521,7 @@ static const struct CmdTable g_cmdTable[] = {
{
"reboot "
,
1
,
1
,
DoRebootCmd
},
{
"setrlimit "
,
3
,
3
,
DoSetrlimit
},
{
"sleep "
,
1
,
1
,
DoSleep
},
{
"wait "
,
1
,
2
,
DoWait
},
{
"hostname "
,
1
,
1
,
DoSetHostname
},
{
"domainname "
,
1
,
1
,
DoSetDomainname
}
};
...
...
services/init/init_common_service.c
浏览文件 @
a08f1db7
...
...
@@ -151,7 +151,7 @@ static void OpenConsole(void)
{
const
int
stdError
=
2
;
setsid
();
WaitForFile
(
"/dev/console"
,
WAIT_MAX_
COUNT
);
WaitForFile
(
"/dev/console"
,
WAIT_MAX_
SECOND
);
int
fd
=
open
(
"/dev/console"
,
O_RDWR
);
if
(
fd
>=
0
)
{
ioctl
(
fd
,
TIOCSCTTY
,
0
);
...
...
services/utils/init_utils.c
浏览文件 @
a08f1db7
...
...
@@ -259,19 +259,19 @@ char **SplitStringExt(char *buffer, const char *del, int *returnCount, int maxIt
return
items
;
}
void
WaitForFile
(
const
char
*
source
,
unsigned
int
max
Count
)
void
WaitForFile
(
const
char
*
source
,
unsigned
int
max
Second
)
{
unsigned
int
maxCountTmp
=
maxCount
;
INIT_ERROR_CHECK
(
maxCountTmp
<=
WAIT_MAX_COUNT
,
maxCountTmp
=
WAIT_MAX_COUNT
,
"WaitForFile max time is 5s"
);
INIT_ERROR_CHECK
(
maxSecond
<=
WAIT_MAX_SECOND
,
maxSecond
=
WAIT_MAX_SECOND
,
"WaitForFile max time is 5s"
);
struct
stat
sourceInfo
=
{};
const
unsigned
int
waitTime
=
500000
;
unsigned
int
waitTime
=
500000
;
/* 500ms interval, check maxSecond*2 times total */
unsigned
int
maxCount
=
maxSecond
*
2
;
unsigned
int
count
=
0
;
do
{
usleep
(
waitTime
);
count
++
;
}
while
((
stat
(
source
,
&
sourceInfo
)
<
0
)
&&
(
errno
==
ENOENT
)
&&
(
count
<
maxCountTmp
));
float
secTime
=
ConvertMicrosecondToSecond
(
waitTime
);
INIT_CHECK_ONLY_ELOG
(
count
!=
maxCountTmp
,
"wait for file:%s failed after %f."
,
source
,
maxCountTmp
*
secTime
);
}
while
((
stat
(
source
,
&
sourceInfo
)
<
0
)
&&
(
errno
==
ENOENT
)
&&
(
count
<
maxCount
));
INIT_CHECK_ONLY_ELOG
(
count
!=
maxCount
,
"wait for file:%s failed after %d second."
,
source
,
maxSecond
);
return
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录