From c55f188207215bea0980027e47cbc6325a3a1f38 Mon Sep 17 00:00:00 2001 From: Bowgo Tsai Date: Wed, 27 Sep 2017 18:00:10 +0800 Subject: [PATCH] fs_mgr_fstab: removing fs_mgr_get_entry_for_mount_point_after() No fs_mgr client is using fs_mgr_get_entry_for_mount_point_after(), which supports matching a mount point iteratively by specifying a starting entry in the fstab. So removes it. Also switch the public API from C/C++ to C++-only: fs_mgr_get_entry_for_mount_point(struct fstab* fstab, const char* path); ==> fs_mgr_get_entry_for_mount_point(struct fstab* fstab, const std::string& path); Bug: 67024518 Test: boot sailfish, manually test fs_mgr_get_entry_for_mount_point(). Change-Id: I38e18fa6bd9485b6cd31b55474406a511df3f506 --- fs_mgr/fs_mgr_fstab.cpp | 34 ++++-------------------------- fs_mgr/include_fstab/fstab/fstab.h | 2 +- 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp index 31c880361..bce245ce3 100644 --- a/fs_mgr/fs_mgr_fstab.cpp +++ b/fs_mgr/fs_mgr_fstab.cpp @@ -779,47 +779,21 @@ int fs_mgr_add_entry(struct fstab *fstab, } /* - * Returns the 1st matching fstab_rec that follows the start_rec. - * start_rec is the result of a previous search or NULL. + * Returns the fstab_rec* whose mount_point is path. + * Returns nullptr if not found. */ -struct fstab_rec* fs_mgr_get_entry_for_mount_point_after(struct fstab_rec* start_rec, - struct fstab* fstab, - const std::string& path) { - int i; +struct fstab_rec* fs_mgr_get_entry_for_mount_point(struct fstab* fstab, const std::string& path) { if (!fstab) { return nullptr; } - - if (start_rec) { - for (i = 0; i < fstab->num_entries; i++) { - if (&fstab->recs[i] == start_rec) { - i++; - break; - } - } - } else { - i = 0; - } - - for (; i < fstab->num_entries; i++) { + for (int i = 0; i < fstab->num_entries; i++) { if (fstab->recs[i].mount_point && path == fstab->recs[i].mount_point) { return &fstab->recs[i]; } } - return nullptr; } -/* - * Returns the 1st matching mount point. - * There might be more. To look for others, use fs_mgr_get_entry_for_mount_point_after() - * and give the fstab_rec from the previous search. - */ -struct fstab_rec *fs_mgr_get_entry_for_mount_point(struct fstab *fstab, const char *path) -{ - return fs_mgr_get_entry_for_mount_point_after(NULL, fstab, path); -} - int fs_mgr_is_voldmanaged(const struct fstab_rec *fstab) { return fstab->fs_mgr_flags & MF_VOLDMANAGED; diff --git a/fs_mgr/include_fstab/fstab/fstab.h b/fs_mgr/include_fstab/fstab/fstab.h index 8a18ec030..ef5172444 100644 --- a/fs_mgr/include_fstab/fstab/fstab.h +++ b/fs_mgr/include_fstab/fstab/fstab.h @@ -70,7 +70,6 @@ void fs_mgr_free_fstab(struct fstab* fstab); int fs_mgr_add_entry(struct fstab* fstab, const char* mount_point, const char* fs_type, const char* blk_device); -struct fstab_rec* fs_mgr_get_entry_for_mount_point(struct fstab* fstab, const char* path); int fs_mgr_is_voldmanaged(const struct fstab_rec* fstab); int fs_mgr_is_nonremovable(const struct fstab_rec* fstab); int fs_mgr_is_verified(const struct fstab_rec* fstab); @@ -95,6 +94,7 @@ __END_DECLS // TODO: move this into separate header files under include/fs_mgr/*.h #ifdef __cplusplus std::string fs_mgr_get_slot_suffix(); +struct fstab_rec* fs_mgr_get_entry_for_mount_point(struct fstab* fstab, const std::string& path); #endif #endif /* __CORE_FS_TAB_H */