I am trying to port an embedded OS to a new platform and I am facing some problems with the filesystem component. I stepped in the code to finally localize the problem: The function call relevant to my case is
// int64_t vnid = 1;
// int32_t vid = 0;
...
vnode = queue_lookup (& vnode_manager . vnode_list,
vnode_id_inspector, vnid, vid);
And here is the queue_lookup declaration:
void * queue_lookup (queue_t * queue, queue_inspector_t inspector, ...)
{
bool result;
va_list list, list_copy;
queue_link_t * item = NULL;
va_start (list, inspector);
if (queue -> status != 0)
{
for (item = queue -> head; item != NULL; item = item -> next)
{
result = false;
va_copy (list_copy, list);
result = inspector (item, list_copy);
va_end (list_copy);
if (result) break;
}
}
va_end (list);
return item;
}
and finally, here is the vnode_id_inspector declaration:
bool vnode_id_inspector (void * node, va_list list)
{
vnode_t vnode = node;
int64_t vnid = va_arg (list, int64_t);
int32_t vid = va_arg (list, int32_t);
watch (bool)
{
ensure (vnode != NULL, false);
return vnode -> id == vnid && vnode -> volume -> id == vid;
}
}
Now the problem is when I call queue_lookup with vnid=1 and vid=0, I get vnid=1 and vid=1145248 in the vnode_id_inspector !
How can I fix this issue with as minimum code change as possible ?
Regards,
Edit: add some debug info
(gdb) p vnode_manager . vnode_list
$44 = {lock = 1, head = 0x167770, tail = 0x167770, status = 1}
(gdb) p vnode_manager . vnode_list ->head
$45 = (queue_link_t *) 0x167770
(gdb) p *(vnode_t)vnode_manager . vnode_list ->head
$46 = {link = {next = 0x0}, id = 1, volume = 0x166370, destroy = false,
usage_counter = 1, data = 0x166430}
(gdb) p *(volume_t)((vnode_t)vnode_manager . vnode_list ->head)->volume
$47 = {link = {next = 0x0}, id = 0, root_vnid = 1, lock = 0, host_volume = 0x0,
host_vnid = -1, cmd = 0x13a768 <rootfs_cmd>, data = 0x1663d0}
I solved this issue, there was a problem in the stack alignment. I fixed it by making some adjustment in the cpu_context_switch.s to align the stack to 8bytes instead of 4bytes .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.