blob: 365cb298b9b013ef82ccfcd67015c7b8080ec25a [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 {
Tom Cherry247ffbf2019-07-08 15:09:36 -070033 int flags;
Vic Yange01ca4d2019-05-29 15:58:32 -070034 // Pair of namespace type, path to name.
35 std::vector<std::pair<int, std::string>> namespaces_to_enter;
36};
Tom Cherrybbcbc2f2019-06-10 11:08:01 -070037Result<void> EnterNamespaces(const NamespaceInfo& info, const std::string& name, bool pre_apexd);
Vic Yange01ca4d2019-05-29 15:58:32 -070038
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};
Tom Cherrybbcbc2f2019-06-10 11:08:01 -070049Result<void> SetProcessAttributes(const ProcessAttributes& attr);
Vic Yange01ca4d2019-05-29 15:58:32 -070050
Tom Cherrybbcbc2f2019-06-10 11:08:01 -070051Result<void> WritePidToFiles(std::vector<std::string>* files);
Vic Yange01ca4d2019-05-29 15:58:32 -070052
53} // namespace init
54} // namespace android