mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2024-10-16 13:02:32 +00:00
Implement stat and getentropy for sgx with ocall to run tensorflow (#436)
This commit is contained in:
parent
ed94b7dcc4
commit
667282eea9
|
@ -49,9 +49,11 @@ int ocall_closedir(int *p_ret, void *dirp);
|
||||||
/** DIR end **/
|
/** DIR end **/
|
||||||
|
|
||||||
/** stat **/
|
/** stat **/
|
||||||
|
int ocall_stat(int *p_ret, const char *pathname,
|
||||||
|
void *buf, unsigned int buf_len);
|
||||||
int ocall_fstat(int *p_ret, int fd, void *buf, unsigned int buf_len);
|
int ocall_fstat(int *p_ret, int fd, void *buf, unsigned int buf_len);
|
||||||
int ocall_fstatat(int *p_ret, int dirfd, const char *pathname, void *buf,
|
int ocall_fstatat(int *p_ret, int dirfd, const char *pathname,
|
||||||
unsigned int buf_len, int flags);
|
void *buf, unsigned int buf_len, int flags);
|
||||||
/** stat end **/
|
/** stat end **/
|
||||||
|
|
||||||
/** link **/
|
/** link **/
|
||||||
|
@ -87,6 +89,7 @@ int ocall_getopt(int *p_ret, int argc, char *argv_buf,
|
||||||
unsigned int argv_buf_len, const char *optstring);
|
unsigned int argv_buf_len, const char *optstring);
|
||||||
int ocall_getrandom(ssize_t *p_ret, void *buf, size_t buflen,
|
int ocall_getrandom(ssize_t *p_ret, void *buf, size_t buflen,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
int ocall_getentropy(int *p_ret, void *buffer, size_t length);
|
||||||
int ocall_sched_yield(int *p_ret);
|
int ocall_sched_yield(int *p_ret);
|
||||||
|
|
||||||
/** struct iovec **/
|
/** struct iovec **/
|
||||||
|
@ -449,6 +452,25 @@ int ftruncate(int fd, off_t length)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int stat(const char *pathname, struct stat *statbuf)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (statbuf == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (ocall_stat(&ret, pathname,
|
||||||
|
(void *)statbuf,
|
||||||
|
sizeof(struct stat)) != SGX_SUCCESS) {
|
||||||
|
TRACE_OCALL_FAIL();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret == -1)
|
||||||
|
errno = get_errno();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int fstat(int fd, struct stat *statbuf)
|
int fstat(int fd, struct stat *statbuf)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -822,6 +844,19 @@ ssize_t getrandom(void *buf, size_t buflen, unsigned int flags)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getentropy(void *buffer, size_t length)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (ocall_getentropy(&ret, buffer, length) != SGX_SUCCESS) {
|
||||||
|
TRACE_OCALL_FAIL();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (ret == -1)
|
||||||
|
errno = get_errno();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int get_errno(void)
|
int get_errno(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
|
@ -183,6 +183,7 @@ ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt,
|
||||||
off_t lseek(int fd, off_t offset, int whence);
|
off_t lseek(int fd, off_t offset, int whence);
|
||||||
int ftruncate(int fd, off_t length);
|
int ftruncate(int fd, off_t length);
|
||||||
|
|
||||||
|
int stat(const char *pathname, struct stat *statbuf);
|
||||||
int fstat(int fd, struct stat *statbuf);
|
int fstat(int fd, struct stat *statbuf);
|
||||||
int fstatat(int dirfd, const char *pathname, struct stat *statbuf,
|
int fstatat(int dirfd, const char *pathname, struct stat *statbuf,
|
||||||
int flags);
|
int flags);
|
||||||
|
@ -218,6 +219,7 @@ int getopt(int argc, char * const argv[],
|
||||||
int sched_yield(void);
|
int sched_yield(void);
|
||||||
|
|
||||||
ssize_t getrandom(void *buf, size_t buflen, unsigned int flags);
|
ssize_t getrandom(void *buf, size_t buflen, unsigned int flags);
|
||||||
|
int getentropy(void *buffer, size_t length);
|
||||||
|
|
||||||
int get_errno(void);
|
int get_errno(void);
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,9 @@ enclave {
|
||||||
long ocall_telldir([user_check]void *dirp);
|
long ocall_telldir([user_check]void *dirp);
|
||||||
int ocall_closedir([user_check]void *dirp);
|
int ocall_closedir([user_check]void *dirp);
|
||||||
|
|
||||||
|
int ocall_stat([in, string]const char *pathname,
|
||||||
|
[out, size=buf_len]void *buf,
|
||||||
|
unsigned int buf_len);
|
||||||
int ocall_fstat(int fd, [out, size=buf_len]void *buf,
|
int ocall_fstat(int fd, [out, size=buf_len]void *buf,
|
||||||
unsigned int buf_len);
|
unsigned int buf_len);
|
||||||
int ocall_fstatat(int dirfd, [in, string]const char *pathname,
|
int ocall_fstatat(int dirfd, [in, string]const char *pathname,
|
||||||
|
@ -76,6 +79,7 @@ enclave {
|
||||||
[in, string]const char *optstring);
|
[in, string]const char *optstring);
|
||||||
ssize_t ocall_getrandom([out, size=buflen]void *buf, size_t buflen,
|
ssize_t ocall_getrandom([out, size=buflen]void *buf, size_t buflen,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
int ocall_getentropy([out, size=length]void *buffer, size_t length);
|
||||||
ssize_t ocall_readv(int fd,
|
ssize_t ocall_readv(int fd,
|
||||||
[in, out, size=buf_size]char *iov_buf,
|
[in, out, size=buf_size]char *iov_buf,
|
||||||
unsigned int buf_size, int iovcnt,
|
unsigned int buf_size, int iovcnt,
|
||||||
|
|
|
@ -130,6 +130,12 @@ int ocall_closedir(void* dirp)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ocall_stat(const char *pathname,
|
||||||
|
void *buf, unsigned int buf_len)
|
||||||
|
{
|
||||||
|
return stat(pathname, (struct stat *)buf);
|
||||||
|
}
|
||||||
|
|
||||||
int ocall_fstat(int fd, void *buf, unsigned int buf_len)
|
int ocall_fstat(int fd, void *buf, unsigned int buf_len)
|
||||||
{
|
{
|
||||||
return fstat(fd, (struct stat *)buf);
|
return fstat(fd, (struct stat *)buf);
|
||||||
|
@ -277,6 +283,11 @@ ssize_t ocall_getrandom(void *buf, size_t buflen, unsigned int flags)
|
||||||
return getrandom(buf, buflen, flags);
|
return getrandom(buf, buflen, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ocall_getentropy(void *buffer, size_t length)
|
||||||
|
{
|
||||||
|
return getentropy(buffer, length);
|
||||||
|
}
|
||||||
|
|
||||||
int ocall_sched_yield()
|
int ocall_sched_yield()
|
||||||
{
|
{
|
||||||
return sched_yield();
|
return sched_yield();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user