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..ce227f53a6ceb85344ddf9508cc08ac67393e911 |
--- /dev/null |
+++ b/mojo/nacl/nonsfi/irt_resource_open.cc |
@@ -0,0 +1,38 @@ |
+// 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 "base/path_service.h" |
+#include "mojo/nacl/nonsfi/irt_mojo_nonsfi.h" |
+#include "native_client/src/untrusted/irt/irt_dev.h" |
+ |
+namespace { |
+ |
+int IrtOpenResource(const char* filename, int* newfd) { |
+ base::FilePath base_path; |
+ PathService::Get(base::DIR_MODULE, &base_path); |
Mark Seaborn
2015/10/28 21:53:01
How about returning ENOENT if this fails?
Sean Klein
2015/10/28 22:22:16
Done.
|
+ std::string path = base_path.value(); |
+ path.append("/pnacl_translation_files/"); |
Mark Seaborn
2015/10/28 21:53:01
You could use FilePath()'s Append() method instead
Sean Klein
2015/10/28 22:22:16
Done, and for consistency, updated pnacl_link and
|
+ if (strcmp(filename, "libpnacl_irt_shim.a")) |
+ path.append(filename); |
+ else |
+ path.append("libpnacl_irt_shim_dummy.a"); |
+ int rv = open(path.c_str(), O_RDONLY); |
+ if (rv < 0) |
+ return -errno; |
Mark Seaborn
2015/10/28 21:53:01
This shouldn't be negated.
Sean Klein
2015/10/28 22:22:16
Done.
|
+ *newfd = rv; |
+ return 0; |
+} |
+ |
+} // namespace anonymous |
+ |
+namespace nacl { |
+ |
+const struct nacl_irt_resource_open nacl_irt_resource_open = { |
+ IrtOpenResource, |
+}; |
+ |
+} // namespace nacl |