blob: 9eb2a544f9de90b7ef643820d2635318c7c2b729 [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_MOUNTER_H_
6#define CROS_DISKS_MOUNTER_H_
7
Sergei Datsenko3cf72cb2019-04-01 11:27:50 +11008#include <memory>
Ben Chane31d2aa2011-06-15 13:52:59 -07009#include <string>
Sergei Datsenko3cf72cb2019-04-01 11:27:50 +110010#include <vector>
Ben Chane31d2aa2011-06-15 13:52:59 -070011
Sergei Datsenko3cf72cb2019-04-01 11:27:50 +110012#include <base/files/file_path.h>
Ben Chanfcb2fc02011-11-21 09:44:07 -080013#include <chromeos/dbus/service_constants.h>
Ben Chane31d2aa2011-06-15 13:52:59 -070014
Ben Chan5ccd9fe2013-11-13 18:28:27 -080015#include "cros-disks/mount_options.h"
Ben Chane31d2aa2011-06-15 13:52:59 -070016
17namespace cros_disks {
18
Sergei Datsenko3cf72cb2019-04-01 11:27:50 +110019class MountPoint;
20
Sergei Datsenko3cf72cb2019-04-01 11:27:50 +110021// Interface for mounting a given filesystem.
Ben Chane31d2aa2011-06-15 13:52:59 -070022class Mounter {
23 public:
Sergei Datsenko58ef4b22020-11-14 23:57:00 +110024 Mounter() = default;
Qijiang Fan6bc59e12020-11-11 02:51:06 +090025 Mounter(const Mounter&) = delete;
26 Mounter& operator=(const Mounter&) = delete;
Sergei Datsenko58ef4b22020-11-14 23:57:00 +110027 virtual ~Mounter() = default;
Ben Chane31d2aa2011-06-15 13:52:59 -070028
Sergei Datsenko3cf72cb2019-04-01 11:27:50 +110029 // Mounts the filesystem. On failure returns nullptr and |error| is
Sergei Datsenkoe8faba52020-10-06 21:45:22 +110030 // set accordingly. Both |source| and |params| are just some strings
Sergei Datsenko3cf72cb2019-04-01 11:27:50 +110031 // that can be interpreted by this mounter.
32 virtual std::unique_ptr<MountPoint> Mount(const std::string& source,
33 const base::FilePath& target_path,
Sergei Datsenkoe8faba52020-10-06 21:45:22 +110034 std::vector<std::string> params,
Sergei Datsenko3cf72cb2019-04-01 11:27:50 +110035 MountErrorType* error) const = 0;
36
37 // Whether this mounter is able to mount given |source| with provided
Sergei Datsenkoe8faba52020-10-06 21:45:22 +110038 // |params|. If so - it may suggest a directory name for the mount point
Sergei Datsenko3cf72cb2019-04-01 11:27:50 +110039 // to be created. Note that in many cases it's impossible to tell beforehand
40 // if the particular source is mountable so it may blanketly return true for
41 // any arguments.
42 virtual bool CanMount(const std::string& source,
Sergei Datsenkoe8faba52020-10-06 21:45:22 +110043 const std::vector<std::string>& params,
Sergei Datsenko3cf72cb2019-04-01 11:27:50 +110044 base::FilePath* suggested_dir_name) const = 0;
Sergei Datsenko3cf72cb2019-04-01 11:27:50 +110045};
46
Ben Chane31d2aa2011-06-15 13:52:59 -070047
48} // namespace cros_disks
49
50#endif // CROS_DISKS_MOUNTER_H_