Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
c07ce374
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看板
未验证
提交
c07ce374
编写于
10月 25, 2022
作者:
O
openharmony_ci
提交者:
Gitee
10月 25, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1208 optimize A/B partition startup
Merge pull request !1208 from cheng_jinsong/slot
上级
da2e1fad
d823b120
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
14 addition
and
15 deletion
+14
-15
interfaces/innerkits/fs_manager/fstab_mount.c
interfaces/innerkits/fs_manager/fstab_mount.c
+14
-15
未找到文件。
interfaces/innerkits/fs_manager/fstab_mount.c
浏览文件 @
c07ce374
...
...
@@ -37,8 +37,8 @@ extern "C" {
#define FS_MANAGER_BUFFER_SIZE 512
#define BLOCK_SIZE_BUFFER (64)
#define RESIZE_BUFFER_SIZE 1024
const
off_t
MISC_PARTITION_ACTIVE_SLOT_OFFSET
=
4096
;
const
off_t
MISC_
PARTITION_ACTIVE_SLOT_SIZE
=
4
;
const
off_t
PARTITION_ACTIVE_SLOT_OFFSET
=
1024
;
const
off_t
PARTITION_ACTIVE_SLOT_SIZE
=
4
;
bool
IsSupportedFilesystem
(
const
char
*
fsType
)
{
...
...
@@ -313,21 +313,21 @@ static int GetSlotInfoFromCmdLine(const char *slotInfoName)
return
atoi
(
value
);
}
static
int
GetSlotInfoFrom
Misc
(
off_t
offset
,
off_t
size
)
static
int
GetSlotInfoFrom
Bootctrl
(
off_t
offset
,
off_t
size
)
{
char
misc
Dev
[
MAX_BUFFER_LEN
]
=
{
0
};
BEGET_ERROR_CHECK
(
GetBlockDevicePath
(
"/
misc"
,
misc
Dev
,
MAX_BUFFER_LEN
)
==
0
,
return
-
1
,
"Failed to get
misc
device"
);
char
*
realPath
=
GetRealPath
(
misc
Dev
);
BEGET_ERROR_CHECK
(
realPath
!=
NULL
,
return
-
1
,
"Failed to get
misc
device real path"
);
char
bootctrl
Dev
[
MAX_BUFFER_LEN
]
=
{
0
};
BEGET_ERROR_CHECK
(
GetBlockDevicePath
(
"/
bootctrl"
,
bootctrl
Dev
,
MAX_BUFFER_LEN
)
==
0
,
return
-
1
,
"Failed to get
bootctrl
device"
);
char
*
realPath
=
GetRealPath
(
bootctrl
Dev
);
BEGET_ERROR_CHECK
(
realPath
!=
NULL
,
return
-
1
,
"Failed to get
bootctrl
device real path"
);
int
fd
=
open
(
realPath
,
O_RDWR
|
O_CLOEXEC
,
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IROTH
);
free
(
realPath
);
BEGET_ERROR_CHECK
(
fd
>=
0
,
return
-
1
,
"Failed to open
misc
device, errno %d"
,
errno
);
BEGET_ERROR_CHECK
(
fd
>=
0
,
return
-
1
,
"Failed to open
bootctrl
device, errno %d"
,
errno
);
BEGET_ERROR_CHECK
(
lseek
(
fd
,
offset
,
SEEK_SET
)
>=
0
,
close
(
fd
);
return
-
1
,
"Failed to lseek
misc
device fd, errno %d"
,
errno
);
"Failed to lseek
bootctrl
device fd, errno %d"
,
errno
);
int
slotInfo
=
0
;
BEGET_INFO_CHECK
(
read
(
fd
,
&
slotInfo
,
size
)
==
size
,
close
(
fd
);
return
-
1
,
"Failed to read current slot from
misc
, errno %d"
,
errno
);
"Failed to read current slot from
bootctrl
, errno %d"
,
errno
);
close
(
fd
);
return
slotInfo
;
}
...
...
@@ -350,10 +350,10 @@ int GetCurrentSlot(void)
// get current slot from cmdline
currentSlot
=
GetSlotInfoFromCmdLine
(
"currentslot"
);
BEGET_CHECK_RETURN_VALUE
(
currentSlot
<=
0
,
currentSlot
);
BEGET_LOGI
(
"No valid slot value found from cmdline, try to get it from
misc
"
);
BEGET_LOGI
(
"No valid slot value found from cmdline, try to get it from
bootctrl
"
);
// get current slot from
misc
return
GetSlotInfoFrom
Misc
(
MISC_PARTITION_ACTIVE_SLOT_OFFSET
,
MISC_
PARTITION_ACTIVE_SLOT_SIZE
);
// get current slot from
bootctrl
return
GetSlotInfoFrom
Bootctrl
(
PARTITION_ACTIVE_SLOT_OFFSET
,
PARTITION_ACTIVE_SLOT_SIZE
);
}
int
MountOneItem
(
FstabItem
*
item
)
...
...
@@ -416,7 +416,6 @@ static void AdjustPartitionNameByPartitionSlot(FstabItem *item)
char
buffer
[
MAX_BUFFER_LEN
]
=
{
0
};
int
slot
=
GetCurrentSlot
();
BEGET_ERROR_CHECK
(
slot
>
0
&&
slot
<=
MAX_SLOT
,
slot
=
1
,
"slot value %d is invalid, set default value"
,
slot
);
BEGET_INFO_CHECK
(
slot
>
1
,
return
,
"default partition doesn't need to add suffix"
);
BEGET_ERROR_CHECK
(
sprintf_s
(
buffer
,
sizeof
(
buffer
),
"%s_%c"
,
item
->
deviceName
,
'a'
+
slot
-
1
)
>
0
,
return
,
"Failed to format partition name suffix, use default partition name"
);
free
(
item
->
deviceName
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录