Skip to content

Commit

Permalink
system/coredump: fix core file size mismatch
Browse files Browse the repository at this point in the history
Write exactly the same data size to core file.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
  • Loading branch information
XuNeo authored and xiaoxiang781216 committed Jan 23, 2025
1 parent 7552b8c commit 7ea9b90
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion system/coredump/coredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,13 @@ static void coredump_restore(FAR char *savepath, size_t maxfile)
lseek(blkfd, 0, SEEK_SET);
while (offset < info.size)
{
readsize = read(blkfd, swap, CONFIG_SYSTEM_COREDUMP_SWAPBUFFER_SIZE);
readsize = info.size - offset;
if (readsize > CONFIG_SYSTEM_COREDUMP_SWAPBUFFER_SIZE)
{
readsize = CONFIG_SYSTEM_COREDUMP_SWAPBUFFER_SIZE;
}

readsize = read(blkfd, swap, readsize);
if (readsize < 0)
{
printf("Read %s fail\n", CONFIG_SYSTEM_COREDUMP_DEVPATH);
Expand Down

0 comments on commit 7ea9b90

Please sign in to comment.