blob: 680eaf05c2c2ec52126e5317d1e073bb46025fe6 [file] [log] [blame]
Gediminas Ramanauskas2f0b8852013-03-14 13:52:32 -07001// 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 Vakulenko262be3f2014-07-30 15:25:50 -07005#ifndef DEBUGD_SRC_STORAGE_TOOL_H_
6#define DEBUGD_SRC_STORAGE_TOOL_H_
Gediminas Ramanauskas2f0b8852013-03-14 13:52:32 -07007
8#include <string>
Alexis Saverye39d3492017-11-07 18:10:08 -08009#include <vector>
Gediminas Ramanauskas2f0b8852013-03-14 13:52:32 -070010
Alexis Saverye39d3492017-11-07 18:10:08 -080011#include <base/files/file_path.h>
Eric Caruso0b241882018-04-04 13:43:46 -070012#include <base/files/scoped_file.h>
Ben Chan657bed82014-09-02 20:40:51 -070013#include <base/macros.h>
Gediminas Ramanauskas2f0b8852013-03-14 13:52:32 -070014
Alex Vakulenko262be3f2014-07-30 15:25:50 -070015#include "debugd/src/subprocess_tool.h"
Gediminas Ramanauskas2f0b8852013-03-14 13:52:32 -070016
17namespace debugd {
18
19class StorageTool : public SubprocessTool {
20 public:
Ben Chan78f89532014-08-29 09:35:09 -070021 StorageTool() = default;
22 ~StorageTool() override = default;
Gediminas Ramanauskas2f0b8852013-03-14 13:52:32 -070023
Eric Carusoc93a15c2017-04-24 16:15:12 -070024 std::string Smartctl(const std::string& option);
Eric Caruso0b241882018-04-04 13:43:46 -070025 std::string Start(const base::ScopedFD& outfd);
Alexis Saverye39d3492017-11-07 18:10:08 -080026 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 Shen92dd7832018-12-21 17:45:07 +080031 std::string Mmc(const std::string& option);
Ben Chana0011d82014-05-13 00:19:29 -070032
Gediminas Ramanauskas2f0b8852013-03-14 13:52:32 -070033 private:
Alexis Saverye39d3492017-11-07 18:10:08 -080034 // 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 Ramanauskas2f0b8852013-03-14 13:52:32 -070042 DISALLOW_COPY_AND_ASSIGN(StorageTool);
43};
44
Ben Chana0011d82014-05-13 00:19:29 -070045} // namespace debugd
Gediminas Ramanauskas2f0b8852013-03-14 13:52:32 -070046
Alex Vakulenko262be3f2014-07-30 15:25:50 -070047#endif // DEBUGD_SRC_STORAGE_TOOL_H_