mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-12 20:28:20 +00:00
file system: enhanced file status info
This patch extends the 'File_system::Status', 'File_system::Directory_entry', and the related 'Vfs' types with the following additional information: - Distinction between continuous and transactional files (Node_type) (issue #3507) - Readable, writeable, and executable attributes (Node_rwx), replacing the former 'mode' bits (issue #3030) The types 'Node_rwx', 'Node_type' are defined twice, once for the VFS (vfs/types.h) and once for the 'File_system' session (file_system_session/file_system_session.h). Similarly, there is a direct correspondance between 'Vfs::Directory_service::Dirent' and 'File_system::Directory_entry'. This duplication of types follows the existing pattern of keeping the VFS and file-system session independent from each other.
This commit is contained in:
committed by
Christian Helmuth
parent
1297a8fb57
commit
5ab1505d43
@ -343,8 +343,8 @@ class Vfs::Dir_file_system : public File_system
|
||||
if (count < sizeof(Dirent))
|
||||
return READ_ERR_INVALID;
|
||||
|
||||
Dirent *dirent = (Dirent*)dst;
|
||||
*dirent = Dirent();
|
||||
Dirent &dirent = *(Dirent*)dst;
|
||||
dirent = Dirent { };
|
||||
|
||||
out_count = sizeof(Dirent);
|
||||
|
||||
@ -456,13 +456,14 @@ class Vfs::Dir_file_system : public File_system
|
||||
* current directory.
|
||||
*/
|
||||
if (strlen(path) == 0 || _top_dir(path)) {
|
||||
out.size = 0;
|
||||
out.mode = STAT_MODE_DIRECTORY | 0755;
|
||||
out.uid = 0;
|
||||
out.gid = 0;
|
||||
out.inode = 1;
|
||||
out.device = (Genode::addr_t)this;
|
||||
out.modification_time = { Vfs::Timestamp::INVALID };
|
||||
out = {
|
||||
.size = 0,
|
||||
.type = Node_type::DIRECTORY,
|
||||
.rwx = Node_rwx::rwx(),
|
||||
.inode = 1,
|
||||
.device = (Genode::addr_t)this,
|
||||
.modification_time = { Vfs::Timestamp::INVALID },
|
||||
};
|
||||
return STAT_OK;
|
||||
}
|
||||
|
||||
@ -903,16 +904,28 @@ class Vfs::Dir_file_system : public File_system
|
||||
return _complete_read_of_file_systems(dir_vfs_handle, dst, count, out_count);
|
||||
|
||||
if (_top_dir(dir_vfs_handle->path.base())) {
|
||||
Dirent *dirent = (Dirent*)dst;
|
||||
file_offset index = vfs_handle->seek() / sizeof(Dirent);
|
||||
|
||||
Dirent &dirent = *(Dirent*)dst;
|
||||
|
||||
file_offset const index = vfs_handle->seek() / sizeof(Dirent);
|
||||
|
||||
if (index == 0) {
|
||||
strncpy(dirent->name, _name.string(), sizeof(dirent->name));
|
||||
|
||||
dirent->type = DIRENT_TYPE_DIRECTORY;
|
||||
dirent->fileno = 1;
|
||||
dirent = {
|
||||
.fileno = 1,
|
||||
.type = Dirent_type::DIRECTORY,
|
||||
.rwx = Node_rwx::rwx(),
|
||||
.name = { _name.string() }
|
||||
};
|
||||
|
||||
} else {
|
||||
dirent->type = DIRENT_TYPE_END;
|
||||
|
||||
dirent = {
|
||||
.fileno = 0,
|
||||
.type = Dirent_type::END,
|
||||
.rwx = { },
|
||||
.name = { }
|
||||
};
|
||||
}
|
||||
|
||||
out_count = sizeof(Dirent);
|
||||
|
Reference in New Issue
Block a user