Chromium Code Reviews| Index: mojo/nacl/nonsfi/irt_resource_open.cc |
| diff --git a/mojo/nacl/nonsfi/irt_resource_open.cc b/mojo/nacl/nonsfi/irt_resource_open.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f2ae7c1c4a1c98f5e9b12137cf0ca3e6ca5276d0 |
| --- /dev/null |
| +++ b/mojo/nacl/nonsfi/irt_resource_open.cc |
| @@ -0,0 +1,29 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include <fcntl.h> |
| + |
| +#include "base/files/file_util.h" |
| +#include "mojo/nacl/nonsfi/irt_mojo_nonsfi.h" |
| +#include "native_client/src/untrusted/irt/irt_dev.h" |
| + |
| +int nacl_irt_open_resource(const char *pathname, int *newfd) { |
|
Mark Seaborn
2015/10/20 21:32:40
This can go in an anon namespace and follow Chromi
Sean Klein
2015/10/22 21:50:00
Done.
|
| + char path[PATH_MAX]; |
| + char nonsfi_toolchain[] = "native_client/toolchain/linux_x86" |
|
Mark Seaborn
2015/10/20 21:32:40
This can use 'const'
Sean Klein
2015/10/22 21:50:00
Not done, since changed to string (which has file
|
| + "/pnacl_translator/translator/x86-32-nonsfi/lib/"; |
| + strcpy(path, nonsfi_toolchain); |
| + if (strcmp(pathname, "libpnacl_irt_shim.a")) |
| + strcat(path, pathname); |
|
Mark Seaborn
2015/10/20 21:32:40
Can you use C++ strings instead? This overruns th
Sean Klein
2015/10/22 21:50:00
Done.
|
| + else |
| + strcat(path, "libpnacl_irt_shim_dummy.a"); |
| + int rv = open(path, O_RDONLY); |
| + if (rv < 0) |
| + return -rv; |
|
Mark Seaborn
2015/10/20 21:32:40
Should return errno instead.
Sean Klein
2015/10/22 21:50:00
Done.
|
| + *newfd = rv; |
| + return 0; |
| +} |
| + |
| +const struct nacl_irt_resource_open nacl_irt_resource_open = { |
| + nacl_irt_open_resource, |
| +}; |