Revert "Replace strtok_r() with C++-style android::base::Tokenize()"

Revert submission 1890098

Reason for revert: Breaks tests, b/206740783
Reverted Changes:
I71190c735:Add ParseFstabFromString(), remove ReadFstabFromFp...
Ic1dd0eb97:Replace strtok_r() with C++-style android::base::T...

Change-Id: I1eecdc43d504385b00caec17db626eb1d623c8ef
diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp
index 0b083e5..159be67 100644
--- a/fs_mgr/fs_mgr_fstab.cpp
+++ b/fs_mgr/fs_mgr_fstab.cpp
@@ -526,11 +526,11 @@
 }  // namespace
 
 bool ReadFstabFromFp(FILE* fstab_file, bool proc_mounts, Fstab* fstab_out) {
-    const int expected_fields = proc_mounts ? 4 : 5;
     ssize_t len;
     size_t alloc_len = 0;
     char *line = NULL;
-    char* p;
+    const char *delim = " \t";
+    char *save_ptr, *p;
     Fstab fstab;
 
     while ((len = getline(&line, &alloc_len, fstab_file)) != -1) {
@@ -548,23 +548,42 @@
         if (*p == '#' || *p == '\0')
             continue;
 
-        auto fields = android::base::Tokenize(line, " \t");
-        if (fields.size() < expected_fields) {
-            LERROR << "Error parsing fstab: expected " << expected_fields << " fields, got "
-                   << fields.size();
+        FstabEntry entry;
+
+        if (!(p = strtok_r(line, delim, &save_ptr))) {
+            LERROR << "Error parsing mount source";
+            goto err;
+        }
+        entry.blk_device = p;
+
+        if (!(p = strtok_r(NULL, delim, &save_ptr))) {
+            LERROR << "Error parsing mount_point";
+            goto err;
+        }
+        entry.mount_point = p;
+
+        if (!(p = strtok_r(NULL, delim, &save_ptr))) {
+            LERROR << "Error parsing fs_type";
+            goto err;
+        }
+        entry.fs_type = p;
+
+        if (!(p = strtok_r(NULL, delim, &save_ptr))) {
+            LERROR << "Error parsing mount_flags";
             goto err;
         }
 
-        FstabEntry entry;
-        auto it = fields.begin();
-
-        entry.blk_device = std::move(*it++);
-        entry.mount_point = std::move(*it++);
-        entry.fs_type = std::move(*it++);
-        ParseMountFlags(std::move(*it++), &entry);
+        ParseMountFlags(p, &entry);
 
         // For /proc/mounts, ignore everything after mnt_freq and mnt_passno
-        if (!proc_mounts && !ParseFsMgrFlags(std::move(*it++), &entry)) {
+        if (proc_mounts) {
+            p += strlen(p);
+        } else if (!(p = strtok_r(NULL, delim, &save_ptr))) {
+            LERROR << "Error parsing fs_mgr_options";
+            goto err;
+        }
+
+        if (!ParseFsMgrFlags(p, &entry)) {
             LERROR << "Error parsing fs_mgr_flags";
             goto err;
         }