2 * Copyright (C) 2016 The Android Open Source Project
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #ifndef __LINKER_NAMESPACES_H
30 #define __LINKER_NAMESPACES_H
32 #include "linker_common_types.h"
37 struct android_namespace_t {
39 android_namespace_t() : name_(nullptr), is_isolated_(false) {}
41 const char* get_name() const { return name_; }
42 void set_name(const char* name) { name_ = name; }
44 bool is_isolated() const { return is_isolated_; }
45 void set_isolated(bool isolated) { is_isolated_ = isolated; }
47 const std::vector<std::string>& get_ld_library_paths() const {
48 return ld_library_paths_;
50 void set_ld_library_paths(std::vector<std::string>&& library_paths) {
51 ld_library_paths_ = library_paths;
54 const std::vector<std::string>& get_default_library_paths() const {
55 return default_library_paths_;
57 void set_default_library_paths(std::vector<std::string>&& library_paths) {
58 default_library_paths_ = library_paths;
61 const std::vector<std::string>& get_permitted_paths() const {
62 return permitted_paths_;
64 void set_permitted_paths(std::vector<std::string>&& permitted_paths) {
65 permitted_paths_ = permitted_paths;
68 void add_soinfo(soinfo* si) {
69 soinfo_list_.push_back(si);
72 void add_soinfos(const soinfo_list_t& soinfos) {
73 for (auto si : soinfos) {
78 void remove_soinfo(soinfo* si) {
79 soinfo_list_.remove_if([&](soinfo* candidate) {
80 return si == candidate;
84 const soinfo_list_t& soinfo_list() const { return soinfo_list_; }
86 // For isolated namespaces - checks if the file is on the search path;
87 // always returns true for not isolated namespace.
88 bool is_accessible(const std::string& path);
93 std::vector<std::string> ld_library_paths_;
94 std::vector<std::string> default_library_paths_;
95 std::vector<std::string> permitted_paths_;
96 soinfo_list_t soinfo_list_;
98 DISALLOW_COPY_AND_ASSIGN(android_namespace_t);
101 #endif /* __LINKER_NAMESPACES_H */