diff --git a/fs_mgr/libfstab/fstab.cpp b/fs_mgr/libfstab/fstab.cpp index 6fa22fee5..6273ee2e8 100644 --- a/fs_mgr/libfstab/fstab.cpp +++ b/fs_mgr/libfstab/fstab.cpp @@ -849,6 +849,14 @@ std::vector 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 GetEntriesForMountPoint(const Fstab* fstab, const std::string& path) { return GetEntriesByPred(fstab, diff --git a/fs_mgr/libfstab/include/fstab/fstab.h b/fs_mgr/libfstab/include/fstab/fstab.h index 5e4019ca1..dea723831 100644 --- a/fs_mgr/libfstab/include/fstab/fstab.h +++ b/fs_mgr/libfstab/include/fstab/fstab.h @@ -108,6 +108,9 @@ std::vector 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.