Gediminas Ramanauskas | 2f0b885 | 2013-03-14 13:52:32 -0700 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 5 | #ifndef DEBUGD_SRC_STORAGE_TOOL_H_ |
| 6 | #define DEBUGD_SRC_STORAGE_TOOL_H_ |
Gediminas Ramanauskas | 2f0b885 | 2013-03-14 13:52:32 -0700 | [diff] [blame] | 7 | |
| 8 | #include <string> |
Alexis Savery | e39d349 | 2017-11-07 18:10:08 -0800 | [diff] [blame] | 9 | #include <vector> |
Gediminas Ramanauskas | 2f0b885 | 2013-03-14 13:52:32 -0700 | [diff] [blame] | 10 | |
Alexis Savery | e39d349 | 2017-11-07 18:10:08 -0800 | [diff] [blame] | 11 | #include <base/files/file_path.h> |
Eric Caruso | 0b24188 | 2018-04-04 13:43:46 -0700 | [diff] [blame] | 12 | #include <base/files/scoped_file.h> |
Ben Chan | 657bed8 | 2014-09-02 20:40:51 -0700 | [diff] [blame] | 13 | #include <base/macros.h> |
Gediminas Ramanauskas | 2f0b885 | 2013-03-14 13:52:32 -0700 | [diff] [blame] | 14 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 15 | #include "debugd/src/subprocess_tool.h" |
Gediminas Ramanauskas | 2f0b885 | 2013-03-14 13:52:32 -0700 | [diff] [blame] | 16 | |
| 17 | namespace debugd { |
| 18 | |
| 19 | class StorageTool : public SubprocessTool { |
| 20 | public: |
Ben Chan | 78f8953 | 2014-08-29 09:35:09 -0700 | [diff] [blame] | 21 | StorageTool() = default; |
| 22 | ~StorageTool() override = default; |
Gediminas Ramanauskas | 2f0b885 | 2013-03-14 13:52:32 -0700 | [diff] [blame] | 23 | |
Eric Caruso | c93a15c | 2017-04-24 16:15:12 -0700 | [diff] [blame] | 24 | std::string Smartctl(const std::string& option); |
Eric Caruso | 0b24188 | 2018-04-04 13:43:46 -0700 | [diff] [blame] | 25 | std::string Start(const base::ScopedFD& outfd); |
Alexis Savery | e39d349 | 2017-11-07 18:10:08 -0800 | [diff] [blame] | 26 | const base::FilePath GetDevice(const base::FilePath& filesystem, |
| 27 | const base::FilePath& mountsFile); |
| 28 | bool IsSupported(const base::FilePath typeFile, |
| 29 | const base::FilePath vendFile, |
| 30 | std::string* errorMsg); |
Ting Shen | 92dd783 | 2018-12-21 17:45:07 +0800 | [diff] [blame] | 31 | std::string Mmc(const std::string& option); |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame] | 32 | |
Gediminas Ramanauskas | 2f0b885 | 2013-03-14 13:52:32 -0700 | [diff] [blame] | 33 | private: |
Alexis Savery | e39d349 | 2017-11-07 18:10:08 -0800 | [diff] [blame] | 34 | // Returns the partition of |dst| as a string. |dst| is expected |
| 35 | // to be a storage device path (e.g. "/dev/sda1"). |
| 36 | const std::string GetPartition(const std::string& dst); |
| 37 | |
| 38 | // Removes the partition from |dstPath| which is expected |
| 39 | // to be a storage device path (e.g. "/dev/mmcblk1p2"). |
| 40 | void StripPartition(base::FilePath* dstPath); |
| 41 | |
Gediminas Ramanauskas | 2f0b885 | 2013-03-14 13:52:32 -0700 | [diff] [blame] | 42 | DISALLOW_COPY_AND_ASSIGN(StorageTool); |
| 43 | }; |
| 44 | |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame] | 45 | } // namespace debugd |
Gediminas Ramanauskas | 2f0b885 | 2013-03-14 13:52:32 -0700 | [diff] [blame] | 46 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 47 | #endif // DEBUGD_SRC_STORAGE_TOOL_H_ |