hwid_override.cc revision 06c76a49bfd29c8abdb8abd5b646a6583783191a
1f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone// Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 2f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone// Use of this source code is governed by a BSD-style license that can be 3f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone// found in the LICENSE file. 4f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone 5f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone#include "update_engine/hwid_override.h" 6f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone 7f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone#include <map> 8f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone#include <string> 9f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone 1075039d7397f03dff77bdf4e26398049ff88edc4cAlex Vakulenko#include <base/files/file_path.h> 1106c76a49bfd29c8abdb8abd5b646a6583783191aBen Chan#include <base/files/file_util.h> 12f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone 13f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone#include "update_engine/simple_key_value_store.h" 14f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone 15f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masoneusing std::map; 16f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masoneusing std::string; 17f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone 18f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masonenamespace chromeos_update_engine { 19f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone 20f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masoneconst char HwidOverride::kHwidOverrideKey[] = "HWID_OVERRIDE"; 21f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone 22f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris MasoneHwidOverride::HwidOverride() {} 23f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone 24f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris MasoneHwidOverride::~HwidOverride() {} 25f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone 26f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masonestd::string HwidOverride::Read(const base::FilePath& root) { 27a7658449213d3141ff11e4aee3531fa35ba0970dAlex Deymo KeyValueStore lsb_release; 28a7658449213d3141ff11e4aee3531fa35ba0970dAlex Deymo lsb_release.Load(root.value() + "/etc/lsb-release"); 29a7658449213d3141ff11e4aee3531fa35ba0970dAlex Deymo string result; 30a7658449213d3141ff11e4aee3531fa35ba0970dAlex Deymo if (lsb_release.GetString(kHwidOverrideKey, &result)) 31a7658449213d3141ff11e4aee3531fa35ba0970dAlex Deymo return result; 32a7658449213d3141ff11e4aee3531fa35ba0970dAlex Deymo return ""; 33f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone} 34f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone 35f8d037f5c506770adbe874f0eefa1e5e5abf4140Chris Masone} // namespace chromeos_update_engine 36