MCPcopy Create free account
hub / github.com/MhmRdd/NoHello / MountRootResolver

Class MountRootResolver

module/src/main/cpp/mountsinfo.cpp:210–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208};
209
210class MountRootResolver {
211private:
212 std::unordered_map<dev_t, std::string> dmm;
213
214public:
215 explicit MountRootResolver(const std::vector<MountInfo>& mounts) {
216 for (const auto& mount : mounts) {
217 if (mount.getRoot() == "/") {
218 dmm[mount.getDev()] = mount.getMountPoint();
219 }
220 }
221 }
222
223 ~MountRootResolver() = default;
224
225 std::string resolveRoot(const MountInfo& mount) {
226 auto dev = mount.getDev();
227 auto it = dmm.find(dev);
228 if (it != dmm.end()) {
229 if (it->second != "/")
230 return it->second + mount.getRoot();
231 }
232 return mount.getRoot();
233 }
234};
235
236std::vector<MountInfo> getMountInfo(const std::string& path = "/proc/self/mountinfo") {
237 std::ifstream mi(path);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected