Merge "Allow querying for fstab for a mount point with fstype" into main

This commit is contained in:
Kelvin Zhang 2024-04-25 16:48:37 +00:00 committed by Gerrit Code Review
commit 946a355241
2 changed files with 11 additions and 0 deletions

View file

@ -849,6 +849,14 @@ std::vector<FstabEntry*> GetEntriesForMountPoint(Fstab* fstab, const std::string
[&path](const FstabEntry& entry) { return entry.mount_point == path; });
}
FstabEntry* GetEntryForMountPoint(Fstab* fstab, const std::string_view path,
const std::string_view fstype) {
auto&& vec = GetEntriesByPred(fstab, [&path, fstype](const FstabEntry& entry) {
return entry.mount_point == path && entry.fs_type == fstype;
});
return vec.empty() ? nullptr : vec.front();
}
std::vector<const FstabEntry*> GetEntriesForMountPoint(const Fstab* fstab,
const std::string& path) {
return GetEntriesByPred(fstab,

View file

@ -108,6 +108,9 @@ std::vector<FstabEntry*> GetEntriesForMountPoint(Fstab* fstab, const std::string
FstabEntry* GetEntryForMountPoint(Fstab* fstab, const std::string& path);
const FstabEntry* GetEntryForMountPoint(const Fstab* fstab, const std::string& path);
FstabEntry* GetEntryForMountPoint(Fstab* fstab, const std::string_view path,
const std::string_view fstype);
// This method builds DSU fstab entries and transfer the fstab.
//
// fstab points to the unmodified fstab.