Skip to content

Commit 7ea9b90

Browse files
XuNeoxiaoxiang781216
authored andcommitted
system/coredump: fix core file size mismatch
Write exactly the same data size to core file. Signed-off-by: xuxingliang <[email protected]>
1 parent 7552b8c commit 7ea9b90

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

system/coredump/coredump.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,13 @@ static void coredump_restore(FAR char *savepath, size_t maxfile)
240240
lseek(blkfd, 0, SEEK_SET);
241241
while (offset < info.size)
242242
{
243-
readsize = read(blkfd, swap, CONFIG_SYSTEM_COREDUMP_SWAPBUFFER_SIZE);
243+
readsize = info.size - offset;
244+
if (readsize > CONFIG_SYSTEM_COREDUMP_SWAPBUFFER_SIZE)
245+
{
246+
readsize = CONFIG_SYSTEM_COREDUMP_SWAPBUFFER_SIZE;
247+
}
248+
249+
readsize = read(blkfd, swap, readsize);
244250
if (readsize < 0)
245251
{
246252
printf("Read %s fail\n", CONFIG_SYSTEM_COREDUMP_DEVPATH);

0 commit comments

Comments
 (0)