diff options
-rw-r--r-- | netfs/lib/entCache.cpp | 42 | ||||
-rw-r--r-- | netfs/lib/entCache.impl.h | 42 |
2 files changed, 42 insertions, 42 deletions
diff --git a/netfs/lib/entCache.cpp b/netfs/lib/entCache.cpp index e1a20a5..6f6d6eb 100644 --- a/netfs/lib/entCache.cpp +++ b/netfs/lib/entCache.cpp @@ -3,3 +3,45 @@ template class EntCache<User>; template class EntCache<Group>; + +const int BUFLEN = 8196; + +void +UserEntCache::fillCache() const noexcept +{ + Lock(lock); + setpwent(); + idcache->clear(); + std::array<char, BUFLEN> buf {}; + struct passwd pwbuf { + }, *pwp; + while (getpwent_r(&pwbuf, buf.data(), buf.size(), &pwp) == 0) { + idcache->insert(std::make_shared<User>(pwp->pw_uid, pwp->pw_name, pwp->pw_gid)); + } + endpwent(); + time(&fillTime); +} + +GroupEntCache::GroupEntCache(EntryResolverPtr<User> u) : users(std::move(u)) { } + +void +GroupEntCache::fillCache() const noexcept +{ + Lock(lock); + setgrent(); + std::array<char, BUFLEN> buf {}; + idcache->clear(); + struct group grpbuf { + }, *grp; + while (getgrent_r(&grpbuf, buf.data(), buf.size(), &grp) == 0) { + auto g = std::make_shared<Group>(grp->gr_gid, grp->gr_name); + for (auto member = grp->gr_mem; *member; member++) { + if (auto ent = users->getEntry(*member)) { + g->members.insert(ent->id); + } + } + idcache->insert(std::move(g)); + } + endgrent(); + time(&fillTime); +} diff --git a/netfs/lib/entCache.impl.h b/netfs/lib/entCache.impl.h index 1d7bbc7..5e6289e 100644 --- a/netfs/lib/entCache.impl.h +++ b/netfs/lib/entCache.impl.h @@ -51,46 +51,4 @@ EntCache<entry_t>::getEntryNoFill(const key_t & key) const noexcept return nullptr; } -const int BUFLEN = 8196; - -void -UserEntCache::fillCache() const noexcept -{ - Lock(lock); - setpwent(); - idcache->clear(); - std::array<char, BUFLEN> buf {}; - struct passwd pwbuf { - }, *pwp; - while (getpwent_r(&pwbuf, buf.data(), buf.size(), &pwp) == 0) { - idcache->insert(std::make_shared<User>(pwp->pw_uid, pwp->pw_name, pwp->pw_gid)); - } - endpwent(); - time(&fillTime); -} - -GroupEntCache::GroupEntCache(EntryResolverPtr<User> u) : users(std::move(u)) { } - -void -GroupEntCache::fillCache() const noexcept -{ - Lock(lock); - setgrent(); - std::array<char, BUFLEN> buf {}; - idcache->clear(); - struct group grpbuf { - }, *grp; - while (getgrent_r(&grpbuf, buf.data(), buf.size(), &grp) == 0) { - auto g = std::make_shared<Group>(grp->gr_gid, grp->gr_name); - for (auto member = grp->gr_mem; *member; member++) { - if (auto ent = users->getEntry(*member)) { - g->members.insert(ent->id); - } - } - idcache->insert(std::move(g)); - } - endgrent(); - time(&fillTime); -} - #endif |