Misc cleanup

This commit is contained in:
Antonio SJ Musumeci 2026-04-13 18:55:56 -05:00
parent ff48ff6047
commit fa06b4b8bd
74 changed files with 809 additions and 619 deletions

View file

@ -73,7 +73,8 @@ _set_stat_if_leads_to_reg(const fs::path &path_,
static
int
_getattr_fake_root(struct stat *st_)
_getattr_fake_root(struct stat *st_,
fuse_timeouts_t *timeout_)
{
st_->st_dev = 0;
st_->st_ino = 0;
@ -89,12 +90,16 @@ _getattr_fake_root(struct stat *st_)
st_->st_mtime = 0;
st_->st_ctime = 0;
timeout_->entry = 0;
timeout_->attr = 0;
return 0;
}
static
int
_getattr_controlfile(struct stat *st_)
_getattr_controlfile(struct stat *st_,
fuse_timeouts_t *timeout_)
{
static const uid_t uid = ::getuid();
static const gid_t gid = ::getgid();
@ -114,13 +119,16 @@ _getattr_controlfile(struct stat *st_)
st_->st_mtime = now;
st_->st_ctime = now;
timeout_->entry = cfg.cache_entry;
timeout_->attr = cfg.cache_attr;
return 0;
}
static
int
_getattr(const Policy::Search &searchFunc_,
const Branches &branches_,
const Branches::Ptr branches_,
const fs::path &fusepath_,
struct stat *st_,
const bool symlinkify_,
@ -134,6 +142,8 @@ _getattr(const Policy::Search &searchFunc_,
rv = searchFunc_(branches_,fusepath_,branches);
if(rv < 0)
return rv;
if(branches.empty())
return -ENOENT;
fullpath = branches[0]->path / fusepath_;
@ -144,12 +154,12 @@ _getattr(const Policy::Search &searchFunc_,
break;
case FollowSymlinks::ENUM::DIRECTORY:
rv = fs::lstat(fullpath,st_);
if(S_ISLNK(st_->st_mode))
if((rv >= 0) && S_ISLNK(st_->st_mode))
::_set_stat_if_leads_to_dir(fullpath,st_);
break;
case FollowSymlinks::ENUM::REGULAR:
rv = fs::lstat(fullpath,st_);
if(S_ISLNK(st_->st_mode))
if((rv >= 0) && S_ISLNK(st_->st_mode))
::_set_stat_if_leads_to_reg(fullpath,st_);
break;
case FollowSymlinks::ENUM::ALL:
@ -187,7 +197,7 @@ _getattr(const fs::path &fusepath_,
cfg.symlinkify_timeout,
cfg.follow_symlinks);
if((rv < 0) && Config::is_rootdir(fusepath_))
return ::_getattr_fake_root(st_);
return ::_getattr_fake_root(st_,timeout_);
timeout_->entry = ((rv >= 0) ?
cfg.cache_entry :
@ -223,7 +233,7 @@ FUSE::getattr(const fs::path &fusepath_,
fuse_timeouts_t *timeout_)
{
if(Config::is_ctrl_file(fusepath_))
return ::_getattr_controlfile(st_);
return ::_getattr_controlfile(st_,timeout_);
return ::_getattr(fusepath_,st_,timeout_);
}