vfs: default constructor for Dirent and Stat

Fixes #1743
This commit is contained in:
Christian Helmuth
2016-06-22 15:38:42 +02:00
parent 0a01edded2
commit d8c34237bf
9 changed files with 64 additions and 24 deletions

View File

@ -86,12 +86,12 @@ struct Vfs::Directory_service
struct Stat
{
file_size size;
unsigned mode;
unsigned uid;
unsigned gid;
unsigned long inode;
unsigned long device;
file_size size = 0;
unsigned mode = 0;
unsigned uid = 0;
unsigned gid = 0;
unsigned long inode = 0;
unsigned long device = 0;
};
enum Stat_result { STAT_ERR_NO_ENTRY = NUM_GENERAL_ERRORS,
@ -120,9 +120,9 @@ struct Vfs::Directory_service
struct Dirent
{
unsigned long fileno;
Dirent_type type;
char name[DIRENT_MAX_NAME_LEN];
unsigned long fileno = 0;
Dirent_type type = DIRENT_TYPE_END;
char name[DIRENT_MAX_NAME_LEN] = { 0 };
};
virtual Dirent_result dirent(char const *path, file_offset index, Dirent &) = 0;

View File

@ -255,7 +255,7 @@ class Vfs::Fs_file_system : public File_system
catch (::File_system::Lookup_failed) { return STAT_ERR_NO_ENTRY; }
catch (::File_system::Out_of_metadata) { return STAT_ERR_NO_PERM; }
memset(&out, 0, sizeof(out));
out = Stat();
out.size = status.size;
out.mode = STAT_MODE_FILE | 0777;

View File

@ -70,7 +70,7 @@ class Vfs::Single_file_system : public File_system
Stat_result stat(char const *path, Stat &out) override
{
out = { 0, 0, 0, 0, 0, 0 };
out = Stat();
out.device = (Genode::addr_t)this;
if (_root(path)) {

View File

@ -75,7 +75,7 @@ class Vfs::Symlink_file_system : public File_system
Stat_result stat(char const *path, Stat &out) override
{
out = { 0, 0, 0, 0, 0, 0 };
out = Stat();
out.device = (Genode::addr_t)this;
if (_root(path)) {

View File

@ -425,6 +425,8 @@ class Vfs::Tar_file_system : public File_system
if (verbose)
PDBG("path = %s", path);
out = Stat();
Node const *node = dereference(path);
if (!node)
return STAT_ERR_NO_ENTRY;
@ -433,7 +435,6 @@ class Vfs::Tar_file_system : public File_system
if (verbose)
PDBG("found a virtual directoty node");
memset(&out, 0, sizeof(out));
out.mode = STAT_MODE_DIRECTORY;
return STAT_OK;
}
@ -452,7 +453,6 @@ class Vfs::Tar_file_system : public File_system
PDBG("unhandled record type %d", record->type());
}
memset(&out, 0, sizeof(out));
out.mode = mode;
out.size = record->size();
out.uid = record->uid();