Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage: Mount unknown partition types as raw #526

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 23 additions & 25 deletions storage/gr716-flash/flashsrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,30 +502,6 @@ static int flashsrv_mountPart(flashsrv_partition_t *part)
(void)snprintf(path, sizeof(path), "flash%u.%s", part->fID, part->pHeader->name);

switch (part->pHeader->type) {
/* Raw partitions locate within single flash chip are handled by one thread */
case ptable_raw:
part->fsCtx = NULL;
part->oid.port = flashsrv_common.flash_memories[part->fID].rawPort;

res = create_dev(&part->oid, path);
if (res < 0) {
LOG_ERROR("create %s - err: %d", path, res);
return res;
}

if (!flashsrv_common.flash_memories[part->fID].rawActive) {
flashsrv_common.flash_memories[part->fID].rawActive = 1;

mem = malloc(THREAD_STACKSZ);
if (mem == NULL) {
LOG_ERROR("cannot alloc memory.");
return -ENOMEM;
}

beginthread(flashsrv_rawThread, GR716_FLASH_PRIO, mem, THREAD_STACKSZ, (void *)&flashsrv_common.flash_memories[part->fID]);
}
break;

/* Each meterfs partition is handled by separate thread */
case ptable_meterfs:
res = flashsrv_initMeterfs(part);
Expand All @@ -551,8 +527,30 @@ static int flashsrv_mountPart(flashsrv_partition_t *part)
beginthread(flashsrv_meterfsThread, GR716_FLASH_PRIO, mem, METERFS_STACKSZ, (void *)part);
break;

/* Raw partitions located within single flash chip are handled by one thread */
case ptable_raw:
/* Mount unknown partitions as raw for forward compatibility and allow FUSE-like usage */
default:
res = -EINVAL;
part->fsCtx = NULL;
part->oid.port = flashsrv_common.flash_memories[part->fID].rawPort;

res = create_dev(&part->oid, path);
if (res < 0) {
LOG_ERROR("create %s - err: %d", path, res);
return res;
}

if (!flashsrv_common.flash_memories[part->fID].rawActive) {
flashsrv_common.flash_memories[part->fID].rawActive = 1;

mem = malloc(THREAD_STACKSZ);
if (mem == NULL) {
LOG_ERROR("cannot alloc memory.");
return -ENOMEM;
}

beginthread(flashsrv_rawThread, GR716_FLASH_PRIO, mem, THREAD_STACKSZ, (void *)&flashsrv_common.flash_memories[part->fID]);
}
break;
}

Expand Down
50 changes: 24 additions & 26 deletions storage/imxrt-flash/flashsrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,31 +761,6 @@ static int flashsrv_mountPart(flashsrv_partition_t *part)
snprintf(path, sizeof(path), "/dev/flash%u.%s", part->fID, part->pHeader->name);

switch (part->pHeader->type) {
/* Raw partitions locate within single flash chip are handled by one thread */
case ptable_raw:
part->fsCtx = NULL;
part->oid.port = flashsrv_common.flash_memories[part->fID].rawPort;

res = create_dev(&part->oid, path);
if (res < 0) {
LOG_ERROR("imxrt-flashsrv: create %s - err: %d", path, res);
return res;
}

if (!flashsrv_common.flash_memories[part->fID].rawActive) {
flashsrv_common.flash_memories[part->fID].rawActive = true;

mem = malloc(THREAD_STACKSZ);
if (mem == NULL) {
LOG_ERROR("imxrt-flashsrv: cannot alloc memory.");
return -ENOMEM;
}

beginthread(flashsrv_rawThread, IMXRT_FLASH_PRIO, mem, THREAD_STACKSZ, (void *)&flashsrv_common.flash_memories[part->fID]);
}
part->pStatus = flashsrv_memory_active;
break;

/* Each meterfs partition is handled by separate thread */
case ptable_meterfs:
res = flashsrv_initMeterfs(part);
Expand Down Expand Up @@ -815,8 +790,31 @@ static int flashsrv_mountPart(flashsrv_partition_t *part)
part->pStatus = flashsrv_memory_active;
break;

/* Raw partitions located within single flash chip are handled by one thread */
case ptable_raw:
/* Mount unknown partitions as raw for forward compatibility and allow FUSE-like usage */
default:
res = -EINVAL;
part->fsCtx = NULL;
part->oid.port = flashsrv_common.flash_memories[part->fID].rawPort;

res = create_dev(&part->oid, path);
if (res < 0) {
LOG_ERROR("imxrt-flashsrv: create %s - err: %d", path, res);
return res;
}

if (!flashsrv_common.flash_memories[part->fID].rawActive) {
flashsrv_common.flash_memories[part->fID].rawActive = true;

mem = malloc(THREAD_STACKSZ);
if (mem == NULL) {
LOG_ERROR("imxrt-flashsrv: cannot alloc memory.");
return -ENOMEM;
}

beginthread(flashsrv_rawThread, IMXRT_FLASH_PRIO, mem, THREAD_STACKSZ, (void *)&flashsrv_common.flash_memories[part->fID]);
}
part->pStatus = flashsrv_memory_active;
break;
}

Expand Down
Loading