Ben Chan | e31d2aa | 2011-06-15 13:52:59 -0700 | [diff] [blame] | 1 | // 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 Datsenko | 3cf72cb | 2019-04-01 11:27:50 +1100 | [diff] [blame] | 8 | #include <memory> |
Ben Chan | e31d2aa | 2011-06-15 13:52:59 -0700 | [diff] [blame] | 9 | #include <string> |
Sergei Datsenko | 3cf72cb | 2019-04-01 11:27:50 +1100 | [diff] [blame] | 10 | #include <vector> |
Ben Chan | e31d2aa | 2011-06-15 13:52:59 -0700 | [diff] [blame] | 11 | |
Sergei Datsenko | 3cf72cb | 2019-04-01 11:27:50 +1100 | [diff] [blame] | 12 | #include <base/files/file_path.h> |
Ben Chan | fcb2fc0 | 2011-11-21 09:44:07 -0800 | [diff] [blame] | 13 | #include <chromeos/dbus/service_constants.h> |
Ben Chan | e31d2aa | 2011-06-15 13:52:59 -0700 | [diff] [blame] | 14 | |
Ben Chan | 5ccd9fe | 2013-11-13 18:28:27 -0800 | [diff] [blame] | 15 | #include "cros-disks/mount_options.h" |
Ben Chan | e31d2aa | 2011-06-15 13:52:59 -0700 | [diff] [blame] | 16 | |
| 17 | namespace cros_disks { |
| 18 | |
Sergei Datsenko | 3cf72cb | 2019-04-01 11:27:50 +1100 | [diff] [blame] | 19 | class MountPoint; |
| 20 | |
Sergei Datsenko | 3cf72cb | 2019-04-01 11:27:50 +1100 | [diff] [blame] | 21 | // Interface for mounting a given filesystem. |
Ben Chan | e31d2aa | 2011-06-15 13:52:59 -0700 | [diff] [blame] | 22 | class Mounter { |
| 23 | public: |
Sergei Datsenko | 58ef4b2 | 2020-11-14 23:57:00 +1100 | [diff] [blame] | 24 | Mounter() = default; |
Qijiang Fan | 6bc59e1 | 2020-11-11 02:51:06 +0900 | [diff] [blame] | 25 | Mounter(const Mounter&) = delete; |
| 26 | Mounter& operator=(const Mounter&) = delete; |
Sergei Datsenko | 58ef4b2 | 2020-11-14 23:57:00 +1100 | [diff] [blame] | 27 | virtual ~Mounter() = default; |
Ben Chan | e31d2aa | 2011-06-15 13:52:59 -0700 | [diff] [blame] | 28 | |
Sergei Datsenko | 3cf72cb | 2019-04-01 11:27:50 +1100 | [diff] [blame] | 29 | // Mounts the filesystem. On failure returns nullptr and |error| is |
Sergei Datsenko | e8faba5 | 2020-10-06 21:45:22 +1100 | [diff] [blame] | 30 | // set accordingly. Both |source| and |params| are just some strings |
Sergei Datsenko | 3cf72cb | 2019-04-01 11:27:50 +1100 | [diff] [blame] | 31 | // 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 Datsenko | e8faba5 | 2020-10-06 21:45:22 +1100 | [diff] [blame] | 34 | std::vector<std::string> params, |
Sergei Datsenko | 3cf72cb | 2019-04-01 11:27:50 +1100 | [diff] [blame] | 35 | MountErrorType* error) const = 0; |
| 36 | |
| 37 | // Whether this mounter is able to mount given |source| with provided |
Sergei Datsenko | e8faba5 | 2020-10-06 21:45:22 +1100 | [diff] [blame] | 38 | // |params|. If so - it may suggest a directory name for the mount point |
Sergei Datsenko | 3cf72cb | 2019-04-01 11:27:50 +1100 | [diff] [blame] | 39 | // 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 Datsenko | e8faba5 | 2020-10-06 21:45:22 +1100 | [diff] [blame] | 43 | const std::vector<std::string>& params, |
Sergei Datsenko | 3cf72cb | 2019-04-01 11:27:50 +1100 | [diff] [blame] | 44 | base::FilePath* suggested_dir_name) const = 0; |
Sergei Datsenko | 3cf72cb | 2019-04-01 11:27:50 +1100 | [diff] [blame] | 45 | }; |
| 46 | |
Ben Chan | e31d2aa | 2011-06-15 13:52:59 -0700 | [diff] [blame] | 47 | |
| 48 | } // namespace cros_disks |
| 49 | |
| 50 | #endif // CROS_DISKS_MOUNTER_H_ |