1 /*
2  * Copyright (c) 2021 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 #ifndef STORAGE_SERVICE_UTILS_ERRNO_H
16 #define STORAGE_SERVICE_UTILS_ERRNO_H
17 
18 #include <sys/types.h>
19 #include <unordered_map>
20 
21 namespace OHOS {
22 constexpr int32_t E_ERR = -1;
23 constexpr int32_t STORAGE_SERVICE_SYS_CAP_TAG = 13600000;
24 
25 enum ErrNo {
26     E_OK = 0,
27     E_PERMISSION_DENIED = 1,    // no permission
28     E_WRITE_DESCRIPTOR_ERR = 2, // ipc error
29     E_EXIST = 3,                // exist
30     E_WRONG_TYPE = 4,           // wrong file type
31     E_USER_STATE = 5,           // wrong user state
32     E_NON_EXIST = 6,            // no such item
33     E_PREPARE_DIR = 7,          // failed to prepare dir
34     E_DESTROY_DIR = 8,          // failed to destroy dir
35     E_MOUNT,                    // mount error
36     E_UMOUNT,                   // umount error
37     E_SET_POLICY,               // set policy error
38     E_USERID_RANGE,             // id out or range
39     E_VOL_STATE,                // volume state check fail
40     E_WAIT,                     // wait
41     E_NOT_SUPPORT,              // not support
42     E_SYS_CALL,                 // syscall error
43     E_NO_CHILD,                 // child not exist
44     E_WRITE_PARCEL_ERR,
45     E_WRITE_REPLY_ERR,
46     E_SA_IS_NULLPTR,
47     E_REMOTE_IS_NULLPTR,
48     E_SERVICE_IS_NULLPTR,
49     E_DEATH_RECIPIENT_IS_NULLPTR,
50     E_BUNDLEMGR_ERROR,
51     E_MEDIALIBRARY_ERROR,
52     E_SYS_ERR,
53     E_KEY_TYPE_INVAL,
54     E_DIFF_UID_GID,
55     E_PARAMS_INVAL,
56     E_ACTIVE_EL2_FAILED,
57     E_CLEAR_KEY_FAILED,
58     E_KEY_NOT_ACTIVED,
59     E_RESTORE_KEY_FAILED,
60     E_UNLOCK_SCREEN_FAILED,
61     E_UNLOCK_APP_KEY2_FAILED,
62     E_MTP_IS_MOUNTING,
63     E_MTP_PREPARE_DIR_ERR,
64     E_MTP_MOUNT_FAILED,
65     E_MTP_UMOUNT_FAILED,
66     E_MIGRATE_ELX_FAILED,
67 
68     // only use for anco
69     E_JSON_PARSE_ERROR = 100,
70     E_OPEN_JSON_FILE_ERROR,
71 
72     E_GLOBAL_KEY_NULLPTR = 200,
73     E_GLOBAL_KEY_INIT_ERROR,
74     E_GLOBAL_KEY_STORE_ERROR,
75     E_GLOBAL_KEY_ACTIVE_ERROR,
76     E_GLOBAL_KEY_UPDATE_ERROR,
77     E_ELX_KEY_INIT_ERROR,
78     E_ELX_KEY_STORE_ERROR,
79     E_ELX_KEY_ACTIVE_ERROR,
80     E_ELX_KEY_UPDATE_ERROR,
81     E_EL5_ADD_CLASS_ERROR,
82     E_EL5_ENCRYPT_CLASS_ERROR,
83     E_ELX_KEY_INACTIVE_ERROR,
84 
85 	// only for use mount and unmount
86     E_UMOUNT_CLOUD_FUSE = 300,
87     E_UMOUNT_CLOUD = 301,
88     E_UMOUNT_MEDIA_FUSE = 302,
89     E_UMOUNT_SHAREFS = 303,
90     E_UMOUNT_HMFS = 304,
91     E_UMOUNT_HMDFS = 305,
92     E_UMOUNT_LOCAL = 306,
93     E_UMOUNT_PROC_MOUNTS_OPEN = 307,
94     E_UMOUNT_ALL_PATH = 308,
95     E_UMOUNT_PROC_OPEN = 309,
96     E_UMOUNT_DETACH = 310,
97     E_UMOUNT_NO_PROCESS_FIND = 311,
98     E_UMOUNT_PROCESS_KILL = 312,
99     E_UMOUNT_FIND_FD = 313,
100 };
101 
102 enum JsErrCode {
103     E_PERMISSION = 201,
104     E_PERMISSION_SYS = 202,
105     E_PARAMS = 401,
106     E_DEVICENOTSUPPORT = 801,
107     E_OSNOTSUPPORT = 901,
108     E_IPCSS = STORAGE_SERVICE_SYS_CAP_TAG + 1,
109     E_SUPPORTEDFS,
110     E_MOUNT_ERR,
111     E_UNMOUNT,
112     E_VOLUMESTATE,
113     E_PREPARE,
114     E_DELETE,
115     E_NOOBJECT,
116     E_OUTOFRANGE,
117 };
118 
119 }
120 #endif // STORAGE_SERVICE_UTILS_ERRNO_H