Anand K Mistry | 110478e | 2019-10-29 15:24:11 +1100 | [diff] [blame] | 1 | // Copyright 2019 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_SMBFS_HELPER_H_ |
| 6 | #define CROS_DISKS_SMBFS_HELPER_H_ |
| 7 | |
| 8 | #include <memory> |
| 9 | #include <string> |
| 10 | #include <vector> |
| 11 | |
Sergei Datsenko | 44612ac | 2020-11-30 09:35:56 +1100 | [diff] [blame] | 12 | #include "cros-disks/fuse_mounter.h" |
Anand K Mistry | 110478e | 2019-10-29 15:24:11 +1100 | [diff] [blame] | 13 | |
| 14 | namespace cros_disks { |
| 15 | |
| 16 | class Platform; |
| 17 | |
| 18 | // A helper for mounting SmbFs. |
| 19 | // |
| 20 | // SmbFs URIs are of the form: |
| 21 | // smbfs://mojo_id |
| 22 | // |
| 23 | // |mojo_id| is an opaque string, which is the string representation of a |
| 24 | // base::UnguessableToken created by calling base::UnguessableToken::ToString(). |
| 25 | // It is used to bootstrap a Mojo IPC connection to Chrome. |
Sergei Datsenko | 44612ac | 2020-11-30 09:35:56 +1100 | [diff] [blame] | 26 | class SmbfsHelper : public FUSEMounterHelper { |
Anand K Mistry | 110478e | 2019-10-29 15:24:11 +1100 | [diff] [blame] | 27 | public: |
| 28 | SmbfsHelper(const Platform* platform, brillo::ProcessReaper* process_reaper); |
Qijiang Fan | 6bc59e1 | 2020-11-11 02:51:06 +0900 | [diff] [blame] | 29 | SmbfsHelper(const SmbfsHelper&) = delete; |
| 30 | SmbfsHelper& operator=(const SmbfsHelper&) = delete; |
| 31 | |
Anand K Mistry | 110478e | 2019-10-29 15:24:11 +1100 | [diff] [blame] | 32 | ~SmbfsHelper() override; |
| 33 | |
Sergei Datsenko | 44612ac | 2020-11-30 09:35:56 +1100 | [diff] [blame] | 34 | bool CanMount(const std::string& source, |
| 35 | const std::vector<std::string>& params, |
| 36 | base::FilePath* suggested_name) const override; |
| 37 | |
| 38 | protected: |
| 39 | MountErrorType ConfigureSandbox(const std::string& source, |
| 40 | const base::FilePath& target_path, |
| 41 | std::vector<std::string> params, |
| 42 | SandboxedProcess* sandbox) const override; |
Anand K Mistry | 110478e | 2019-10-29 15:24:11 +1100 | [diff] [blame] | 43 | |
| 44 | private: |
Sergei Datsenko | 44612ac | 2020-11-30 09:35:56 +1100 | [diff] [blame] | 45 | const FUSESandboxedProcessFactory sandbox_factory_; |
| 46 | |
Anand K Mistry | 110478e | 2019-10-29 15:24:11 +1100 | [diff] [blame] | 47 | friend class SmbfsHelperTest; |
Anand K Mistry | 110478e | 2019-10-29 15:24:11 +1100 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | } // namespace cros_disks |
| 51 | |
| 52 | #endif // CROS_DISKS_SMBFS_HELPER_H_ |