blob: f7502a9b6a8b75a184a035e78ad982dc750d7bdf [file] [log] [blame]
Vic Yange01ca4d2019-05-29 15:58:32 -07001/*
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
29namespace android {
30namespace init {
31
32struct NamespaceInfo {
33 unsigned flags;
34 // Pair of namespace type, path to name.
35 std::vector<std::pair<int, std::string>> namespaces_to_enter;
36};
37Result<Success> EnterNamespaces(const NamespaceInfo& info, const std::string& name, bool pre_apexd);
38
39struct 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};
49Result<Success> SetProcessAttributes(const ProcessAttributes& attr);
50
51Result<Success> WritePidToFiles(std::vector<std::string>* files);
52
53} // namespace init
54} // namespace android