-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharchive_manager.h
64 lines (48 loc) · 1.9 KB
/
archive_manager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CROS_DISKS_ARCHIVE_MANAGER_H_
#define CROS_DISKS_ARCHIVE_MANAGER_H_
#include <map>
#include <memory>
#include <string>
#include <vector>
#include <brillo/scoped_mount_namespace.h>
#include <gtest/gtest_prod.h>
#include "cros-disks/mount_manager.h"
#include "cros-disks/mount_options.h"
namespace cros_disks {
// A derived class of MountManager for mounting archive files as a virtual
// filesystem.
class ArchiveManager : public MountManager {
public:
using MountManager::MountManager;
// MountManager overrides
MountSourceType GetMountSourceType() const final {
return MOUNT_SOURCE_ARCHIVE;
}
bool ResolvePath(const std::string& path, std::string* real_path) final;
std::string SuggestMountPath(const std::string& source_path) const final;
// Checks if the given file path is in an allowed location to be mounted as an
// archive. The following paths can be mounted:
//
// /home/chronos/u-<user-id>/MyFiles/...<file>
// /media/archive/<dir>/...<file>
// /media/fuse/<dir>/...<file>
// /media/removable/<dir>/...<file>
// /run/arc/sdcard/write/emulated/0/<dir>/...<file>
static bool IsInAllowedFolder(const std::string& source_path);
// Gets a list of supplementary group IDs the FUSE mounter program should run
// with in order to access files in all the required locations.
std::vector<gid_t> GetSupplementaryGroups() const;
// Gets FUSE mount options.
MountErrorType GetMountOptions(MountOptions* options) const;
protected:
struct MountNamespace {
std::unique_ptr<brillo::ScopedMountNamespace> guard;
std::string name;
};
static MountNamespace GetMountNamespaceFor(const std::string& path);
};
} // namespace cros_disks
#endif // CROS_DISKS_ARCHIVE_MANAGER_H_