OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <sys/stat.h> | 5 #include <sys/stat.h> |
6 #include <sys/types.h> | 6 #include <sys/types.h> |
7 #include <unistd.h> | 7 #include <unistd.h> |
8 #include <cstring> | 8 #include <cstring> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "native_client/src/trusted/service_runtime/include/sys/stat.h" | 11 #include "native_client/src/trusted/service_runtime/include/sys/stat.h" |
Mark Seaborn
2014/01/15 19:49:28
Add #include to cover nacl_abi_timespec?
hidehiko
2014/01/16 05:30:12
Done.
| |
12 | 12 |
13 namespace nacl { | 13 namespace nacl { |
14 namespace nonsfi { | 14 namespace nonsfi { |
15 | 15 |
16 void NaClAbiTimeSpecToTimeSpec(const struct nacl_abi_timespec& nacl_timespec, | |
17 struct timespec* host_timespec) { | |
18 host_timespec->tv_sec = nacl_timespec.tv_sec; | |
19 host_timespec->tv_nsec = nacl_timespec.tv_nsec; | |
20 } | |
21 | |
22 void TimeSpecToNaClAbiTimeSpec(const struct timespec& host_timespec, | |
23 struct nacl_abi_timespec* nacl_timespec) { | |
24 nacl_timespec->tv_sec = host_timespec.tv_sec; | |
25 nacl_timespec->tv_nsec = host_timespec.tv_nsec; | |
26 } | |
27 | |
16 void StatToNaClAbiStat( | 28 void StatToNaClAbiStat( |
17 const struct stat& host_stat, struct nacl_abi_stat* nacl_stat) { | 29 const struct stat& host_stat, struct nacl_abi_stat* nacl_stat) { |
18 // Some fields in host_stat, such as st_dev, group/other bits of mode and | 30 // Some fields in host_stat, such as st_dev, group/other bits of mode and |
19 // (a,m,c)timensec, are ignored to sync with the NaCl's original | 31 // (a,m,c)timensec, are ignored to sync with the NaCl's original |
20 // implementation. Please see also NaClAbiStatHostDescStatXlateCtor in | 32 // implementation. Please see also NaClAbiStatHostDescStatXlateCtor in |
21 // native_client/src/trusted/desc/posix/nacl_desc.c. | 33 // native_client/src/trusted/desc/posix/nacl_desc.c. |
22 std::memset(nacl_stat, 0, sizeof(*nacl_stat)); | 34 std::memset(nacl_stat, 0, sizeof(*nacl_stat)); |
23 nacl_stat->nacl_abi_st_dev = 0; | 35 nacl_stat->nacl_abi_st_dev = 0; |
24 nacl_stat->nacl_abi_st_ino = host_stat.st_ino; | 36 nacl_stat->nacl_abi_st_ino = host_stat.st_ino; |
25 nacl_abi_mode_t mode; | 37 nacl_abi_mode_t mode; |
(...skipping 26 matching lines...) Expand all Loading... | |
52 nacl_stat->nacl_abi_st_size = host_stat.st_size; | 64 nacl_stat->nacl_abi_st_size = host_stat.st_size; |
53 nacl_stat->nacl_abi_st_blksize = 0; | 65 nacl_stat->nacl_abi_st_blksize = 0; |
54 nacl_stat->nacl_abi_st_blocks = 0; | 66 nacl_stat->nacl_abi_st_blocks = 0; |
55 nacl_stat->nacl_abi_st_atime = host_stat.st_atime; | 67 nacl_stat->nacl_abi_st_atime = host_stat.st_atime; |
56 nacl_stat->nacl_abi_st_mtime = host_stat.st_mtime; | 68 nacl_stat->nacl_abi_st_mtime = host_stat.st_mtime; |
57 nacl_stat->nacl_abi_st_ctime = host_stat.st_ctime; | 69 nacl_stat->nacl_abi_st_ctime = host_stat.st_ctime; |
58 } | 70 } |
59 | 71 |
60 } // namespace nonsfi | 72 } // namespace nonsfi |
61 } // namespace nacl | 73 } // namespace nacl |
OLD | NEW |