OLD | NEW |
(Empty) | |
| 1 #include <errno.h> |
| 2 #include <stddef.h> |
| 3 #include <sys/stat.h> |
| 4 |
| 5 #include <kernel_stat.h> |
| 6 #include <nacl_stat.h> |
| 7 #include <nacl_syscalls.h> |
| 8 |
| 9 void __nacl_abi_stat_to_stat (struct nacl_abi_stat *nacl_st, |
| 10 struct stat *st) |
| 11 { |
| 12 st->st_dev = nacl_st->nacl_abi_st_dev; |
| 13 #ifdef _HAVE_STAT___PAD1 |
| 14 st->__pad1 = 0; |
| 15 #endif |
| 16 #ifdef _HAVE_STAT___ST_INO |
| 17 st->__st_ino = nacl_st->nacl_abi_st_ino; |
| 18 #endif |
| 19 st->st_mode = nacl_st->nacl_abi_st_mode; |
| 20 st->st_nlink = nacl_st->nacl_abi_st_nlink; |
| 21 st->st_uid = nacl_st->nacl_abi_st_uid; |
| 22 st->st_gid = nacl_st->nacl_abi_st_gid; |
| 23 st->st_rdev = nacl_st->nacl_abi_st_rdev; |
| 24 #ifdef _HAVE_STAT___PAD2 |
| 25 st->__pad2 = 0; |
| 26 #endif |
| 27 st->st_size = nacl_st->nacl_abi_st_size; |
| 28 st->st_blksize = nacl_st->nacl_abi_st_blksize; |
| 29 st->st_blocks = nacl_st->nacl_abi_st_blocks; |
| 30 st->st_atim.tv_sec = nacl_st->nacl_abi_st_atime; |
| 31 st->st_atim.tv_nsec = 0; |
| 32 st->st_mtim.tv_sec = nacl_st->nacl_abi_st_mtime; |
| 33 st->st_mtim.tv_nsec = 0; |
| 34 st->st_ctim.tv_sec = nacl_st->nacl_abi_st_ctime; |
| 35 st->st_ctim.tv_nsec = 0; |
| 36 st->st_ino = nacl_st->nacl_abi_st_ino; |
| 37 } |
| 38 |
| 39 int __fxstat (int vers, int fd, struct stat *buf) |
| 40 { |
| 41 if (buf == NULL) { |
| 42 errno = EFAULT; |
| 43 return -1; |
| 44 } |
| 45 struct nacl_abi_stat nacl_buf; |
| 46 int result = NACL_SYSCALL (fstat) (fd, &nacl_buf); |
| 47 if (result < 0) { |
| 48 errno = -result; |
| 49 return -1; |
| 50 } |
| 51 __nacl_abi_stat_to_stat (&nacl_buf, buf); |
| 52 return result; |
| 53 } |
| 54 hidden_def (__fxstat) |
OLD | NEW |