Vic Yang | e01ca4d | 2019-05-29 15:58:32 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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 | |
| 17 | #pragma once |
| 18 | |
| 19 | #include <sys/resource.h> |
| 20 | #include <sys/types.h> |
| 21 | |
| 22 | #include <string> |
| 23 | #include <vector> |
| 24 | |
| 25 | #include <cutils/iosched_policy.h> |
| 26 | |
| 27 | #include "result.h" |
| 28 | |
| 29 | namespace android { |
| 30 | namespace init { |
| 31 | |
| 32 | struct NamespaceInfo { |
| 33 | unsigned flags; |
| 34 | // Pair of namespace type, path to name. |
| 35 | std::vector<std::pair<int, std::string>> namespaces_to_enter; |
| 36 | }; |
Tom Cherry | bbcbc2f | 2019-06-10 11:08:01 -0700 | [diff] [blame] | 37 | Result<void> EnterNamespaces(const NamespaceInfo& info, const std::string& name, bool pre_apexd); |
Vic Yang | e01ca4d | 2019-05-29 15:58:32 -0700 | [diff] [blame] | 38 | |
| 39 | struct ProcessAttributes { |
| 40 | std::string console; |
| 41 | IoSchedClass ioprio_class; |
| 42 | int ioprio_pri; |
| 43 | std::vector<std::pair<int, rlimit>> rlimits; |
| 44 | uid_t uid; |
| 45 | gid_t gid; |
| 46 | std::vector<gid_t> supp_gids; |
| 47 | int priority; |
| 48 | }; |
Tom Cherry | bbcbc2f | 2019-06-10 11:08:01 -0700 | [diff] [blame] | 49 | Result<void> SetProcessAttributes(const ProcessAttributes& attr); |
Vic Yang | e01ca4d | 2019-05-29 15:58:32 -0700 | [diff] [blame] | 50 | |
Tom Cherry | bbcbc2f | 2019-06-10 11:08:01 -0700 | [diff] [blame] | 51 | Result<void> WritePidToFiles(std::vector<std::string>* files); |
Vic Yang | e01ca4d | 2019-05-29 15:58:32 -0700 | [diff] [blame] | 52 | |
| 53 | } // namespace init |
| 54 | } // namespace android |