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

Side by Side Diff: ports/nacl-spawn/nacl_apipe.c

Issue 1742043002: Make M-x shell work in emacs. (Closed) Base URL: https://chromium.googlesource.com/webports.git@master
Patch Set: fix Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The Native Client Authors. All rights reserved. 2 * Copyright 2015 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 26 matching lines...) Expand all
37 return 0; 37 return 0;
38 } 38 }
39 39
40 static int apipe_read( 40 static int apipe_read(
41 const char* path, char* buf, size_t count, off_t offset, 41 const char* path, char* buf, size_t count, off_t offset,
42 struct fuse_file_info* info) { 42 struct fuse_file_info* info) {
43 struct PP_Var req_var = nspawn_dict_create(); 43 struct PP_Var req_var = nspawn_dict_create();
44 nspawn_dict_setstring(req_var, "command", "nacl_apipe_read"); 44 nspawn_dict_setstring(req_var, "command", "nacl_apipe_read");
45 nspawn_dict_setint(req_var, "pipe_id", info->fh); 45 nspawn_dict_setint(req_var, "pipe_id", info->fh);
46 nspawn_dict_setint(req_var, "count", count); 46 nspawn_dict_setint(req_var, "count", count);
47 nspawn_dict_setint(req_var, "nonblock",
48 (info->flags & O_NONBLOCK) != O_NONBLOCK);
47 49
48 struct PP_Var result_var = nspawn_send_request(req_var); 50 struct PP_Var result_var = nspawn_send_request(req_var);
51 int err = nspawn_dict_getint(result_var, "error");
52 if (err != 0) {
53 nspawn_var_release(result_var);
54 return -err;
55 }
49 struct PP_Var data = nspawn_dict_get(result_var, "data"); 56 struct PP_Var data = nspawn_dict_get(result_var, "data");
50 assert(data.type == PP_VARTYPE_ARRAY_BUFFER); 57 assert(data.type == PP_VARTYPE_ARRAY_BUFFER);
51 uint32_t len; 58 uint32_t len;
52 if (!PSInterfaceVarArrayBuffer()->ByteLength(data, &len)) { 59 if (!PSInterfaceVarArrayBuffer()->ByteLength(data, &len)) {
53 nspawn_var_release(data); 60 nspawn_var_release(data);
54 nspawn_var_release(result_var); 61 nspawn_var_release(result_var);
55 return -EIO; 62 return -EIO;
56 } 63 }
57 void *p = PSInterfaceVarArrayBuffer()->Map(data); 64 void *p = PSInterfaceVarArrayBuffer()->Map(data);
58 if (len > 0 && !p) { 65 if (len > 0 && !p) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 int ret = nspawn_dict_getint(result_var, "count"); 103 int ret = nspawn_dict_getint(result_var, "count");
97 nspawn_var_release(result_var); 104 nspawn_var_release(result_var);
98 105
99 return ret; 106 return ret;
100 } 107 }
101 108
102 static int apipe_release(const char* path, struct fuse_file_info* info) { 109 static int apipe_release(const char* path, struct fuse_file_info* info) {
103 struct PP_Var req_var = nspawn_dict_create(); 110 struct PP_Var req_var = nspawn_dict_create();
104 nspawn_dict_setstring(req_var, "command", "nacl_apipe_close"); 111 nspawn_dict_setstring(req_var, "command", "nacl_apipe_close");
105 nspawn_dict_setint(req_var, "pipe_id", info->fh); 112 nspawn_dict_setint(req_var, "pipe_id", info->fh);
106 nspawn_dict_setint(req_var, "writer", info->flags == O_WRONLY); 113 nspawn_dict_setint(req_var, "writer", (info->flags & O_WRONLY) == O_WRONLY);
107 114
108 struct PP_Var result_var = nspawn_send_request(req_var); 115 struct PP_Var result_var = nspawn_send_request(req_var);
109 int ret = nspawn_dict_getint(result_var, "result"); 116 int ret = nspawn_dict_getint(result_var, "result");
110 nspawn_var_release(result_var); 117 nspawn_var_release(result_var);
111 118
112 return ret; 119 return ret;
113 } 120 }
114 121
115 static int apipe_fgetattr( 122 static int apipe_fgetattr(
116 const char* path, struct stat* st, struct fuse_file_info* info) { 123 const char* path, struct stat* st, struct fuse_file_info* info) {
(...skipping 23 matching lines...) Expand all
140 } 147 }
141 mkdir("/apipe", 0777); 148 mkdir("/apipe", 0777);
142 result = mount("", "/apipe", fs_type, 0, NULL); 149 result = mount("", "/apipe", fs_type, 0, NULL);
143 if (result != 0) { 150 if (result != 0) {
144 fprintf(stderr, "error: mount of '%s' failed: %d.\n", fs_type, result); 151 fprintf(stderr, "error: mount of '%s' failed: %d.\n", fs_type, result);
145 return 1;; 152 return 1;;
146 } 153 }
147 154
148 return 0; 155 return 0;
149 } 156 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698