Skip to content

Commit 15efee2

Browse files
committed
fix: enhance fioGetStatFiller to calculate total size for main+subs in unused private fields
1 parent 98d0f68 commit 15efee2

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

iop/hdd/apa/src/hdd_fio.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -695,19 +695,27 @@ int hddLseek(iomanX_iop_file_t *f, int post, int whence)
695695

696696
static void fioGetStatFiller(apa_cache_t *clink, iox_stat_t *stat)
697697
{
698-
stat->mode = clink->header->type;
699-
stat->attr = clink->header->flags;
698+
stat->mode = clink->header->type;
699+
stat->attr = clink->header->flags;
700700
stat->hisize = 0;
701-
stat->size = clink->header->length;
701+
stat->size = clink->header->length;
702702
memcpy(&stat->ctime, &clink->header->created, sizeof(apa_ps2time_t));
703703
memcpy(&stat->atime, &clink->header->created, sizeof(apa_ps2time_t));
704704
memcpy(&stat->mtime, &clink->header->created, sizeof(apa_ps2time_t));
705+
stat->private_1 = 0;
706+
stat->private_2 = 0;
705707
if (clink->header->flags & APA_FLAG_SUB)
706708
stat->private_0 = clink->header->number;
707-
else
709+
else {
708710
stat->private_0 = clink->header->nsub;
709-
stat->private_1 = 0;
710-
stat->private_2 = 0;
711+
712+
u64 totalsize = (u64)clink->header->length;
713+
for (int i = 0; i < clink->header->nsub; i++) {
714+
totalsize += (u64)clink->header->subs[i].length;
715+
}
716+
stat->private_1 = (u32)(totalsize & 0xFFFFFFFF); // low size
717+
stat->private_2 = (u32)(totalsize >> 32); // high size
718+
}
711719
stat->private_3 = 0;
712720
stat->private_4 = 0;
713721
#ifndef APA_STAT_RETURN_PART_LBA

0 commit comments

Comments
 (0)