• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 Huawei Technologies Co., Ltd.
3  * Licensed under the Mulan PSL v2.
4  * You can use this software according to the terms and conditions of the Mulan PSL v2.
5  * You may obtain a copy of Mulan PSL v2 at:
6  *     http://license.coscl.org.cn/MulanPSL2
7  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
8  * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
9  * PURPOSE.
10  * See the Mulan PSL v2 for more details.
11  */
12 #ifndef __TEE_FS_H
13 #define __TEE_FS_H
14 
15 #include "tee_defines.h"
16 
17 /* Macros for access() */
18 #define R_OK 4 // Read
19 #define W_OK 2 // Write
20 #define F_OK 0 // Existence
21 
22 #define HASH_LEN        32
23 /* DIR_LEN is for mutiple sec storage partition and dir,e.g. sec_storage/dirA/file1.txt */
24 #define DIR_LEN                         64
25 #define NEW_DIR_LEN                     128
26 
27 #ifndef CONFIG_SPEC_STORAGE_PATH /* for router */
28 #define HASH_NAME_BUFF_LEN              (2 * HASH_LEN + 1 + DIR_LEN)
29 #define MAX_FILE_ID_LEN                 HASH_NAME_BUFF_LEN
30 #define SFS_PARTITION_PERSISTENT        "sec_storage/"
31 #define SFS_PARTITION_TRANSIENT         "sec_storage_data/"
32 #else
33 #define HASH_NAME_BUFF_LEN              (2 * HASH_LEN + 1 + DIR_LEN)
34 #define MAX_FILE_ID_LEN                 256
35 #define SFS_PARTITION_PERSISTENT        "cert/"
36 #define SFS_PARTITION_TRANSIENT         "tee/"
37 #endif
38 
39 #define MAX_FILE_SIZE                   (4 * 1024 * 1024)
40 #define SFS_PERSO                       "_perso/"
41 #define SFS_PRIVATE                     "_private/"
42 #define SFS_PARTITION_TRANSIENT_PRIVATE SFS_PARTITION_TRANSIENT SFS_PRIVATE
43 #define SFS_PARTITION_TRANSIENT_PERSO   SFS_PARTITION_TRANSIENT SFS_PERSO
44 #define MAX_TRUNCATE_SIZE               (4 * 1024 * 1024)
45 
46 #define FILE_NAME_INVALID_STR "../" // file name path must not contain ../
47 
48 TEE_Result check_file_name(const char *name);
49 TEE_Result check_name_by_storageid(const char *obj_id, uint32_t obj_len, uint32_t storage_id);
50 #endif
51