From 74e83ebecfebce0952705665bc706536259c309c Mon Sep 17 00:00:00 2001 From: Steve Kondik Date: Sun, 24 Nov 2013 21:40:09 -0800 Subject: sr: Puke out an /etc/fstab so stuff like Busybox is happy * And disregard special mount flags on purpose because of certain dubious packages which "exec busybox mount". Change-Id: I163702c9bd7fca3d40676fd6d8476e8deb13acc0 --- roots.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'roots.cpp') diff --git a/roots.cpp b/roots.cpp index af3a960..966c8b2 100644 --- a/roots.cpp +++ b/roots.cpp @@ -39,6 +39,20 @@ static struct fstab *fstab = NULL; extern struct selabel_handle *sehandle; +static void write_fstab_entry(Volume *v, FILE *file) +{ + if (NULL != v && strcmp(v->fs_type, "mtd") != 0 && strcmp(v->fs_type, "emmc") != 0 + && strcmp(v->fs_type, "bml") != 0 && !fs_mgr_is_voldmanaged(v) + && strncmp(v->blk_device, "/", 1) == 0 + && strncmp(v->mount_point, "/", 1) == 0) { + + fprintf(file, "%s ", v->blk_device); + fprintf(file, "%s ", v->mount_point); + fprintf(file, "%s ", v->fs_type); + fprintf(file, "%s 0 0\n", v->fs_options == NULL ? "defaults" : v->fs_options); + } +} + void load_volume_table() { int i; @@ -58,13 +72,25 @@ void load_volume_table() return; } + // Create a boring /etc/fstab so tools like Busybox work + FILE *file = fopen("/etc/fstab", "w"); + if (file == NULL) { + LOGW("Unable to create /etc/fstab!\n"); + return; + } + printf("recovery filesystem table\n"); printf("=========================\n"); for (i = 0; i < fstab->num_entries; ++i) { Volume* v = &fstab->recs[i]; printf(" %d %s %s %s %lld\n", i, v->mount_point, v->fs_type, v->blk_device, v->length); + + write_fstab_entry(v, file); } + + fclose(file); + printf("\n"); } -- cgit v1.1