mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-13 22:40:03 -04:00
feat(filesystem_v2): add error_code / throwing API for getattr
This commit is contained in:
parent
2ca18e776b
commit
dfcc2a20eb
@ -118,6 +118,12 @@ class filesystem_v2 {
|
||||
return impl_->getattr(entry, stbuf);
|
||||
}
|
||||
|
||||
file_stat getattr(inode_view entry, std::error_code& ec) const {
|
||||
return impl_->getattr(entry, ec);
|
||||
}
|
||||
|
||||
file_stat getattr(inode_view entry) const { return impl_->getattr(entry); }
|
||||
|
||||
int access(inode_view entry, int mode, uid_t uid, gid_t gid) const {
|
||||
return impl_->access(entry, mode, uid, gid);
|
||||
}
|
||||
@ -239,6 +245,8 @@ class filesystem_v2 {
|
||||
virtual std::optional<inode_view>
|
||||
find(int inode, const char* name) const = 0;
|
||||
virtual int getattr(inode_view entry, file_stat* stbuf) const = 0;
|
||||
virtual file_stat getattr(inode_view entry, std::error_code& ec) const = 0;
|
||||
virtual file_stat getattr(inode_view entry) const = 0;
|
||||
virtual int
|
||||
access(inode_view entry, int mode, uid_t uid, gid_t gid) const = 0;
|
||||
virtual std::optional<directory_view> opendir(inode_view entry) const = 0;
|
||||
|
@ -425,6 +425,8 @@ class filesystem_ final : public filesystem_v2::impl {
|
||||
std::optional<inode_view> find(int inode) const override;
|
||||
std::optional<inode_view> find(int inode, const char* name) const override;
|
||||
int getattr(inode_view entry, file_stat* stbuf) const override;
|
||||
file_stat getattr(inode_view entry, std::error_code& ec) const override;
|
||||
file_stat getattr(inode_view entry) const override;
|
||||
int access(inode_view entry, int mode, uid_t uid, gid_t gid) const override;
|
||||
std::optional<directory_view> opendir(inode_view entry) const override;
|
||||
std::optional<std::pair<inode_view, std::string>>
|
||||
@ -495,6 +497,8 @@ class filesystem_ final : public filesystem_v2::impl {
|
||||
PERFMON_CLS_TIMER_DECL(find_inode)
|
||||
PERFMON_CLS_TIMER_DECL(find_inode_name)
|
||||
PERFMON_CLS_TIMER_DECL(getattr)
|
||||
PERFMON_CLS_TIMER_DECL(getattr_ec)
|
||||
PERFMON_CLS_TIMER_DECL(getattr_throw)
|
||||
PERFMON_CLS_TIMER_DECL(access)
|
||||
PERFMON_CLS_TIMER_DECL(opendir)
|
||||
PERFMON_CLS_TIMER_DECL(readdir)
|
||||
@ -575,6 +579,8 @@ filesystem_<LoggerPolicy>::filesystem_(
|
||||
PERFMON_CLS_TIMER_INIT(find_inode)
|
||||
PERFMON_CLS_TIMER_INIT(find_inode_name)
|
||||
PERFMON_CLS_TIMER_INIT(getattr)
|
||||
PERFMON_CLS_TIMER_INIT(getattr_ec)
|
||||
PERFMON_CLS_TIMER_INIT(getattr_throw)
|
||||
PERFMON_CLS_TIMER_INIT(access)
|
||||
PERFMON_CLS_TIMER_INIT(opendir)
|
||||
PERFMON_CLS_TIMER_INIT(readdir)
|
||||
@ -1049,6 +1055,20 @@ int filesystem_<LoggerPolicy>::getattr(inode_view entry,
|
||||
return meta_.getattr(entry, stbuf);
|
||||
}
|
||||
|
||||
template <typename LoggerPolicy>
|
||||
file_stat filesystem_<LoggerPolicy>::getattr(inode_view entry,
|
||||
std::error_code& ec) const {
|
||||
PERFMON_CLS_SCOPED_SECTION(getattr_ec)
|
||||
return call_int_error<file_stat>(
|
||||
[&](auto& stbuf) { return getattr(entry, &stbuf); }, ec);
|
||||
}
|
||||
|
||||
template <typename LoggerPolicy>
|
||||
file_stat filesystem_<LoggerPolicy>::getattr(inode_view entry) const {
|
||||
PERFMON_CLS_SCOPED_SECTION(getattr_throw)
|
||||
return call_ec_throw([&](std::error_code& ec) { return getattr(entry, ec); });
|
||||
}
|
||||
|
||||
template <typename LoggerPolicy>
|
||||
int filesystem_<LoggerPolicy>::access(inode_view entry, int mode, uid_t uid,
|
||||
gid_t gid) const {
|
||||
|
Loading…
x
Reference in New Issue
Block a user