Merge "Remove MTD cruft from init."
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 98595da..452e333 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -382,22 +382,7 @@
     source = args[2].c_str();
     target = args[3].c_str();
 
-    if (!strncmp(source, "mtd@", 4)) {
-        n = mtd_name_to_number(source + 4);
-        if (n < 0) {
-            return -1;
-        }
-
-        snprintf(tmp, sizeof(tmp), "/dev/block/mtdblock%d", n);
-
-        if (wait)
-            wait_for_file(tmp, COMMAND_RETRY_TIMEOUT);
-        if (mount(tmp, target, system, flags, options) < 0) {
-            return -1;
-        }
-
-        goto exit_success;
-    } else if (!strncmp(source, "loop@", 5)) {
+    if (!strncmp(source, "loop@", 5)) {
         int mode, loop, fd;
         struct loop_info info;
 
diff --git a/init/readme.txt b/init/readme.txt
index e75b4b2..27c5e67 100644
--- a/init/readme.txt
+++ b/init/readme.txt
@@ -311,8 +311,6 @@
 
 mount <type> <device> <dir> [ <flag> ]* [<options>]
    Attempt to mount the named device at the directory <dir>
-   <device> may be of the form mtd@name to specify a mtd block
-   device by name.
    <flag>s include "ro", "rw", "remount", "noatime", ...
    <options> include "barrier=1", "noauto_da_alloc", "discard", ... as
    a comma separated string, eg: barrier=1,noauto_da_alloc
diff --git a/init/ueventd.cpp b/init/ueventd.cpp
index 73b2136..b637141 100644
--- a/init/ueventd.cpp
+++ b/init/ueventd.cpp
@@ -119,22 +119,13 @@
         return;
     }
 
-    /* If path starts with mtd@ lookup the mount number. */
-    if (!strncmp(name, "mtd@", 4)) {
-        int n = mtd_name_to_number(name + 4);
-        if (n >= 0)
-            asprintf(&tmp, "/dev/mtd/mtd%d", n);
-        name = tmp;
-    } else {
-        int len = strlen(name);
-        char *wildcard_chr = strchr(name, '*');
-        if ((name[len - 1] == '*') &&
-            (wildcard_chr == (name + len - 1))) {
-            prefix = 1;
-            name[len - 1] = '\0';
-        } else if (wildcard_chr) {
-            wildcard = 1;
-        }
+    int len = strlen(name);
+    char *wildcard_chr = strchr(name, '*');
+    if ((name[len - 1] == '*') && (wildcard_chr == (name + len - 1))) {
+        prefix = 1;
+        name[len - 1] = '\0';
+    } else if (wildcard_chr) {
+        wildcard = 1;
     }
 
     perm = strtol(args[1], &endptr, 8);
diff --git a/init/util.cpp b/init/util.cpp
index 69f6566..368096e 100644
--- a/init/util.cpp
+++ b/init/util.cpp
@@ -199,78 +199,6 @@
     return result;
 }
 
-#define MAX_MTD_PARTITIONS 16
-
-static struct {
-    char name[16];
-    int number;
-} mtd_part_map[MAX_MTD_PARTITIONS];
-
-static int mtd_part_count = -1;
-
-static void find_mtd_partitions(void)
-{
-    int fd;
-    char buf[1024];
-    char *pmtdbufp;
-    ssize_t pmtdsize;
-    int r;
-
-    fd = open("/proc/mtd", O_RDONLY|O_CLOEXEC);
-    if (fd < 0)
-        return;
-
-    buf[sizeof(buf) - 1] = '\0';
-    pmtdsize = read(fd, buf, sizeof(buf) - 1);
-    pmtdbufp = buf;
-    while (pmtdsize > 0) {
-        int mtdnum, mtdsize, mtderasesize;
-        char mtdname[16];
-        mtdname[0] = '\0';
-        mtdnum = -1;
-        r = sscanf(pmtdbufp, "mtd%d: %x %x %15s",
-                   &mtdnum, &mtdsize, &mtderasesize, mtdname);
-        if ((r == 4) && (mtdname[0] == '"')) {
-            char *x = strchr(mtdname + 1, '"');
-            if (x) {
-                *x = 0;
-            }
-            INFO("mtd partition %d, %s\n", mtdnum, mtdname + 1);
-            if (mtd_part_count < MAX_MTD_PARTITIONS) {
-                strcpy(mtd_part_map[mtd_part_count].name, mtdname + 1);
-                mtd_part_map[mtd_part_count].number = mtdnum;
-                mtd_part_count++;
-            } else {
-                ERROR("too many mtd partitions\n");
-            }
-        }
-        while (pmtdsize > 0 && *pmtdbufp != '\n') {
-            pmtdbufp++;
-            pmtdsize--;
-        }
-        if (pmtdsize > 0) {
-            pmtdbufp++;
-            pmtdsize--;
-        }
-    }
-    close(fd);
-}
-
-int mtd_name_to_number(const char *name)
-{
-    int n;
-    if (mtd_part_count < 0) {
-        mtd_part_count = 0;
-        find_mtd_partitions();
-    }
-    for (n = 0; n < mtd_part_count; n++) {
-        if (!strcmp(name, mtd_part_map[n].name)) {
-            return mtd_part_map[n].number;
-        }
-    }
-    return -1;
-}
-
 time_t gettime() {
     timespec now;
     clock_gettime(CLOCK_MONOTONIC, &now);
diff --git a/init/util.h b/init/util.h
index b9496a9..90fb39a 100644
--- a/init/util.h
+++ b/init/util.h
@@ -27,7 +27,6 @@
 
 #define COLDBOOT_DONE "/dev/.coldboot_done"
 
-int mtd_name_to_number(const char *name);
 int create_socket(const char *name, int type, mode_t perm,
                   uid_t uid, gid_t gid, const char *socketcon);