summaryrefslogtreecommitdiffstats
path: root/roots.c
diff options
context:
space:
mode:
Diffstat (limited to 'roots.c')
-rw-r--r--roots.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/roots.c b/roots.c
index a510145e5..9691ad365 100644
--- a/roots.c
+++ b/roots.c
@@ -23,6 +23,11 @@
#include "mtdutils/mtdutils.h"
#include "mtdutils/mounts.h"
+
+#ifdef USE_EXT4
+#include "make_ext4fs.h"
+#endif
+
#include "minzip/Zip.h"
#include "roots.h"
#include "common.h"
@@ -45,16 +50,25 @@ static const char g_package_file[] = "@\0g_package_file";
static const char g_ramdisk[] = "@\0g_ramdisk";
static RootInfo g_roots[] = {
+ { "SDCARD:", "/dev/block/mmcblk0p1", "/dev/block/mmcblk0", NULL, "/sdcard", "vfat" },
+ { "TMP:", NULL, NULL, NULL, "/tmp", g_ramdisk },
+
+#ifdef USE_EXT4
+ { "CACHE:", "/dev/block/platform/sdhci-tegra.3/by-name/cache", NULL, NULL,
+ "/cache", "ext4" },
+ { "DATA:", "/dev/block/platform/sdhci-tegra.3/by-name/userdata", NULL, NULL,
+ "/data", "ext4" },
+ { "EXT:", "/dev/block/sda1", NULL, NULL, "/sdcard", "vfat" },
+#else
{ "CACHE:", g_mtd_device, NULL, "cache", "/cache", "yaffs2" },
{ "DATA:", g_mtd_device, NULL, "userdata", "/data", "yaffs2" },
+ { "EXT:", "/dev/block/mmcblk0p1", "/dev/block/mmcblk0", NULL, "/sdcard", "vfat" },
{ "MISC:", g_mtd_device, NULL, "misc", NULL, g_raw },
- { "SDCARD:", "/dev/block/mmcblk0p1", "/dev/block/mmcblk0", NULL, "/sdcard", "vfat" },
- { "TMP:", NULL, NULL, NULL, "/tmp", g_ramdisk },
+#endif
+
};
#define NUM_ROOTS (sizeof(g_roots) / sizeof(g_roots[0]))
-// TODO: for SDCARD:, try /dev/block/mmcblk0 if mmcblk0p1 fails
-
static const RootInfo *
get_root_info_for_path(const char *root_path)
{
@@ -197,7 +211,7 @@ ensure_root_path_mounted(const char *root_path)
mkdir(info->mount_point, 0755); // in case it doesn't already exist
if (mount(info->device, info->mount_point, info->filesystem,
- MS_NOATIME | MS_NODEV | MS_NODIRATIME, "")) {
+ MS_NOATIME | MS_NODEV | MS_NODIRATIME, "")) {
if (info->device2 == NULL) {
LOGE("Can't mount %s\n(%s)\n", info->device, strerror(errno));
return -1;
@@ -313,7 +327,23 @@ format_root_device(const char *root)
}
}
}
+
+#ifdef USE_EXT4
+ if (strcmp(info->filesystem, "ext4") == 0) {
+ LOGW("starting to reformat ext4\n");
+ reset_ext4fs_info();
+ int result = make_ext4fs(info->device, NULL, NULL, 0, 0, 0);
+ LOGW("finished reformat ext4: result = %d\n", result);
+ if (result != 0) {
+ LOGW("make_ext4fs failed: %d\n", result);
+ return -1;
+ }
+ return 0;
+ }
+#endif
+
//TODO: handle other device types (sdcard, etc.)
- LOGW("format_root_device: can't handle non-mtd device \"%s\"\n", root);
+
+ LOGW("format_root_device: unknown device \"%s\"\n", root);
return -1;
}