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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #include <string.h>
2 #include <stdio.h>
3 #include <sys/nacl_syscalls.h>
4 #include <nacl/nacl_srpc.h>
5 #include <sys/nacl_name_service.h>
6 #include <sys/fcntl.h>
7 #include "native_client/src/untrusted/irt/irt.h"
8
9 static void print_error(const char *message) {
10 write(2, message, strlen(message));
11 }
12
13 int irt_open_file_in_manifest (const char* file) {
14 int ns;
15 int connected_socket;
16 struct NaClSrpcChannel ns_channel;
17 int status;
18 int desc;
19 int manifest;
20 int manifest_conn;
21 struct NaClSrpcChannel manifest_channel;
22 print_error("irt here\n");
23 ns = -1;
24 nacl_nameservice(&ns);
25 printf("irt ns = %d\n", ns);
26 if (-1 == ns) {
27 print_error("Can't connect to name service\n");
28 return -1;
29 }
30 connected_socket = imc_connect(ns);
31 if (-1 == connected_socket) {
32 print_error("Can't connect to name service\n");
33 return -1;
34 }
35 close(ns);
36 if (!NaClSrpcClientCtor(&ns_channel, connected_socket)) {
37 print_error("Srpc client channel ctor failed\n");
38 return -1;
39 }
40 if (NACL_SRPC_RESULT_OK != NaClSrpcInvokeBySignature(
41 &ns_channel, NACL_NAME_SERVICE_LOOKUP, "ManifestNameService", O_RDWR,
42 &status, &manifest)) {
43 print_error("Nameservice lookup failed, status\n");
44 NaClSrpcDtor(&ns_channel);
45 return -1;
46 }
47 if (-1 == manifest) {
48 print_error("Manifest descriptor is invalid\n");
49 NaClSrpcDtor(&ns_channel);
50 return -1;
51 }
52 manifest_conn = imc_connect(manifest);
53 if (-1 == manifest_conn) {
54 print_error("Can't connect to manifest service\n");
55 NaClSrpcDtor(&ns_channel);
56 return -1;
57 }
58 close(manifest);
59 if (!NaClSrpcClientCtor(&manifest_channel, manifest_conn)) {
60 print_error("Can't create manifest srpc channel\n");
61 NaClSrpcDtor(&ns_channel);
62 return -1;
63 }
64 desc = 0;
65 if (NACL_SRPC_RESULT_OK != NaClSrpcInvokeBySignature(
66 &manifest_channel, NACL_NAME_SERVICE_LOOKUP, file, O_RDONLY,
67 &status, &desc)) {
68 print_error("Manifest lookup RPC failed\n");
69 NaClSrpcDtor(&manifest_channel);
70 return -1;
71 }
72 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.
73 NaClSrpcDtor(&ns_channel);
74 return desc;
75 }
76
77 const struct nacl_irt_manifest_open nacl_irt_manifest_open = {
78 irt_open_file_in_manifest
79 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698