1 /*
2  * Copyright (c) 2023 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 INIT_ERROR_H
17 #define INIT_ERROR_H
18 
19 #include "beget_ext.h"
20 
21 #ifdef __cplusplus
22 #if __cplusplus
23 extern "C" {
24 #endif
25 #endif
26 
27 /* Expand this list if necessary. */
28 #define INIT_ERRNO_MAP(XX)                  \
29     XX(EPARAMETER, "Invalid parameter")     \
30     XX(EFORMAT, "Format string fail")       \
31     XX(ECFG, "cfg error")                   \
32     XX(EPATH, "Invalid path")               \
33     XX(EFORK, "Fork fail")                  \
34     XX(ESANDBOX, "Create sandbox fail")     \
35     XX(EACCESSTOKEN, "Set access token fail")   \
36     XX(ESOCKET, "Create socket fail")       \
37     XX(EFILE, "Create file fail")           \
38     XX(ECONSOLE, "Open console fail")       \
39     XX(EHOLDER, "Publish holder fail")      \
40     XX(EBINDCORE, "Bind core fail")         \
41     XX(EKEEPCAP, "Set keep capability fail")    \
42     XX(EGIDSET, "Set gid fail")             \
43     XX(ESECCOMP, "Set SECCOMP fail")        \
44     XX(EUIDSET, "Set uid fail")             \
45     XX(ECAP, "Set capability fail")         \
46     XX(EWRITEPID, "Write pid fail")         \
47     XX(ECONTENT, "Set sub content fail")    \
48     XX(EPRIORITY, "Set priority fail")      \
49     XX(EEXEC_CONTENT, "Set exec content fail")  \
50     XX(EEXEC, "Exec fail")
51 
52 typedef enum {
53     INIT_OK,
54 #define XX(code, _) INIT_ ## code,
55     INIT_ERRNO_MAP(XX)
56 #undef XX
57 } InitErrno;
58 
59 struct InitErrMap {
60     int code;
61     const char *info;
62 } ;
63 
64 #ifdef __cplusplus
65 #if __cplusplus
66 }
67 #endif
68 #endif
69 #endif // INIT_UTILS_H
70