1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2014, STMicroelectronics International N.V. 4 */ 5 6 #ifndef TEE_FS_H 7 #define TEE_FS_H 8 9 #include <stddef.h> 10 #include <stdint.h> 11 #include <tee_api_types.h> 12 13 #define TEE_FS_NAME_MAX 350 14 15 typedef int64_t tee_fs_off_t; 16 typedef uint32_t tee_fs_mode_t; 17 18 struct tee_fs_dirent { 19 uint8_t oid[TEE_OBJECT_ID_MAX_LEN]; 20 size_t oidlen; 21 }; 22 23 struct tee_fs_dir; 24 struct tee_file_handle; 25 struct tee_pobj; 26 27 /* 28 * tee_fs implements a POSIX like secure file system with GP extension 29 */ 30 struct tee_file_operations { 31 TEE_Result (*open)(struct tee_pobj *po, size_t *size, 32 struct tee_file_handle **fh); 33 TEE_Result (*create)(struct tee_pobj *po, bool overwrite, 34 const void *head, size_t head_size, 35 const void *attr, size_t attr_size, 36 const void *data, size_t data_size, 37 struct tee_file_handle **fh); 38 void (*close)(struct tee_file_handle **fh); 39 TEE_Result (*read)(struct tee_file_handle *fh, size_t pos, 40 void *buf, size_t *len); 41 TEE_Result (*write)(struct tee_file_handle *fh, size_t pos, 42 const void *buf, size_t len); 43 TEE_Result (*rename)(struct tee_pobj *old_po, struct tee_pobj *new_po, 44 bool overwrite); 45 TEE_Result (*remove)(struct tee_pobj *po); 46 TEE_Result (*truncate)(struct tee_file_handle *fh, size_t size); 47 48 TEE_Result (*opendir)(const TEE_UUID *uuid, struct tee_fs_dir **d); 49 TEE_Result (*readdir)(struct tee_fs_dir *d, struct tee_fs_dirent **ent); 50 void (*closedir)(struct tee_fs_dir *d); 51 }; 52 53 #ifdef CFG_REE_FS 54 extern const struct tee_file_operations ree_fs_ops; 55 #endif 56 #ifdef CFG_RPMB_FS 57 extern const struct tee_file_operations rpmb_fs_ops; 58 59 TEE_Result tee_rpmb_fs_raw_open(const char *fname, bool create, 60 struct tee_file_handle **fh); 61 #endif 62 63 #endif /*TEE_FS_H*/ 64