Android-cuttlefish cvd tool
system_image_dir_path_resolution.h
Go to the documentation of this file.
1//
2// Copyright (C) 2026 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#pragma once
17
18#include <string>
19#include <string_view>
20
22
23namespace cuttlefish {
24
25// Resolution of a config / command line argument that accepts a path in
26// system_image_dir or an absolute path.
27//
28// Shared rules for all three helpers below:
29// * An empty value means "not set" and is returned unchanged.
30// * A path beginning with '/' is already absolute: it is returned unchanged.
31// * A relative path is joined as "<system_image_dir>/<path>" is checked for
32// existence, otherwise an error naming the resolved absolute path is
33// returned.
34Result<std::string> ResolveSystemImageDirPath(std::string_view value,
35 std::string_view system_image_dir,
36 std::string_view flag_name);
37
38// Resolves the path in --device-tree-overlay for passing to crosvm
39// The expected value should be in the same format as crosvm's
40// device-tree-overlay command line argument:
41// "PATH[,filter][,select-symbols=[xxx,yyy]]".
42// Only the first part (PATH) is checked and rewritten.
43Result<std::string> ResolveCrosvmDeviceTreeOverlayPath(
44 std::string_view value, std::string_view system_image_dir);
45
46// Resolves the path in --file-backed-mapping for passing to crosvm.
47// The expected value should be in the same format as crosvm's
48// file-backed-mapping command line argument: "path=X,addr=0x...,size=0x...".
49// Only the value of the `path=` token is checked and rewritten, others are
50// untouched.
51Result<std::string> ResolveCrosvmFileBackedMappingPath(
52 std::string_view value, std::string_view system_image_dir);
53
54} // namespace cuttlefish
Definition: alloc_driver.h:21
Result< std::string > ResolveSystemImageDirPath(std::string_view value, std::string_view system_image_dir, std::string_view flag_name)
Definition: system_image_dir_path_resolution.cc:39
Result< std::string > ResolveCrosvmDeviceTreeOverlayPath(std::string_view value, std::string_view system_image_dir)
Definition: system_image_dir_path_resolution.cc:53
Result< std::string > ResolveCrosvmFileBackedMappingPath(std::string_view value, std::string_view system_image_dir)
Definition: system_image_dir_path_resolution.cc:80