111 Signed-off-by:zl_zl <zhenglei28@huawei.com>

This commit is contained in:
z00500798 2024-05-17 16:21:35 +08:00
parent 05a8c441da
commit efc1a5276e
2 changed files with 80 additions and 23 deletions

View File

@ -369,20 +369,58 @@ int GetCurrentSlot(void)
return GetSlotInfoFromBootctrl(PARTITION_ACTIVE_SLOT_OFFSET, PARTITION_ACTIVE_SLOT_SIZE);
}
int MountOneItem(FstabItem *item)
static int DoMountOneItem(FstabItem *item)
{
if (item == NULL) {
return -1;
}
BEGET_LOGI("Mount device %s to %s", item->deviceName, item->mountPoint);
unsigned long mountFlags;
char fsSpecificData[FS_MANAGER_BUFFER_SIZE] = {0};
mountFlags = GetMountFlags(item->mountOptions, fsSpecificData, sizeof(fsSpecificData),
item->mountPoint);
if (!IsSupportedFilesystem(item->fsType)) {
BEGET_LOGW("Unsupported file system \" %s \"", item->fsType);
return 0;
int retryCount = 3;
int rc = 0;
while (retryCount-- > 0) {
rc = Mount(item->deviceName, item->mountPoint, item->fsType, mountFlags, fsSpecificData);
if (rc == 0) {
return rc;
}
BEGET_LOGE("Mount device %s to %s failed, err = %d, retry", item->deviceName, item->mountPoint, errno);
}
return rc;
}
static bool CheckIsErofs(const char *dev)
{
// todo
return false;
}
static int MountItemByFsType(FstabItem *item)
{
if (CheckIsErofs(item->deviceName)) {
if (strcmp(item->fsType, "erofs") == 0) {
return DoMountOneItem(item);
} else {
BEGET_LOGI("fsType not erofs system, skip erofs mount process");
return 0;
}
}
if (strcmp(item->fsType, "erofs") != 0) {
return DoMountOneItem(item);
}
BEGET_LOGI("fsType is erofs system, skip ext4 or hms mount process");
return 0;
}
int MountOneItem(FstabItem *item)
{
if (item == NULL) {
return -1;
}
if (FM_MANAGER_WAIT_ENABLED(item->fsManagerFlags)) {
WaitForFile(item->deviceName, WAIT_MAX_SECOND);
}
@ -408,15 +446,8 @@ int MountOneItem(FstabItem *item)
}
}
int retryCount = 3;
int rc = 0;
while (retryCount-- > 0) {
rc = Mount(item->deviceName, item->mountPoint, item->fsType, mountFlags, fsSpecificData);
if (rc == 0) {
break;
}
BEGET_LOGE("Mount device %s to %s failed, err = %d, retry", item->deviceName, item->mountPoint, errno);
}
rc = MountItemByFsType(item);
InitPostMount(item->mountPoint, rc, item->fsType);
if (rc != 0) {
if (FM_MANAGER_NOFAIL_ENABLED(item->fsManagerFlags)) {
@ -431,6 +462,22 @@ int MountOneItem(FstabItem *item)
return rc;
}
#ifdef SUPPORT_HVB
static bool NeedDmVerity(FstabItem *item)
{
if (CheckIsErofs(item->deviceName)) {
if (strcmp(item->fsType, "erofs") == 0) {
return true;
}
} else {
if (strcmp(item->fsType, "erofs") != 0) {
return true;
}
}
return false;
}
#endif
static void AdjustPartitionNameByPartitionSlot(FstabItem *item)
{
BEGET_CHECK_ONLY_RETURN(strstr(item->deviceName, "/system") != NULL ||
@ -460,13 +507,15 @@ static int CheckRequiredAndMount(FstabItem *item, bool required)
int bootSlots = GetBootSlots();
BEGET_INFO_CHECK(bootSlots <= 1, AdjustPartitionNameByPartitionSlot(item),
"boot slots is %d, now adjust partition name according to current slot", bootSlots);
#ifdef SUPPORT_HVB
rc = HvbDmVeritySetUp(item);
if (rc != 0) {
BEGET_LOGE("set dm_verity err, ret = 0x%x", rc);
return rc;
#ifdef SUPPORT_HVB
if (NeedDmVerity(item)) {
rc = HvbDmVeritySetUp(item);
if (rc != 0) {
BEGET_LOGE("set dm_verity err, ret = 0x%x", rc);
return rc;
}
}
#endif
#endif
rc = MountOneItem(item);
}
} else { // Mount partition during second startup.

View File

@ -41,7 +41,11 @@ static char **GetRequiredDevices(Fstab fstab, int *requiredNum)
if (FM_MANAGER_REQUIRED_ENABLED(item->fsManagerFlags)) {
num++;
}
item = item->next;
if (item->next != NULL && strcmp(item->deviceName, item->next->deviceName) == 0) {
item = item->next->next;
} else {
item = item->next;
}
}
if (num == 0) {
return NULL;
@ -58,7 +62,11 @@ static char **GetRequiredDevices(Fstab fstab, int *requiredNum)
"Failed strdup err=%d", errno);
i++;
}
item = item->next;
if (item->next != NULL && strcmp(item->deviceName, item->next->deviceName) == 0) {
item = item->next->next;
} else {
item = item->next;
}
}
*requiredNum = num;
return devices;