OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2014 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2014 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
11 #include "native_client/tests/irt_ext/file_desc.h" | |
12 #include "native_client/src/include/nacl_assert.h" | 11 #include "native_client/src/include/nacl_assert.h" |
13 #include "native_client/src/include/nacl_macros.h" | 12 #include "native_client/src/include/nacl_macros.h" |
14 #include "native_client/src/untrusted/irt/irt_dev.h" | 13 #include "native_client/src/untrusted/irt/irt_dev.h" |
15 #include "native_client/src/untrusted/irt/irt_extension.h" | 14 #include "native_client/src/untrusted/irt/irt_extension.h" |
15 #include "native_client/tests/irt_ext/file_desc.h" | |
16 | 16 |
17 static struct file_desc_environment *g_activated_env = NULL; | 17 static struct file_desc_environment *g_activated_env = NULL; |
18 static const struct inode_data g_default_inode = { | 18 static const struct inode_data g_default_inode = { |
19 .valid = false, | 19 .valid = false, |
20 .mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, | 20 .mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, |
21 }; | 21 }; |
22 | 22 |
23 static struct inode_data g_root_dir = { | 23 static struct inode_data g_root_dir = { |
24 .valid = true, | 24 .valid = true, |
25 .mode = S_IFDIR, | 25 .mode = S_IFDIR, |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 size_t *nread) { | 272 size_t *nread) { |
273 return ENOSYS; | 273 return ENOSYS; |
274 } | 274 } |
275 | 275 |
276 static int my_utimes(const char *filename, const struct timeval *times) { | 276 static int my_utimes(const char *filename, const struct timeval *times) { |
277 return ENOSYS; | 277 return ENOSYS; |
278 } | 278 } |
279 | 279 |
280 /* Module file_desc functions. */ | 280 /* Module file_desc functions. */ |
281 void init_file_desc_module(void) { | 281 void init_file_desc_module(void) { |
282 size_t size; | |
Roland McGrath
2014/08/28 23:27:42
Use C99 style rather than predeclaring a local
David Yen
2014/08/29 16:43:33
Done.
| |
282 struct nacl_irt_dev_fdio fdio = { | 283 struct nacl_irt_dev_fdio fdio = { |
283 my_close, | 284 my_close, |
284 my_dup, | 285 my_dup, |
285 my_dup2, | 286 my_dup2, |
286 my_read, | 287 my_read, |
287 my_write, | 288 my_write, |
288 my_seek, | 289 my_seek, |
289 my_fstat, | 290 my_fstat, |
290 my_getdents, | 291 my_getdents, |
291 my_fchdir, | 292 my_fchdir, |
292 my_fchmod, | 293 my_fchmod, |
293 my_fsync, | 294 my_fsync, |
294 my_fdatasync, | 295 my_fdatasync, |
295 my_ftruncate, | 296 my_ftruncate, |
296 my_isatty, | 297 my_isatty, |
297 }; | 298 }; |
298 | 299 |
299 /* These tables should have share common prefixes with one another. */ | 300 size = nacl_interface_ext_supply(NACL_IRT_DEV_FDIO_v0_3, &fdio, |
300 ASSERT_GT(sizeof(struct nacl_irt_dev_fdio_v0_2), | 301 sizeof(fdio)); |
301 sizeof(struct nacl_irt_fdio)); | 302 ASSERT_EQ(size, sizeof(fdio)); |
302 ASSERT_GT(sizeof(struct nacl_irt_dev_fdio), | |
303 sizeof(struct nacl_irt_dev_fdio_v0_2)); | |
304 | |
305 nacl_interface_ext_supply(NACL_IRT_FDIO_v0_1, &fdio, | |
306 sizeof(struct nacl_irt_fdio)); | |
307 nacl_interface_ext_supply(NACL_IRT_DEV_FDIO_v0_2, &fdio, | |
308 sizeof(struct nacl_irt_dev_fdio_v0_2)); | |
309 nacl_interface_ext_supply(NACL_IRT_DEV_FDIO_v0_3, &fdio, | |
310 sizeof(fdio)); | |
311 | 303 |
312 struct nacl_irt_dev_filename fname = { | 304 struct nacl_irt_dev_filename fname = { |
313 my_open, | 305 my_open, |
314 my_stat, | 306 my_stat, |
315 my_mkdir, | 307 my_mkdir, |
316 my_rmdir, | 308 my_rmdir, |
317 my_chdir, | 309 my_chdir, |
318 my_getcwd, | 310 my_getcwd, |
319 my_unlink, | 311 my_unlink, |
320 my_truncate, | 312 my_truncate, |
321 my_lstat, | 313 my_lstat, |
322 my_link, | 314 my_link, |
323 my_rename, | 315 my_rename, |
324 my_symlink, | 316 my_symlink, |
325 my_chmod, | 317 my_chmod, |
326 my_access, | 318 my_access, |
327 my_readlink, | 319 my_readlink, |
328 my_utimes, | 320 my_utimes, |
329 }; | 321 }; |
330 | 322 |
331 /* These tables should have share common prefixes with one another. */ | 323 /* These tables should have share common prefixes with one another. */ |
332 ASSERT_GT(sizeof(struct nacl_irt_dev_filename_v0_2), | 324 size = nacl_interface_ext_supply(NACL_IRT_DEV_FILENAME_v0_3, &fname, |
333 sizeof(struct nacl_irt_filename)); | 325 sizeof(fname)); |
334 ASSERT_GT(sizeof(struct nacl_irt_dev_filename), | 326 ASSERT_EQ(size, sizeof(fname)); |
335 sizeof(struct nacl_irt_dev_filename_v0_2)); | |
336 | |
337 nacl_interface_ext_supply(NACL_IRT_FILENAME_v0_1, &fname, | |
338 sizeof(struct nacl_irt_filename)); | |
339 nacl_interface_ext_supply(NACL_IRT_DEV_FILENAME_v0_2, &fname, | |
340 sizeof(struct nacl_irt_dev_filename_v0_2)); | |
341 nacl_interface_ext_supply(NACL_IRT_DEV_FILENAME_v0_3, &fname, | |
342 sizeof(fname)); | |
343 } | 327 } |
344 | 328 |
345 void init_inode_data(struct inode_data *inode_data) { | 329 void init_inode_data(struct inode_data *inode_data) { |
346 *inode_data = g_default_inode; | 330 *inode_data = g_default_inode; |
347 } | 331 } |
348 | 332 |
349 void init_file_descriptor(struct file_descriptor *file_desc) { | 333 void init_file_descriptor(struct file_descriptor *file_desc) { |
350 file_desc->valid = false; | 334 file_desc->valid = false; |
351 file_desc->data = NULL; | 335 file_desc->data = NULL; |
352 } | 336 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 return find_inode_name(env, current_dir, path_iter, strlen(path_iter)); | 413 return find_inode_name(env, current_dir, path_iter, strlen(path_iter)); |
430 } | 414 } |
431 | 415 |
432 void activate_file_desc_env(struct file_desc_environment *env) { | 416 void activate_file_desc_env(struct file_desc_environment *env) { |
433 g_activated_env = env; | 417 g_activated_env = env; |
434 } | 418 } |
435 | 419 |
436 void deactivate_file_desc_env(void) { | 420 void deactivate_file_desc_env(void) { |
437 g_activated_env = NULL; | 421 g_activated_env = NULL; |
438 } | 422 } |
OLD | NEW |