mirror of
https://github.com/genodelabs/genode.git
synced 2025-05-23 18:54:15 +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
@ -235,7 +235,7 @@ namespace File_system {
|
|||||||
Symlink_handle symlink(Dir_handle dir_handle, Name const &name, bool create)
|
Symlink_handle symlink(Dir_handle dir_handle, Name const &name, bool create)
|
||||||
{
|
{
|
||||||
PDBGV("_root = %s, dir_name = %s, name = %s, create = %d",
|
PDBGV("_root = %s, dir_name = %s, name = %s, create = %d",
|
||||||
_root.record()->name(),
|
_root.record()->name(),
|
||||||
_handle_registry.lookup(dir_handle)->record()->name(),
|
_handle_registry.lookup(dir_handle)->record()->name(),
|
||||||
name.string(),
|
name.string(),
|
||||||
create);
|
create);
|
||||||
@ -276,7 +276,7 @@ namespace File_system {
|
|||||||
Dir_handle dir(Path const &path, bool create)
|
Dir_handle dir(Path const &path, bool create)
|
||||||
{
|
{
|
||||||
PDBGV("_root = %s, path = %s, create = %d",
|
PDBGV("_root = %s, path = %s, create = %d",
|
||||||
_root.record()->name(), path.string(), create);
|
_root.record()->name(), path.string(), create);
|
||||||
|
|
||||||
_assert_valid_path(path.string());
|
_assert_valid_path(path.string());
|
||||||
|
|
||||||
@ -379,20 +379,36 @@ namespace File_system {
|
|||||||
|
|
||||||
Node *node = _handle_registry.lookup(node_handle);
|
Node *node = _handle_registry.lookup(node_handle);
|
||||||
|
|
||||||
status.size = node->record()->size();
|
|
||||||
|
|
||||||
/* convert TAR record modes to stat modes */
|
/* convert TAR record modes to stat modes */
|
||||||
switch (node->record()->type()) {
|
switch (node->record()->type()) {
|
||||||
case Record::TYPE_DIR: status.mode |= Status::MODE_DIRECTORY; break;
|
case Record::TYPE_DIR:
|
||||||
case Record::TYPE_FILE: status.mode |= Status::MODE_FILE; break;
|
{
|
||||||
case Record::TYPE_SYMLINK: status.mode |= Status::MODE_SYMLINK; break;
|
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:
|
default:
|
||||||
if (verbose)
|
if (verbose)
|
||||||
PWRN("unhandled record type %d", node->record()->type());
|
PWRN("unhandled record type %d", node->record()->type());
|
||||||
}
|
}
|
||||||
|
|
||||||
PDBGV("name = %s", node->record()->name());
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ namespace File_system {
|
|||||||
|
|
||||||
/* record type values */
|
/* record type values */
|
||||||
enum { TYPE_FILE = 0, TYPE_HARDLINK = 1,
|
enum { TYPE_FILE = 0, TYPE_HARDLINK = 1,
|
||||||
TYPE_SYMLINK = 2, TYPE_DIR = 5 };
|
TYPE_SYMLINK = 2, TYPE_DIR = 5 };
|
||||||
|
|
||||||
size_t size() const { return _read(_size); }
|
size_t size() const { return _read(_size); }
|
||||||
unsigned uid() const { return _read(_uid); }
|
unsigned uid() const { return _read(_uid); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user