blob: 71663502196b070236480b9557b8f27e4744eea6 [file] [log] [blame]
Sam McNallyc56ae312018-05-22 13:14:27 +10001// Copyright 2018 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_DRIVEFS_HELPER_H_
6#define CROS_DISKS_DRIVEFS_HELPER_H_
7
8#include <memory>
9#include <string>
10#include <vector>
11
Sergei Datsenkof5553d12020-11-25 07:51:59 +110012#include "cros-disks/fuse_mounter.h"
Sam McNallyc56ae312018-05-22 13:14:27 +100013
14namespace cros_disks {
15
16class Platform;
17
Sergei Datsenkof5553d12020-11-25 07:51:59 +110018// A mounter for DriveFS.
Sam McNallyc56ae312018-05-22 13:14:27 +100019//
20// DriveFS URIs are of the form:
21// drivefs://identity
22//
Sam McNallyc56ae312018-05-22 13:14:27 +100023// |identity| is an opaque string. In particular it's a string representation of
24// a base::UnguessableToken, used to lookup a pending DriveFS mount in Chrome.
Sergei Datsenkof5553d12020-11-25 07:51:59 +110025//
26// The datadir option is required. It is the path DriveFS should use for its
27// data. It must be an absolute path without parent directory references.
28class DrivefsHelper : public FUSEMounterHelper {
Sam McNallyc56ae312018-05-22 13:14:27 +100029 public:
Sergei Datsenkoa910bba2019-06-18 13:31:59 +100030 DrivefsHelper(const Platform* platform,
31 brillo::ProcessReaper* process_reaper);
Qijiang Fan6bc59e12020-11-11 02:51:06 +090032 DrivefsHelper(const DrivefsHelper&) = delete;
33 DrivefsHelper& operator=(const DrivefsHelper&) = delete;
34
Sam McNallyc56ae312018-05-22 13:14:27 +100035 ~DrivefsHelper() override;
36
Sergei Datsenkof5553d12020-11-25 07:51:59 +110037 bool CanMount(const std::string& source,
38 const std::vector<std::string>& params,
39 base::FilePath* suggested_name) const override;
Sam McNallyc56ae312018-05-22 13:14:27 +100040
41 protected:
Sergei Datsenkof5553d12020-11-25 07:51:59 +110042 MountErrorType ConfigureSandbox(const std::string& source,
43 const base::FilePath& target_path,
44 std::vector<std::string> params,
45 SandboxedProcess* sandbox) const override;
Sam McNallydd0ff982019-06-12 18:18:36 +100046
Sam McNallyc56ae312018-05-22 13:14:27 +100047 private:
Sergei Datsenkof5553d12020-11-25 07:51:59 +110048 const FUSESandboxedProcessFactory sandbox_factory_;
Sam McNallyc56ae312018-05-22 13:14:27 +100049
Sergei Datsenkof5553d12020-11-25 07:51:59 +110050 friend class DrivefsHelperTest;
Sam McNallyc56ae312018-05-22 13:14:27 +100051};
52
53} // namespace cros_disks
54
55#endif // CROS_DISKS_DRIVEFS_HELPER_H_