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