begin to abstract out the file system and mount information. known issue: create_fstab causes segfault on incredible. and thus subsequent crash loop of recovery.
This commit is contained in:
parent
f8b21c2b4d
commit
14239d291a
44
Android.mk
44
Android.mk
@ -26,7 +26,7 @@ LOCAL_MODULE := recovery
|
||||
|
||||
LOCAL_FORCE_STATIC_EXECUTABLE := true
|
||||
|
||||
RECOVERY_VERSION := ClockworkMod Recovery v1.8.2.5
|
||||
RECOVERY_VERSION := ClockworkMod Recovery v1.8.2.8
|
||||
LOCAL_CFLAGS := -DRECOVERY_VERSION="$(RECOVERY_VERSION)"
|
||||
RECOVERY_API_VERSION := 2
|
||||
LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)
|
||||
@ -35,22 +35,36 @@ ifeq ($(BOARD_HAS_NO_SELECT_BUTTON),true)
|
||||
LOCAL_CFLAGS += -DKEY_POWER_IS_SELECT_ITEM
|
||||
endif
|
||||
|
||||
# This file system specific stuff is in need of some serious cleaning up...
|
||||
|
||||
ifeq ($BOARD_SDCARD_MMCBLK1,true)
|
||||
LOCAL_CFLAGS += -DSDCARD_MMCBLK1
|
||||
ifdef BOARD_SDCARD_DEVICE_PRIMARY
|
||||
LOCAL_CFLAGS += -DSDCARD_DEVICE_PRIMARY=\"$(BOARD_SDCARD_DEVICE_PRIMARY)\"
|
||||
endif
|
||||
|
||||
ifeq ($(BOARD_SD_EXT3),true)
|
||||
LOCAL_CFLAGS += -DSD_EXT3
|
||||
ifdef BOARD_SDCARD_DEVICE_SECONDARY
|
||||
LOCAL_CFLAGS += -DSDCARD_DEVICE_SECONDARY=\"$(BOARD_SDCARD_DEVICE_SECONDARY)\"
|
||||
endif
|
||||
|
||||
ifeq ($(BOARD_USERDATA_EXT3),true)
|
||||
LOCAL_CFLAGS += -DUSERDATA_EXT3
|
||||
ifdef BOARD_SDEXT_DEVICE
|
||||
LOCAL_CFLAGS += -DSDEXT_DEVICE=\"$(BOARD_SDEXT_DEVICE)\"
|
||||
endif
|
||||
|
||||
ifeq ($(BOARD_CACHE_EXT3),true)
|
||||
LOCAL_CFLAGS += -DCACHE_EXT3
|
||||
ifdef BOARD_SDEXT_FILESYSTEM
|
||||
LOCAL_CFLAGS += -DSDCARD_DEVICE_PRIMARY=\"$(BOARD_SDEXT_FILESYSTEM)\"
|
||||
endif
|
||||
|
||||
ifdef BOARD_DATA_DEVICE
|
||||
LOCAL_CFLAGS += -DDATA_DEVICE=\"$(BOARD_DATA_DEVICE)\"
|
||||
endif
|
||||
|
||||
ifdef BOARD_DATA_FILESYSTEM
|
||||
LOCAL_CFLAGS += -DDATA_FILESYSTEM=\"$(BOARD_DATA_FILESYSTEM)\"
|
||||
endif
|
||||
|
||||
ifdef BOARD_CACHE_DEVICE
|
||||
LOCAL_CFLAGS += -DCACHE_DEVICE=\"$(BOARD_CACHE_DEVICE)\"
|
||||
endif
|
||||
|
||||
ifdef BOARD_CACHE_FILESYSTEM
|
||||
LOCAL_CFLAGS += -DCACHE_FILESYSTEM=\"$(BOARD_CACHE_FILESYSTEM)\"
|
||||
endif
|
||||
|
||||
# This binary is in the recovery ramdisk, which is otherwise a copy of root.
|
||||
@ -106,14 +120,6 @@ LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
|
||||
LOCAL_SRC_FILES := nandroid-md5.sh
|
||||
include $(BUILD_PREBUILT)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := mkfstab.sh
|
||||
LOCAL_MODULE_TAGS := eng
|
||||
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
|
||||
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
|
||||
LOCAL_SRC_FILES := mkfstab.sh
|
||||
include $(BUILD_PREBUILT)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := killrecovery.sh
|
||||
LOCAL_MODULE_TAGS := eng
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "commands.h"
|
||||
#include "amend/amend.h"
|
||||
|
||||
#include "mtdutils/mtdutils.h"
|
||||
#include "mtdutils/dump_image.h"
|
||||
#include "../../external/yaffs2/yaffs2/utils/mkyaffs2image.h"
|
||||
#include "../../external/yaffs2/yaffs2/utils/unyaffs.h"
|
||||
@ -785,4 +786,32 @@ void show_advanced_menu()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void write_fstab_root(char *root_path, FILE *file)
|
||||
{
|
||||
RootInfo *info = get_root_info_for_path(root_path);
|
||||
MtdPartition *mtd = get_root_mtd_partition(root_path);
|
||||
if (mtd != NULL)
|
||||
{
|
||||
fprintf(file, "/dev/block/mtdblock%d ", mtd->device_index);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(file, "%s ", info->device);
|
||||
}
|
||||
|
||||
fprintf(file, "%s ", info->mount_point);
|
||||
fprintf(file, "%s rw\n", info->filesystem);
|
||||
}
|
||||
|
||||
void create_fstab()
|
||||
{
|
||||
FILE *file = fopen("/etc/fstab", "w");
|
||||
write_fstab_root("CACHE:", file);
|
||||
write_fstab_root("DATA:", file);
|
||||
write_fstab_root("SYSTEM:", file);
|
||||
write_fstab_root("SDCARD:", file);
|
||||
write_fstab_root("SDEXT:", file);
|
||||
fclose(file);
|
||||
}
|
@ -43,3 +43,4 @@ format_non_mtd_device(const char* root);
|
||||
void
|
||||
wipe_battery_stats();
|
||||
|
||||
void create_fstab();
|
||||
|
41
mkfstab.sh
41
mkfstab.sh
@ -1,41 +0,0 @@
|
||||
#!/sbin/sh
|
||||
|
||||
rm -f /etc/fstab
|
||||
cat /proc/mtd | while read mtdentry
|
||||
do
|
||||
mtd=$(echo $mtdentry | awk '{print $1}')
|
||||
mtd=$(echo $mtd | sed s/mtd//)
|
||||
mtd=$(echo $mtd | sed s/://)
|
||||
exist=$(ls -l /dev/block/mtdblock$mtd) 2> /dev/null
|
||||
if [ -z "$exist" ]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
partition=$(echo $mtdentry | awk '{print $4}')
|
||||
partition=$(echo $partition | sed s/\"//g)
|
||||
mount=$partition
|
||||
type=
|
||||
if [ "$partition" = "system" ]
|
||||
then
|
||||
type=yaffs2
|
||||
elif [ "$partition" = "userdata" ]
|
||||
then
|
||||
type=yaffs2
|
||||
mount=data
|
||||
elif [ "$partition" == "cache" ]
|
||||
then
|
||||
type=yaffs2
|
||||
else
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "/dev/block/mtdblock$mtd /$mount $type rw" >> /etc/fstab
|
||||
done
|
||||
if [ ! -z $SDCARD_MMCBLK1 ]
|
||||
then
|
||||
echo "/dev/block/mmcblk1p1" /sdcard vfat rw >> /etc/fstab
|
||||
echo "/dev/block/mmcblk1p2" /sd-ext auto rw >> /etc/fstab
|
||||
else
|
||||
echo "/dev/block/mmcblk0p1" /sdcard vfat rw >> /etc/fstab
|
||||
echo "/dev/block/mmcblk0p2" /sd-ext auto rw >> /etc/fstab
|
||||
fi
|
@ -28,13 +28,6 @@
|
||||
|
||||
#include "mtdutils.h"
|
||||
|
||||
struct MtdPartition {
|
||||
int device_index;
|
||||
unsigned int size;
|
||||
unsigned int erase_size;
|
||||
char *name;
|
||||
};
|
||||
|
||||
struct MtdReadContext {
|
||||
const MtdPartition *partition;
|
||||
char *buffer;
|
||||
|
@ -52,4 +52,11 @@ off_t mtd_erase_blocks(MtdWriteContext *, int blocks); /* 0 ok, -1 for all */
|
||||
off_t mtd_find_write_start(MtdWriteContext *ctx, off_t pos);
|
||||
int mtd_write_close(MtdWriteContext *);
|
||||
|
||||
struct MtdPartition {
|
||||
int device_index;
|
||||
unsigned int size;
|
||||
unsigned int erase_size;
|
||||
char *name;
|
||||
};
|
||||
|
||||
#endif // MTDUTILS_H_
|
||||
|
@ -491,11 +491,7 @@ main(int argc, char **argv)
|
||||
return amend_main(argc, argv);
|
||||
return busybox_driver(argc, argv);
|
||||
}
|
||||
#ifdef SDCARD_MMCBLK1
|
||||
__system("SDCARD_MMCBLK1=true /sbin/mkfstab.sh");
|
||||
#else
|
||||
__system("/sbin/mkfstab.sh");
|
||||
#endif
|
||||
//create_fstab();
|
||||
__system("/sbin/postrecoveryboot.sh");
|
||||
|
||||
int is_user_initiated_recovery = 0;
|
||||
|
63
roots.c
63
roots.c
@ -29,15 +29,6 @@
|
||||
|
||||
#include "extendedcommands.h"
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *device;
|
||||
const char *device2; // If the first one doesn't work (may be NULL)
|
||||
const char *partition_name;
|
||||
const char *mount_point;
|
||||
const char *filesystem;
|
||||
} RootInfo;
|
||||
|
||||
/* Canonical pointers.
|
||||
xxx may just want to use enums
|
||||
*/
|
||||
@ -45,43 +36,47 @@ static const char g_mtd_device[] = "@\0g_mtd_device";
|
||||
static const char g_raw[] = "@\0g_raw";
|
||||
static const char g_package_file[] = "@\0g_package_file";
|
||||
|
||||
#ifdef SDCARD_MMCBLK1
|
||||
#define SDCARD_MMCBLK_SECONDARY "/dev/block/mmcblk1"
|
||||
#define SDCARD_MMCBLK_PRIMARY "/dev/block/mmcblk1p1"
|
||||
#define SDEXT "/dev/block/mmcblk1p2"
|
||||
#else
|
||||
#define SDCARD_MMCBLK_SECONDARY "/dev/block/mmcblk0"
|
||||
#define SDCARD_MMCBLK_PRIMARY "/dev/block/mmcblk0p1"
|
||||
#define SDEXT "/dev/block/mmcblk0p2"
|
||||
#ifndef SDCARD_DEVICE_PRIMARY
|
||||
#define SDCARD_DEVICE_PRIMARY "/dev/block/mmcblk0p1"
|
||||
#endif
|
||||
|
||||
#ifdef SD_EXT3
|
||||
#define SD_EXT_FILE_SYSTEM "ext3"
|
||||
#else
|
||||
#define SD_EXT_FILE_SYSTEM "ext4"
|
||||
#ifndef SDCARD_DEVICE_SECONDARY
|
||||
#define SDCARD_DEVICE_SECONDARY "/dev/block/mmcblk0p2"
|
||||
#endif
|
||||
|
||||
#ifdef USERDATA_EXT3
|
||||
#define SD_EXT_FILE_SYSTEM "ext3"
|
||||
#else
|
||||
#define SD_EXT_FILE_SYSTEM "ext4"
|
||||
#ifndef SDEXT_DEVICE
|
||||
#define SDEXT_DEVICE "/dev/block/mmcblk0p2"
|
||||
#endif
|
||||
|
||||
#ifdef CACHE_EXT3
|
||||
#define SD_EXT_FILE_SYSTEM "ext3"
|
||||
#else
|
||||
#define SD_EXT_FILE_SYSTEM "ext4"
|
||||
#ifndef SDEXT_FILESYSTEM
|
||||
#define SDEXT_FILESYSTEM "ext4"
|
||||
#endif
|
||||
|
||||
#ifndef DATA_DEVICE
|
||||
#define DATA_DEVICE g_mtd_device
|
||||
#endif
|
||||
|
||||
#ifndef DATA_FILESYSTEM
|
||||
#define DATA_FILESYSTEM "yaffs2"
|
||||
#endif
|
||||
|
||||
#ifndef CACHE_DEVICE
|
||||
#define CACHE_DEVICE g_mtd_device
|
||||
#endif
|
||||
|
||||
#ifndef CACHE_FILESYSTEM
|
||||
#define CACHE_FILESYSTEM "yaffs2"
|
||||
#endif
|
||||
|
||||
static RootInfo g_roots[] = {
|
||||
{ "BOOT:", g_mtd_device, NULL, "boot", NULL, g_raw },
|
||||
{ "CACHE:", g_mtd_device, NULL, "cache", "/cache", "yaffs2" },
|
||||
{ "DATA:", g_mtd_device, NULL, "userdata", "/data", "yaffs2" },
|
||||
{ "CACHE:", CACHE_DEVICE, NULL, "cache", "/cache", CACHE_FILESYSTEM },
|
||||
{ "DATA:", DATA_DEVICE, NULL, "userdata", "/data", DATA_FILESYSTEM },
|
||||
{ "MISC:", g_mtd_device, NULL, "misc", NULL, g_raw },
|
||||
{ "PACKAGE:", NULL, NULL, NULL, NULL, g_package_file },
|
||||
{ "RECOVERY:", g_mtd_device, NULL, "recovery", "/", g_raw },
|
||||
{ "SDCARD:", SDCARD_MMCBLK_PRIMARY, SDCARD_MMCBLK_SECONDARY, NULL, "/sdcard", "vfat" },
|
||||
{ "SDEXT:", SDEXT, NULL, NULL, "/sd-ext", SD_EXT_FILE_SYSTEM },
|
||||
{ "SDCARD:", SDCARD_DEVICE_PRIMARY, SDCARD_DEVICE_SECONDARY, NULL, "/sdcard", "vfat" },
|
||||
{ "SDEXT:", SDEXT_DEVICE, NULL, NULL, "/sd-ext", SDEXT_FILESYSTEM },
|
||||
{ "SYSTEM:", g_mtd_device, NULL, "system", "/system", "yaffs2" },
|
||||
{ "MBM:", g_mtd_device, NULL, "mbm", NULL, g_raw },
|
||||
{ "TMP:", NULL, NULL, NULL, "/tmp", NULL },
|
||||
@ -90,7 +85,7 @@ static RootInfo g_roots[] = {
|
||||
|
||||
// TODO: for SDCARD:, try /dev/block/mmcblk0 if mmcblk0p1 fails
|
||||
|
||||
static const RootInfo *
|
||||
const RootInfo *
|
||||
get_root_info_for_path(const char *root_path)
|
||||
{
|
||||
const char *c;
|
||||
|
9
roots.h
9
roots.h
@ -60,4 +60,13 @@ const MtdPartition *get_root_mtd_partition(const char *root_path);
|
||||
*/
|
||||
int format_root_device(const char *root);
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *device;
|
||||
const char *device2; // If the first one doesn't work (may be NULL)
|
||||
const char *partition_name;
|
||||
const char *mount_point;
|
||||
const char *filesystem;
|
||||
} RootInfo;
|
||||
|
||||
#endif // RECOVERY_ROOTS_H_
|
||||
|
Loading…
Reference in New Issue
Block a user