• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 
16 #ifndef BASE_STARTUP_INITLITE_SANDBOX_H
17 #define BASE_STARTUP_INITLITE_SANDBOX_H
18 
19 #include <stdbool.h>
20 #include "init_utils.h"
21 #include "list.h"
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 typedef enum SandboxTag {
27     SANDBOX_TAG_MOUNT_PATH = 0,
28     SANDBOX_TAG_MOUNT_FILE,
29     SANDBOX_TAG_SYMLINK
30 } SandboxTag;
31 
32 typedef struct MountList {
33     char *source;  // source 目录,一般是全局的fs 目录
34     char *target;  // 沙盒化后的目录
35     unsigned long flags;
36     bool ignoreErrors;
37     SandboxTag tag;
38     struct ListNode node;
39 } mountlist_t;
40 
41 typedef struct LinkList {
42     char *target;
43     char *linkName;
44     struct ListNode node;
45 } linklist_t;
46 
47 typedef struct {
48     ListNode pathMountsHead;
49     ListNode fileMountsHead;
50     ListNode linksHead;
51     char *rootPath; // /mnt/sandbox/system|vendor|xxx
52     char name[MAX_BUFFER_LEN]; // name of sandbox. i.e system, chipset etc.
53     bool isCreated; // sandbox already created or not
54     int ns; // namespace
55 } sandbox_t;
56 
57 bool InitSandboxWithName(const char *name);
58 int PrepareSandbox(const char *name);
59 int EnterSandbox(const char *name);
60 void DestroySandbox(const char *name);
61 void DumpSandboxByName(const char *name);
62 #ifdef __cplusplus
63 }
64 #endif
65 #endif
66