Add android::fs_mgr namespace for new Fstab code

Also add libfstab dependencies where needed.  Previously the
`typedef struct FstabEntry Volume;` line served to both define a
`struct FstabEntry` as well as alias Volume to it.  With the new
namespace for android::fs_mgr::FstabEntry, `struct FstabEntry` isn't
compatible anymore, so we need to alias Volume to the real
android::fs_mgr::FstabEntry.

In doing so, we need to include <fstab/fstab.h> and this requires
libfstab as a library, which a few modules did not have before.

Test: treehugger
Change-Id: I655209a0efb304b3e0568db0748bd5cf7cecbdb7
This commit is contained in:
Tom Cherry 2019-01-30 15:59:53 -08:00
parent 9a54dd3bf9
commit 72a114a3e1
5 changed files with 18 additions and 5 deletions

View file

@ -45,6 +45,7 @@ cc_library {
static_libs: [ static_libs: [
"libminui", "libminui",
"libotautil", "libotautil",
"libfstab",
], ],
shared_libs: [ shared_libs: [
@ -157,6 +158,7 @@ cc_defaults {
"libhealthhalutils", "libhealthhalutils",
"libvintf_recovery", "libvintf_recovery",
"libvintf", "libvintf",
"libfstab",
], ],
} }
@ -260,6 +262,7 @@ cc_binary {
static_libs: [ static_libs: [
"libotautil", "libotautil",
"libfstab",
], ],
init_rc: [ init_rc: [
@ -287,6 +290,7 @@ cc_binary {
static_libs: [ static_libs: [
"libotautil", "libotautil",
"libfstab",
], ],
init_rc: [ init_rc: [

View file

@ -29,6 +29,9 @@
#include <android-base/unique_fd.h> #include <android-base/unique_fd.h>
#include <fstab/fstab.h> #include <fstab/fstab.h>
using android::fs_mgr::Fstab;
using android::fs_mgr::ReadDefaultFstab;
static std::string get_misc_blk_device(std::string* err) { static std::string get_misc_blk_device(std::string* err) {
Fstab fstab; Fstab fstab;
if (!ReadDefaultFstab(&fstab)) { if (!ReadDefaultFstab(&fstab)) {

View file

@ -45,6 +45,10 @@
#include "otautil/mounts.h" #include "otautil/mounts.h"
#include "otautil/sysutil.h" #include "otautil/sysutil.h"
using android::fs_mgr::Fstab;
using android::fs_mgr::FstabEntry;
using android::fs_mgr::ReadDefaultFstab;
static Fstab fstab; static Fstab fstab;
extern struct selabel_handle* sehandle; extern struct selabel_handle* sehandle;
@ -69,10 +73,7 @@ void load_volume_table() {
} }
Volume* volume_for_mount_point(const std::string& mount_point) { Volume* volume_for_mount_point(const std::string& mount_point) {
auto it = std::find_if(fstab.begin(), fstab.end(), [&mount_point](const auto& entry) { return android::fs_mgr::GetEntryForMountPoint(&fstab, mount_point);
return entry.mount_point == mount_point;
});
return it == fstab.end() ? nullptr : &*it;
} }
// Mount the volume specified by path at the given mount_point. // Mount the volume specified by path at the given mount_point.

View file

@ -19,7 +19,9 @@
#include <string> #include <string>
typedef struct FstabEntry Volume; #include <fstab/fstab.h>
using Volume = android::fs_mgr::FstabEntry;
// Load and parse volume data from /etc/recovery.fstab. // Load and parse volume data from /etc/recovery.fstab.
void load_volume_table(); void load_volume_table();

View file

@ -119,6 +119,9 @@
#include "otautil/error_code.h" #include "otautil/error_code.h"
using android::fs_mgr::Fstab;
using android::fs_mgr::ReadDefaultFstab;
static constexpr int WINDOW_SIZE = 5; static constexpr int WINDOW_SIZE = 5;
static constexpr int FIBMAP_RETRY_LIMIT = 3; static constexpr int FIBMAP_RETRY_LIMIT = 3;