From 8e2b4af30bf1608217030f9b39ba5d4129a6d364 Mon Sep 17 00:00:00 2001
From: David Rouleau <Shabbypenguin@gmail.com>
Date: Tue, 15 Jul 2014 17:08:34 -0400
Subject: [PATCH] Try seperate fstabs again

---
 BoardConfig.mk         |  8 ++++++--
 device_peregrine.mk    |  8 ++++++++
 rootdir/Android.mk     | 10 ++++++++++
 rootdir/etc/fstab.qcom | 17 +++++++++++++++++
 rootdir/etc/twrp.fstab |  8 ++++++++
 5 files changed, 49 insertions(+), 2 deletions(-)
 create mode 100644 rootdir/Android.mk
 create mode 100644 rootdir/etc/fstab.qcom
 create mode 100644 rootdir/etc/twrp.fstab

diff --git a/BoardConfig.mk b/BoardConfig.mk
index f1e5aff..ea8a508 100644
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -29,11 +29,15 @@
 LOCAL_PATH := device/motorola/perergine
 
 BOARD_CUSTOM_BOOTIMG_MK := device/motorola/peregrine/mkbootimg.mk
-BOARD_HAS_NO_MISC_PARTITION := true
+# BOARD_HAS_NO_MISC_PARTITION := true
+
+TARGET_UNIFIED_DEVICE := true
+TARGET_INIT_VENDOR_LIB := libinit_msm
 
-# fix this up by examining /proc/mtd on a running device
 BOARD_USERDATAIMAGE_PARTITION_SIZE := 8589934592
 
+TARGET_RECOVERY_FSTAB := $(LOCAL_PATH)/rootdir/etc/fstab.qcom
+
 #TWRP
 DEVICE_RESOLUTION := 720x1280
 TW_IGNORE_MAJOR_AXIS_0 := true
diff --git a/device_peregrine.mk b/device_peregrine.mk
index e7d71e6..bf73629 100644
--- a/device_peregrine.mk
+++ b/device_peregrine.mk
@@ -7,6 +7,14 @@ LOCAL_PATH := device/motorola/peregrine
 # peregrine specific overlay
 DEVICE_PACKAGE_OVERLAYS += $(LOCAL_PATH)/overlay
 
+# Ramdisk
+PRODUCT_PACKAGES += \
+    fstab.qcom
+
+# TWRP
+PRODUCT_COPY_FILES += \
+    $(LOCAL_PATH)/rootdir/etc/twrp.fstab:recovery/root/etc/twrp.fstab
+
 PRODUCT_LOCALES := en_US
 PRODUCT_LOCALES += xhdpi
 PRODUCT_AAPT_CONFIG := normal hdpi xhdpi
diff --git a/rootdir/Android.mk b/rootdir/Android.mk
new file mode 100644
index 0000000..4477b0f
--- /dev/null
+++ b/rootdir/Android.mk
@@ -0,0 +1,10 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE       := fstab.qcom
+LOCAL_MODULE_TAGS  := optional eng
+LOCAL_MODULE_CLASS := ETC
+LOCAL_SRC_FILES    := etc/fstab.qcom
+LOCAL_MODULE_PATH  := $(TARGET_ROOT_OUT)
+include $(BUILD_PREBUILT)
diff --git a/rootdir/etc/fstab.qcom b/rootdir/etc/fstab.qcom
new file mode 100644
index 0000000..1101fc5
--- /dev/null
+++ b/rootdir/etc/fstab.qcom
@@ -0,0 +1,17 @@
+# Android fstab file.
+# The filesystem that contains the filesystem checker binary (typically /system) cannot
+# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
+#<src>                                              <mnt_point>  <type>  <mnt_flags and options>                                                        <fs_mgr_flags>
+/dev/block/platform/msm_sdcc.1/by-name/system       /system      ext4    ro,barrier=1                                                                   wait
+/dev/block/platform/msm_sdcc.1/by-name/userdata     /data        f2fs    rw,discard,nosuid,nodev,noatime,nodiratime,inline_xattr,errors=recover         wait,nonremovable,encryptable=footer,length=-16384
+/dev/block/platform/msm_sdcc.1/by-name/cache        /cache       ext4    rw,nosuid,nodev,noatime,nodiratime,data=writeback,noauto_da_alloc,barrier=1    wait,check
+/dev/block/platform/msm_sdcc.1/by-name/fsg          /fsg         ext4    defaults                                                                       recoveryonly
+/dev/block/platform/msm_sdcc.1/by-name/modem        /firmware    ext4    defaults                                                                       recoveryonly
+/dev/block/platform/msm_sdcc.1/by-name/persist      /persist     ext4    defaults                                                                       recoveryonly
+/dev/block/platform/msm_sdcc.1/by-name/boot         /boot        emmc    defaults                                                                       recoveryonly
+/dev/block/platform/msm_sdcc.1/by-name/recovery     /recovery    emmc    defaults                                                                       recoveryonly
+
+/dev/block/mmcblk1p1            		    /external_sd auto    default  	  								recoveryonly
+/devices/msm_sdcc.2/mmc_host                        auto         vfat    defaults							                voldmanaged=sdcard1:auto,migrate=target,noemulatedsd
+/devices/platform/msm_hsusb_host                    auto         auto    defaults                                                                       voldmanaged=usbdisk:auto
+/dev/block/zram0                                    none         swap    defaults                                                                       zramsize=134217728
diff --git a/rootdir/etc/twrp.fstab b/rootdir/etc/twrp.fstab
new file mode 100644
index 0000000..3badbc4
--- /dev/null
+++ b/rootdir/etc/twrp.fstab
@@ -0,0 +1,8 @@
+# mount point   fstype          device
+
+/data         f2fs      /dev/block/platform/msm_sdcc.1/by-name/userdata     flags=fsflags="inline_xattr"
+/cache        ext4      /dev/block/platform/msm_sdcc.1/by-name/cache
+/system       ext4      /dev/block/platform/msm_sdcc.1/by-name/system
+/boot         emmc      /dev/block/platform/msm_sdcc.1/by-name/boot
+/recovery     emmc      /dev/block/platform/msm_sdcc.1/by-name/recovery
+/external_sd    vfat    /dev/block/mmcblk1p1    /dev/block/mmcblk1              flags=display="Micro SDcard";storage;wipeingui;removable