Allow querying for fstab for a mount point with fstype

Test: th
Bug: 293313353
Change-Id: I8e12c465d0a3e886fcfa0cebf546b145b785c220
This commit is contained in:
Kelvin Zhang 2024-04-24 14:17:20 -07:00
parent 6f7fb5a0b5
commit 6cdee65b8b
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.