Skip to content

Commit

Permalink
GP11 : trusted storage verify (block enc fs)
Browse files Browse the repository at this point in the history
Signed-off-by: Cedric Chaumont <cedric.chaumont@st.com>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Tested-by: Cedric Chaumont <cedric.chaumont@linaro.org> (STM boards)
Tested-by: Cedric Chaumont <cedric.chaumont@linaro.org> (ARM Juno board)
  • Loading branch information
cedric-chaumont-st committed Oct 7, 2015
1 parent 855ae4e commit a2e9a83
Show file tree
Hide file tree
Showing 12 changed files with 851 additions and 524 deletions.
15 changes: 9 additions & 6 deletions core/include/tee/tee_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <stddef.h>
#include <stdint.h>
#include <tee_api_types.h>

#define TEE_FS_NAME_MAX 350

Expand Down Expand Up @@ -66,18 +67,20 @@ struct tee_fs_dirent {
char *d_name;
};


/*
* tee_fs implemets a POSIX like secure file system
* tee_fs implemets a POSIX like secure file system with GP extension
*/
struct tee_file_operations {
int (*open)(const char *file, int flags, ...);
int (*open)(TEE_Result *errno, const char *file, int flags, ...);
int (*close)(int fd);
int (*read)(int fd, void *buf, size_t len);
int (*write)(int fd, const void *buf, size_t len);
tee_fs_off_t (*lseek)(int fd, tee_fs_off_t offset, int whence);
int (*read)(TEE_Result *errno, int fd, void *buf, size_t len);
int (*write)(TEE_Result *errno, int fd, const void *buf, size_t len);
tee_fs_off_t (*lseek)(TEE_Result *errno,
int fd, tee_fs_off_t offset, int whence);
int (*rename)(const char *old, const char *new);
int (*unlink)(const char *file);
int (*ftruncate)(int fd, tee_fs_off_t length);
int (*ftruncate)(TEE_Result *errno, int fd, tee_fs_off_t length);
int (*mkdir)(const char *path, tee_fs_mode_t mode);
tee_fs_dir *(*opendir)(const char *name);
int (*closedir)(tee_fs_dir *d);
Expand Down
2 changes: 2 additions & 0 deletions core/include/tee/tee_fs_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#define TEE_FS_O_RDWR 0x4
#define TEE_FS_O_CREATE 0x8
#define TEE_FS_O_EXCL 0x10
#define TEE_FS_O_APPEND 0x20
#define TEE_FS_O_TRUNC 0x40

/*
* tee_fs_lseek
Expand Down
2 changes: 2 additions & 0 deletions core/include/tee/tee_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ void tee_obj_close(struct tee_ta_ctx *ctx, struct tee_obj *o);

void tee_obj_close_all(struct tee_ta_ctx *ctx);

TEE_Result tee_obj_verify(struct tee_ta_session *sess, struct tee_obj *o);

#endif
8 changes: 8 additions & 0 deletions core/include/tee/tee_svc_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <tee_api_types.h>
#include <kernel/tee_ta_manager.h>
#include <tee/tee_fs.h>

/*
* Persistant Object Functions
Expand Down Expand Up @@ -79,4 +80,11 @@ void tee_svc_storage_close_all_enum(struct tee_ta_ctx *ctx);

void tee_svc_storage_init(void);

char *tee_svc_storage_create_filename(struct tee_ta_session *sess,
void *object_id,
uint32_t object_id_len,
bool transient);

char *tee_svc_storage_create_dirname(struct tee_ta_session *sess);

#endif /* TEE_SVC_STORAGE_H */
17 changes: 9 additions & 8 deletions core/tee/tee_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,33 @@ static int tee_fs_close(int fd)
return tee_fs_common_close(fdp);
}

static int tee_fs_read(int fd, void *buf, size_t len)
static int tee_fs_read(TEE_Result *errno, int fd, void *buf, size_t len)
{
struct tee_fs_fd *fdp = tee_fs_fd_lookup(fd);

return tee_fs_common_read(fdp, buf, len);
return tee_fs_common_read(errno, fdp, buf, len);
}

static int tee_fs_write(int fd, const void *buf, size_t len)
static int tee_fs_write(TEE_Result *errno, int fd, const void *buf, size_t len)
{
struct tee_fs_fd *fdp = tee_fs_fd_lookup(fd);

return tee_fs_common_write(fdp, buf, len);
return tee_fs_common_write(errno, fdp, buf, len);
}

static tee_fs_off_t tee_fs_lseek(int fd, tee_fs_off_t offset, int whence)
static tee_fs_off_t tee_fs_lseek(TEE_Result *errno,
int fd, tee_fs_off_t offset, int whence)
{
struct tee_fs_fd *fdp = tee_fs_fd_lookup(fd);

return tee_fs_common_lseek(fdp, offset, whence);
return tee_fs_common_lseek(errno, fdp, offset, whence);
}

static int tee_fs_ftruncate(int fd, tee_fs_off_t length)
static int tee_fs_ftruncate(TEE_Result *errno, int fd, tee_fs_off_t length)
{
struct tee_fs_fd *fdp = tee_fs_fd_lookup(fd);

return tee_fs_common_ftruncate(fdp, length);
return tee_fs_common_ftruncate(errno, fdp, length);
}

struct tee_file_operations tee_file_ops = {
Expand Down
Loading

0 comments on commit a2e9a83

Please sign in to comment.