blob: 374fc99cd7e74858da7021ac50022f47346b6dd4 [file] [log] [blame]
Daniil Lunevc063a1b2020-11-16 17:59:27 +11001// Copyright 2020 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 CRYPTOHOME_FILESYSTEM_LAYOUT_H_
6#define CRYPTOHOME_FILESYSTEM_LAYOUT_H_
7
Daniil Lunevb18fc802020-12-04 17:20:10 +11008#include <string>
9
Daniil Lunevc063a1b2020-11-16 17:59:27 +110010#include <base/files/file_path.h>
11#include <brillo/secure_blob.h>
12
13#include "cryptohome/crypto.h"
14#include "cryptohome/platform.h"
15
16namespace cryptohome {
17
Daniil Lunevb18fc802020-12-04 17:20:10 +110018// Name of the vault directory which is used with eCryptfs cryptohome.
19constexpr char kEcryptfsVaultDir[] = "vault";
20// Name of the mount directory.
21constexpr char kMountDir[] = "mount";
Sarthak Kukreti11e552e2021-01-11 02:23:49 -080022// Name of the temporary mount directory used during migration.
23constexpr char kTemporaryMountDir[] = "temporary_mount";
Sarthak Kukreti96fed762021-01-05 00:07:21 -080024// Name of the dm-crypt cache directory.
25constexpr char kDmcryptCacheDir[] = "cache";
26// Device Mapper directory.
27constexpr char kDeviceMapperDir[] = "/dev/mapper";
28
29// Suffix for cryptohome dm-crypt container.
30constexpr char kDmcryptCacheContainerSuffix[] = "cache";
31constexpr char kDmcryptDataContainerSuffix[] = "data";
Daniil Lunevb18fc802020-12-04 17:20:10 +110032
Daniil Lunevbc873f82020-12-07 13:30:51 +110033constexpr mode_t kKeyFilePermissions = 0600;
Hardik Goyalae019af2021-05-10 15:48:28 -070034constexpr int kKeyFileMax = 100; // master.0 ... master.99 // nocheck
35constexpr char kKeyFile[] = "master"; // nocheck
Daniil Lunevbc873f82020-12-07 13:30:51 +110036constexpr char kKeyLegacyPrefix[] = "legacy-";
37
38constexpr int kInitialKeysetIndex = 0;
39constexpr char kTsFile[] = "timestamp";
40
Sarthak Kukreti5817ce92021-02-01 16:56:00 -080041constexpr char kDmcryptContainerMountType[] = "ext4";
42constexpr char kDmcryptContainerMountOptions[] = "discard,commit=600";
43
Daniil Lunevb18fc802020-12-04 17:20:10 +110044base::FilePath ShadowRoot();
45base::FilePath SaltFile();
46base::FilePath SkelDir();
Daniil Lunevbc873f82020-12-07 13:30:51 +110047base::FilePath VaultKeysetPath(const std::string& obfuscated, int index);
48base::FilePath UserActivityTimestampPath(const std::string& obfuscated,
49 int index);
Daniil Lunevb18fc802020-12-04 17:20:10 +110050
Sarthak Kukreti96fed762021-01-05 00:07:21 -080051std::string LogicalVolumePrefix(const std::string& obfuscated_username);
52std::string DmcryptVolumePrefix(const std::string& obfuscated_username);
53
Daniil Lunevb18fc802020-12-04 17:20:10 +110054base::FilePath GetEcryptfsUserVaultPath(const std::string& obfuscated_username);
55base::FilePath GetUserMountDirectory(const std::string& obfuscated_username);
Sarthak Kukreti11e552e2021-01-11 02:23:49 -080056base::FilePath GetUserTemporaryMountDirectory(
57 const std::string& obfuscated_username);
Sarthak Kukreti96fed762021-01-05 00:07:21 -080058base::FilePath GetDmcryptUserCacheDirectory(
59 const std::string& obfuscated_username);
60base::FilePath GetDmcryptDataVolume(const std::string& obfuscated_username);
61base::FilePath GetDmcryptCacheVolume(const std::string& obfuscated_username);
Daniil Lunevc063a1b2020-11-16 17:59:27 +110062
63bool InitializeFilesystemLayout(Platform* platform,
64 Crypto* crypto,
Daniil Lunevc063a1b2020-11-16 17:59:27 +110065 brillo::SecureBlob* salt);
66
67} // namespace cryptohome
68
69#endif // CRYPTOHOME_FILESYSTEM_LAYOUT_H_