| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 The Native Client Authors. All rights reserved. | 2 * Copyright 2008 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can |
| 4 * be found in the LICENSE file. | 4 * be found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 // This is a very basic file interface for Native Client. It allows | 7 // This is a very basic file interface for Native Client. It allows |
| 8 // Javascript to register a file which can then be read in C code via | 8 // Javascript to register a file which can then be read in C code via |
| 9 // the standard file interface; for example fopen(), fread(), fclose(). | 9 // the standard file interface; for example fopen(), fread(), fclose(). |
| 10 // | 10 // |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 NaClSrpcArg **in_args, \ | 68 NaClSrpcArg **in_args, \ |
| 69 NaClSrpcArg **out_args, \ | 69 NaClSrpcArg **out_args, \ |
| 70 NaClSrpcClosure *done) | 70 NaClSrpcClosure *done) |
| 71 | 71 |
| 72 NACL_SRPC_HANDLER("file:shi:", NaClFile) { | 72 NACL_SRPC_HANDLER("file:shi:", NaClFile) { |
| 73 char *pathname; | 73 char *pathname; |
| 74 int fd; | 74 int fd; |
| 75 int last; | 75 int last; |
| 76 struct nacl_file_map *entry; | 76 struct nacl_file_map *entry; |
| 77 | 77 |
| 78 pathname = in_args[0]->u.sval; | 78 pathname = in_args[0]->arrays.str; |
| 79 fd = in_args[1]->u.ival; | 79 fd = in_args[1]->u.ival; |
| 80 last = in_args[2]->u.hval; | 80 last = in_args[2]->u.hval; |
| 81 | 81 |
| 82 printf("NaClFile(%s,%d,%d)\n", pathname, fd, last); | 82 printf("NaClFile(%s,%d,%d)\n", pathname, fd, last); |
| 83 | 83 |
| 84 entry = reinterpret_cast<nacl_file_map*>(malloc(sizeof *entry)); | 84 entry = reinterpret_cast<nacl_file_map*>(malloc(sizeof *entry)); |
| 85 | 85 |
| 86 if (NULL == entry) { | 86 if (NULL == entry) { |
| 87 fprintf(stderr, "No memory for file map for %s\n", pathname); | 87 fprintf(stderr, "No memory for file map for %s\n", pathname); |
| 88 exit(1); | 88 exit(1); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 case SEEK_END: | 242 case SEEK_END: |
| 243 offset = __real_lseek(nacl_files[dd].real_fd, offset, SEEK_END); | 243 offset = __real_lseek(nacl_files[dd].real_fd, offset, SEEK_END); |
| 244 break; | 244 break; |
| 245 } | 245 } |
| 246 if (-1 != offset) { | 246 if (-1 != offset) { |
| 247 nacl_files[dd].pos = offset; | 247 nacl_files[dd].pos = offset; |
| 248 } | 248 } |
| 249 pthread_mutex_unlock(&nacl_files[dd].mu); | 249 pthread_mutex_unlock(&nacl_files[dd].mu); |
| 250 return offset; | 250 return offset; |
| 251 } | 251 } |
| OLD | NEW |