update_engine: added partition name manipulation library methods

Added utility methods to split and merge partition device names
to help "semi-intelligently" break down full partition device
name into disk name and partition name and merge them back.

With special handling for MMC devices and similar.

Also removed inconsistent naming for the disk and partition
device names (such as "boot device", "root device", etc).
Now device names such as "/dev/sda" are referred to as
"disk name" and "/dev/sda1" as "partition name").

BUG=None
TEST=Updated and ran unit tests

Change-Id: Ica41b8c99f0120799be326af0b41324639c5cf6a
Reviewed-on: https://chromium-review.googlesource.com/187453
Commit-Queue: Alex Vakulenko <[email protected]>
Tested-by: Alex Vakulenko <[email protected]>
Reviewed-by: Don Garrett <[email protected]>
diff --git a/payload_state.cc b/payload_state.cc
index a23b545..7505b96 100644
--- a/payload_state.cc
+++ b/payload_state.cc
@@ -1166,13 +1166,13 @@
   // payload was marked as ready immediately before the last reboot, and we
   // need to check if such payload successfully rebooted or not.
   if (prefs_->Exists(kPrefsTargetVersionInstalledFrom)) {
-    string installed_from;
-    if (!prefs_->GetString(kPrefsTargetVersionInstalledFrom, &installed_from)) {
+    int64_t installed_from = 0;
+    if (!prefs_->GetInt64(kPrefsTargetVersionInstalledFrom, &installed_from)) {
       LOG(ERROR) << "Error reading TargetVersionInstalledFrom on reboot.";
       return;
     }
-    if (installed_from ==
-        utils::PartitionNumber(system_state_->hardware()->BootDevice())) {
+    if (int(installed_from) ==
+        utils::GetPartitionNumber(system_state_->hardware()->BootDevice())) {
       // A reboot was pending, but the chromebook is again in the same
       // BootDevice where the update was installed from.
       int64_t target_attempt;
@@ -1221,8 +1221,8 @@
   }
   prefs_->SetInt64(kPrefsTargetVersionAttempt, target_attempt + 1);
 
-  prefs_->SetString(kPrefsTargetVersionInstalledFrom,
-                    utils::PartitionNumber(
+  prefs_->SetInt64(kPrefsTargetVersionInstalledFrom,
+                    utils::GetPartitionNumber(
                         system_state_->hardware()->BootDevice()));
 }