mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-10 04:50:31 -04:00
metadata_v2: getattr, part 2
This commit is contained in:
parent
d052217f59
commit
a7f9518278
@ -55,7 +55,8 @@ class entry_view
|
|||||||
|
|
||||||
std::string_view name() const;
|
std::string_view name() const;
|
||||||
uint16_t mode() const;
|
uint16_t mode() const;
|
||||||
// size_t size() const;
|
uint16_t getuid() const;
|
||||||
|
uint16_t getgid() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
::apache::thrift::frozen::MappedFrozen<thrift::metadata::metadata> const*
|
::apache::thrift::frozen::MappedFrozen<thrift::metadata::metadata> const*
|
||||||
|
@ -45,6 +45,10 @@ std::string_view entry_view::name() const {
|
|||||||
|
|
||||||
uint16_t entry_view::mode() const { return meta_->modes()[mode_index()]; }
|
uint16_t entry_view::mode() const { return meta_->modes()[mode_index()]; }
|
||||||
|
|
||||||
|
uint16_t entry_view::getuid() const { return meta_->uids()[owner_index()]; }
|
||||||
|
|
||||||
|
uint16_t entry_view::getgid() const { return meta_->gids()[group_index()]; }
|
||||||
|
|
||||||
boost::integer_range<uint32_t> directory_view::entry_range() const {
|
boost::integer_range<uint32_t> directory_view::entry_range() const {
|
||||||
auto first = first_entry();
|
auto first = first_entry();
|
||||||
return boost::irange(first, first + entry_count());
|
return boost::irange(first, first + entry_count());
|
||||||
@ -332,12 +336,11 @@ std::optional<entry_view> metadata_v2_<LoggerPolicy>::find(int inode) const {
|
|||||||
|
|
||||||
template <typename LoggerPolicy>
|
template <typename LoggerPolicy>
|
||||||
std::optional<entry_view>
|
std::optional<entry_view>
|
||||||
metadata_v2_<LoggerPolicy>::find(int inode,
|
metadata_v2_<LoggerPolicy>::find(int inode, const char* name) const {
|
||||||
const char* name) const { // TODO: string_view?
|
|
||||||
auto entry = get_entry(inode);
|
auto entry = get_entry(inode);
|
||||||
|
|
||||||
if (entry) {
|
if (entry) {
|
||||||
entry = find(getdir(*entry), std::string_view(name)); // TODO
|
entry = find(getdir(*entry), std::string_view(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
@ -349,16 +352,17 @@ int metadata_v2_<LoggerPolicy>::getattr(entry_view entry,
|
|||||||
::memset(stbuf, 0, sizeof(*stbuf));
|
::memset(stbuf, 0, sizeof(*stbuf));
|
||||||
|
|
||||||
auto mode = entry.mode();
|
auto mode = entry.mode();
|
||||||
|
auto timebase = meta_.timestamp_base();
|
||||||
|
|
||||||
stbuf->st_mode = mode & READ_ONLY_MASK;
|
stbuf->st_mode = mode & READ_ONLY_MASK;
|
||||||
stbuf->st_size = file_size(entry, mode);
|
stbuf->st_size = file_size(entry, mode);
|
||||||
stbuf->st_ino = entry.inode() + inode_offset_;
|
stbuf->st_ino = entry.inode() + inode_offset_;
|
||||||
stbuf->st_blocks = (stbuf->st_size + 511) / 512;
|
stbuf->st_blocks = (stbuf->st_size + 511) / 512;
|
||||||
// stbuf->st_uid = getuid(de); // TODO
|
stbuf->st_uid = entry.getuid();
|
||||||
// stbuf->st_gid = getgid(de);
|
stbuf->st_gid = entry.getgid();
|
||||||
// stbuf->st_atime = real_de->atime;
|
stbuf->st_atime = timebase + entry.atime_offset();
|
||||||
// stbuf->st_mtime = real_de->mtime;
|
stbuf->st_mtime = timebase + entry.mtime_offset();
|
||||||
// stbuf->st_ctime = real_de->ctime;
|
stbuf->st_ctime = timebase + entry.ctime_offset();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user