Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Unified Diff: src/untrusted/irt/irt_manifest.c

Issue 7605029: Extend IRT with nacl_irt_resource_open interface (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: remove empty lines Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/untrusted/irt/irt_manifest.c
===================================================================
--- src/untrusted/irt/irt_manifest.c (revision 0)
+++ src/untrusted/irt/irt_manifest.c (revision 0)
@@ -0,0 +1,79 @@
+#include <string.h>
+#include <stdio.h>
+#include <sys/nacl_syscalls.h>
+#include <nacl/nacl_srpc.h>
+#include <sys/nacl_name_service.h>
+#include <sys/fcntl.h>
+#include "native_client/src/untrusted/irt/irt.h"
+
+static void print_error(const char *message) {
+ write(2, message, strlen(message));
+}
+
+int irt_open_file_in_manifest (const char* file) {
+ int ns;
+ int connected_socket;
+ struct NaClSrpcChannel ns_channel;
+ int status;
+ int desc;
+ int manifest;
+ int manifest_conn;
+ struct NaClSrpcChannel manifest_channel;
+ print_error("irt here\n");
+ ns = -1;
+ nacl_nameservice(&ns);
+ printf("irt ns = %d\n", ns);
+ if (-1 == ns) {
+ print_error("Can't connect to name service\n");
+ return -1;
+ }
+ connected_socket = imc_connect(ns);
+ if (-1 == connected_socket) {
+ print_error("Can't connect to name service\n");
+ return -1;
+ }
+ close(ns);
+ if (!NaClSrpcClientCtor(&ns_channel, connected_socket)) {
+ print_error("Srpc client channel ctor failed\n");
+ return -1;
+ }
+ if (NACL_SRPC_RESULT_OK != NaClSrpcInvokeBySignature(
+ &ns_channel, NACL_NAME_SERVICE_LOOKUP, "ManifestNameService", O_RDWR,
+ &status, &manifest)) {
+ print_error("Nameservice lookup failed, status\n");
+ NaClSrpcDtor(&ns_channel);
+ return -1;
+ }
+ if (-1 == manifest) {
+ print_error("Manifest descriptor is invalid\n");
+ NaClSrpcDtor(&ns_channel);
+ return -1;
+ }
+ manifest_conn = imc_connect(manifest);
+ if (-1 == manifest_conn) {
+ print_error("Can't connect to manifest service\n");
+ NaClSrpcDtor(&ns_channel);
+ return -1;
+ }
+ close(manifest);
+ if (!NaClSrpcClientCtor(&manifest_channel, manifest_conn)) {
+ print_error("Can't create manifest srpc channel\n");
+ NaClSrpcDtor(&ns_channel);
+ return -1;
+ }
+ desc = 0;
+ if (NACL_SRPC_RESULT_OK != NaClSrpcInvokeBySignature(
+ &manifest_channel, NACL_NAME_SERVICE_LOOKUP, file, O_RDONLY,
+ &status, &desc)) {
+ print_error("Manifest lookup RPC failed\n");
+ NaClSrpcDtor(&manifest_channel);
+ return -1;
+ }
+ NaClSrpcDtor(&manifest_channel);
bsy 2011/08/11 02:32:43 the irt should be able to cache these channels for
halyavin 2011/08/12 08:52:07 Done.
+ NaClSrpcDtor(&ns_channel);
+ return desc;
+}
+
+const struct nacl_irt_manifest_open nacl_irt_manifest_open = {
+ irt_open_file_in_manifest
+};

Powered by Google App Engine
This is Rietveld 408576698