mirror of
https://github.com/genodelabs/genode.git
synced 2025-05-23 10:44:11 +00:00
tar_fs: Return correct size of stat'ed dirs
Genode's file system interface returns the number of directories multiplied by sizeof(Directory_entry) as size of a directory. The tar_fs server used to return zero. The fix counts the sub nodes of the given directory.
This commit is contained in:
parent
a96f912f73
commit
b43a5f1255
@ -379,20 +379,36 @@ namespace File_system {
|
||||
|
||||
Node *node = _handle_registry.lookup(node_handle);
|
||||
|
||||
status.size = node->record()->size();
|
||||
|
||||
/* convert TAR record modes to stat modes */
|
||||
switch (node->record()->type()) {
|
||||
case Record::TYPE_DIR: status.mode |= Status::MODE_DIRECTORY; break;
|
||||
case Record::TYPE_FILE: status.mode |= Status::MODE_FILE; break;
|
||||
case Record::TYPE_SYMLINK: status.mode |= Status::MODE_SYMLINK; break;
|
||||
case Record::TYPE_DIR:
|
||||
{
|
||||
status.size = node->record()->size();
|
||||
|
||||
/* count directory entries */
|
||||
Lookup_member_of_path lookup_criterion(node->record()->name(), ~0);
|
||||
_lookup(&lookup_criterion);
|
||||
|
||||
status.size = lookup_criterion.cnt*sizeof(Directory_entry);
|
||||
status.mode |= Status::MODE_DIRECTORY;
|
||||
break;
|
||||
}
|
||||
|
||||
case Record::TYPE_FILE:
|
||||
status.size = node->record()->size();
|
||||
status.mode |= Status::MODE_FILE;
|
||||
break;
|
||||
|
||||
case Record::TYPE_SYMLINK:
|
||||
status.size = node->record()->size();
|
||||
status.mode |= Status::MODE_SYMLINK;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (verbose)
|
||||
PWRN("unhandled record type %d", node->record()->type());
|
||||
}
|
||||
|
||||
PDBGV("name = %s", node->record()->name());
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user