blob: 211c679d211bcbdd174e27817fb431f25b642538 [file] [log] [blame]
Ben Chane31d2aa2011-06-15 13:52:59 -07001// Copyright (c) 2011 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
5#ifndef CROS_DISKS_SYSTEM_MOUNTER_H_
6#define CROS_DISKS_SYSTEM_MOUNTER_H_
7
Sergei Datsenko85a18332019-04-08 14:25:03 +10008#include <memory>
Ben Chan190d3cf2011-07-07 09:38:48 -07009#include <string>
Sergei Datsenko85a18332019-04-08 14:25:03 +100010#include <vector>
Ben Chan190d3cf2011-07-07 09:38:48 -070011
Sam McNallyc56ae312018-05-22 13:14:27 +100012#include <base/macros.h>
13
Sergei Datsenko85a18332019-04-08 14:25:03 +100014#include "cros-disks/mount_point.h"
Ben Chane31d2aa2011-06-15 13:52:59 -070015#include "cros-disks/mounter.h"
Sergei Datsenkoe8faba52020-10-06 21:45:22 +110016#include "cros-disks/platform.h"
Ben Chane31d2aa2011-06-15 13:52:59 -070017
18namespace cros_disks {
19
Sergei Datsenko85a18332019-04-08 14:25:03 +100020// A class for mounting a device file using the system mount() call.
21class SystemMounter : public Mounter {
22 public:
Sergei Datsenkoe8faba52020-10-06 21:45:22 +110023 SystemMounter(const Platform* platform,
24 std::string filesystem_type,
25 bool read_only,
26 std::vector<std::string> options);
Qijiang Fan6bc59e12020-11-11 02:51:06 +090027 SystemMounter(const SystemMounter&) = delete;
28 SystemMounter& operator=(const SystemMounter&) = delete;
29
Sergei Datsenko85a18332019-04-08 14:25:03 +100030 ~SystemMounter() override;
31
Sergei Datsenkoe8faba52020-10-06 21:45:22 +110032 const std::string& filesystem_type() const { return filesystem_type_; }
33 bool read_only() const { return (flags_ & MS_RDONLY) == MS_RDONLY; }
34 const std::vector<std::string>& options() const { return options_; }
35
Ben Chane31d2aa2011-06-15 13:52:59 -070036 // Mounts a device file using the system mount() call.
Sergei Datsenko85a18332019-04-08 14:25:03 +100037 std::unique_ptr<MountPoint> Mount(const std::string& source,
38 const base::FilePath& target_path,
Sergei Datsenkoe8faba52020-10-06 21:45:22 +110039 std::vector<std::string> params,
Sergei Datsenko85a18332019-04-08 14:25:03 +100040 MountErrorType* error) const override;
41
42 // As there is no way to figure out beforehand if that would work, always
43 // returns true, so this mounter is a "catch-all".
44 bool CanMount(const std::string& source,
Sergei Datsenkoe8faba52020-10-06 21:45:22 +110045 const std::vector<std::string>& params,
Sergei Datsenko85a18332019-04-08 14:25:03 +100046 base::FilePath* suggested_dir_name) const override;
Sam McNallyc56ae312018-05-22 13:14:27 +100047
48 private:
49 const Platform* const platform_;
Sergei Datsenkoe8faba52020-10-06 21:45:22 +110050 const std::string filesystem_type_;
51 const int flags_;
52 const std::vector<std::string> options_;
Ben Chane31d2aa2011-06-15 13:52:59 -070053};
54
55} // namespace cros_disks
56
57#endif // CROS_DISKS_SYSTEM_MOUNTER_H_