Use new fstab_suffix feature

Now the fstab suffix can be controlled independently of ro.hardware or
ro.hardware.platform, we can install both f2fs and ext4 fstabs
concurrently. This change does not implement dynamic switching.

Bug: 142424832
Change-Id: I4084aa06c404e5ded0cce13d0ec7ce64efcdccf8
Merged-In: I4084aa06c404e5ded0cce13d0ec7ce64efcdccf8
diff --git a/shared/BoardConfig.mk b/shared/BoardConfig.mk
index c9d09ba..6d8220a 100644
--- a/shared/BoardConfig.mk
+++ b/shared/BoardConfig.mk
@@ -145,7 +145,7 @@
 
 TARGET_RECOVERY_PIXEL_FORMAT := ABGR_8888
 
-TARGET_RECOVERY_FSTAB ?= device/google/cuttlefish/shared/config/fstab
+TARGET_RECOVERY_FSTAB ?= device/google/cuttlefish/shared/config/fstab.f2fs
 
 BOARD_SUPER_PARTITION_SIZE := 6442450944
 BOARD_SUPER_PARTITION_GROUPS := google_dynamic_partitions
@@ -165,6 +165,14 @@
 BOARD_KERNEL_CMDLINE += security=selinux
 BOARD_KERNEL_CMDLINE += androidboot.console=ttyS1
 
+ifeq ($(TARGET_USERDATAIMAGE_FILE_SYSTEM_TYPE),f2fs)
+BOARD_KERNEL_CMDLINE += androidboot.fstab_suffix=f2fs
+endif
+
+ifeq ($(TARGET_USERDATAIMAGE_FILE_SYSTEM_TYPE),ext4)
+BOARD_KERNEL_CMDLINE += androidboot.fstab_suffix=ext4
+endif
+
 BOARD_INCLUDE_DTB_IN_BOOTIMG := true
 BOARD_BOOT_HEADER_VERSION := 3
 BOARD_USES_RECOVERY_AS_BOOT := true
diff --git a/shared/config/fstab b/shared/config/fstab.f2fs
similarity index 100%
rename from shared/config/fstab
rename to shared/config/fstab.f2fs
diff --git a/shared/config/init.vendor.rc b/shared/config/init.vendor.rc
index 66b6c75..0e10cd2 100644
--- a/shared/config/init.vendor.rc
+++ b/shared/config/init.vendor.rc
@@ -48,7 +48,7 @@
 
 on fs
     # Mount everything that does not require fsck
-    mount_all /vendor/etc/fstab.${ro.hardware} --early
+    mount_all --early
     restorecon_recursive /vendor
 
     start setup_wifi
@@ -86,7 +86,7 @@
     exec_start wait_for_keymaster
 
     # Mount RW partitions which need run fsck
-    mount_all /vendor/etc/fstab.${ro.hardware} --late
+    mount_all --late
 
     write /dev/kmsg "GUEST_BUILD_FINGERPRINT: ${ro.build.fingerprint}"
 
diff --git a/shared/device.mk b/shared/device.mk
index 02e002d..72dd5e7 100644
--- a/shared/device.mk
+++ b/shared/device.mk
@@ -222,20 +222,12 @@
     frameworks/native/data/etc/android.software.verified_boot.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.verified_boot.xml \
     system/bt/vendor_libs/test_vendor_lib/data/controller_properties.json:vendor/etc/bluetooth/controller_properties.json \
     device/google/cuttlefish/shared/config/task_profiles.json:$(TARGET_COPY_OUT_VENDOR)/etc/task_profiles.json \
-
-ifeq ($(TARGET_USERDATAIMAGE_FILE_SYSTEM_TYPE),f2fs)
-PRODUCT_COPY_FILES += \
-    device/google/cuttlefish/shared/config/fstab:$(TARGET_COPY_OUT_RAMDISK)/fstab.cutf_cvm \
-    device/google/cuttlefish/shared/config/fstab:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.cutf_cvm \
-    device/google/cuttlefish/shared/config/fstab:$(TARGET_COPY_OUT_RECOVERY)/root/first_stage_ramdisk/fstab.cutf_cvm
-endif
-
-ifeq ($(TARGET_USERDATAIMAGE_FILE_SYSTEM_TYPE),ext4)
-PRODUCT_COPY_FILES += \
-    device/google/cuttlefish/shared/config/fstab.ext4:$(TARGET_COPY_OUT_RAMDISK)/fstab.cutf_cvm \
-    device/google/cuttlefish/shared/config/fstab.ext4:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.cutf_cvm \
-    device/google/cuttlefish/shared/config/fstab.ext4:$(TARGET_COPY_OUT_RECOVERY)/root/first_stage_ramdisk/fstab.cutf_cvm
-endif
+    device/google/cuttlefish/shared/config/fstab.f2fs:$(TARGET_COPY_OUT_RAMDISK)/fstab.f2fs \
+    device/google/cuttlefish/shared/config/fstab.f2fs:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.f2fs \
+    device/google/cuttlefish/shared/config/fstab.f2fs:$(TARGET_COPY_OUT_RECOVERY)/root/first_stage_ramdisk/fstab.f2fs \
+    device/google/cuttlefish/shared/config/fstab.ext4:$(TARGET_COPY_OUT_RAMDISK)/fstab.ext4 \
+    device/google/cuttlefish/shared/config/fstab.ext4:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.ext4 \
+    device/google/cuttlefish/shared/config/fstab.ext4:$(TARGET_COPY_OUT_RECOVERY)/root/first_stage_ramdisk/fstab.ext4
 
 ifeq ($(TARGET_VULKAN_SUPPORT),true)
 PRODUCT_COPY_FILES += \