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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/jsfs/js_fs.cc

Issue 349703003: [NaCl SDK] Add some more logging to nacl_io. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix linux host build Created 6 years, 6 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "nacl_io/jsfs/js_fs.h" 5 #include "nacl_io/jsfs/js_fs.h"
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 <limits.h> 10 #include <limits.h>
11 #include <string.h> 11 #include <string.h>
12 12
13 #include "nacl_io/ioctl.h" 13 #include "nacl_io/ioctl.h"
14 #include "nacl_io/jsfs/js_fs_node.h" 14 #include "nacl_io/jsfs/js_fs_node.h"
15 #include "nacl_io/kernel_handle.h" 15 #include "nacl_io/kernel_handle.h"
16 #include "nacl_io/log.h" 16 #include "nacl_io/log.h"
17 #include "nacl_io/osdirent.h" 17 #include "nacl_io/osdirent.h"
18 #include "nacl_io/pepper_interface.h" 18 #include "nacl_io/pepper_interface.h"
19 #include "sdk_util/macros.h" 19 #include "sdk_util/macros.h"
20 20
21 #define TRACE(format, ...) \
22 LOG_TRACE("%s:%d: " format, __FILE__, __LINE__, ##__VA_ARGS__)
23 #define ERROR(format, ...) \
24 LOG_ERROR("%s:%d: " format, __FILE__, __LINE__, ##__VA_ARGS__)
25
26 namespace nacl_io { 21 namespace nacl_io {
27 22
28 JsFs::JsFs() 23 JsFs::JsFs()
29 : messaging_iface_(NULL), 24 : messaging_iface_(NULL),
30 array_iface_(NULL), 25 array_iface_(NULL),
31 buffer_iface_(NULL), 26 buffer_iface_(NULL),
32 dict_iface_(NULL), 27 dict_iface_(NULL),
33 var_iface_(NULL), 28 var_iface_(NULL),
34 request_id_(0) { 29 request_id_(0) {
35 } 30 }
36 31
37 Error JsFs::Init(const FsInitArgs& args) { 32 Error JsFs::Init(const FsInitArgs& args) {
38 Error error = Filesystem::Init(args); 33 Error error = Filesystem::Init(args);
39 if (error) 34 if (error)
40 return error; 35 return error;
41 36
42 pthread_cond_init(&response_cond_, NULL); 37 pthread_cond_init(&response_cond_, NULL);
43 38
44 messaging_iface_ = ppapi_->GetMessagingInterface(); 39 messaging_iface_ = ppapi_->GetMessagingInterface();
45 array_iface_ = ppapi_->GetVarArrayInterface(); 40 array_iface_ = ppapi_->GetVarArrayInterface();
46 buffer_iface_ = ppapi_->GetVarArrayBufferInterface(); 41 buffer_iface_ = ppapi_->GetVarArrayBufferInterface();
47 dict_iface_ = ppapi_->GetVarDictionaryInterface(); 42 dict_iface_ = ppapi_->GetVarDictionaryInterface();
48 var_iface_ = ppapi_->GetVarInterface(); 43 var_iface_ = ppapi_->GetVarInterface();
49 44
50 if (!messaging_iface_ || !array_iface_ || !buffer_iface_ || !dict_iface_ || 45 if (!messaging_iface_ || !array_iface_ || !buffer_iface_ || !dict_iface_ ||
51 !var_iface_) { 46 !var_iface_) {
52 ERROR("Got 1+ NULL interface(s): %s%s%s%s%s", 47 LOG_ERROR("Got 1+ NULL interface(s): %s%s%s%s%s",
53 messaging_iface_ ? "" : "Messaging ", 48 messaging_iface_ ? "" : "Messaging ",
54 array_iface_ ? "" : "VarArray ", 49 array_iface_ ? "" : "VarArray ",
55 buffer_iface_ ? "" : "VarArrayBuffer ", 50 buffer_iface_ ? "" : "VarArrayBuffer ",
56 dict_iface_ ? "" : "VarDictionary ", 51 dict_iface_ ? "" : "VarDictionary ",
57 var_iface_ ? "" : "Var "); 52 var_iface_ ? "" : "Var ");
58 return ENOSYS; 53 return ENOSYS;
59 } 54 }
60 55
61 return 0; 56 return 0;
62 } 57 }
63 58
64 void JsFs::Destroy() { 59 void JsFs::Destroy() {
65 pthread_cond_destroy(&response_cond_); 60 pthread_cond_destroy(&response_cond_);
66 } 61 }
67 62
68 bool JsFs::SetDictVar(PP_Var dict, const char* key, PP_Var value) { 63 bool JsFs::SetDictVar(PP_Var dict, const char* key, PP_Var value) {
69 PP_Var key_var = var_iface_->VarFromUtf8(key, strlen(key)); 64 PP_Var key_var = var_iface_->VarFromUtf8(key, strlen(key));
70 ScopedVar scoped_key(ppapi_, key_var); 65 ScopedVar scoped_key(ppapi_, key_var);
71 if (key_var.type != PP_VARTYPE_STRING) { 66 if (key_var.type != PP_VARTYPE_STRING) {
72 ERROR("Unable to create string key \"%s\".", key); 67 LOG_ERROR("Unable to create string key \"%s\".", key);
73 return false; 68 return false;
74 } 69 }
75 70
76 PP_Bool success = dict_iface_->Set(dict, key_var, value); 71 PP_Bool success = dict_iface_->Set(dict, key_var, value);
77 if (!success) { 72 if (!success) {
78 ERROR("Unable to set \"%s\" key of dictionary.", key); 73 LOG_ERROR("Unable to set \"%s\" key of dictionary.", key);
79 return false; 74 return false;
80 } 75 }
81 76
82 return true; 77 return true;
83 } 78 }
84 79
85 PP_Var JsFs::GetDictVar(PP_Var dict, const char* key) { 80 PP_Var JsFs::GetDictVar(PP_Var dict, const char* key) {
86 PP_Var key_var = var_iface_->VarFromUtf8(key, strlen(key)); 81 PP_Var key_var = var_iface_->VarFromUtf8(key, strlen(key));
87 ScopedVar scoped_key(ppapi_, key_var); 82 ScopedVar scoped_key(ppapi_, key_var);
88 if (key_var.type != PP_VARTYPE_STRING) { 83 if (key_var.type != PP_VARTYPE_STRING) {
89 ERROR("Unable to create string key \"%s\".", key); 84 LOG_ERROR("Unable to create string key \"%s\".", key);
90 return PP_MakeUndefined(); 85 return PP_MakeUndefined();
91 } 86 }
92 87
93 return dict_iface_->Get(dict, key_var); 88 return dict_iface_->Get(dict, key_var);
94 } 89 }
95 90
96 bool JsFs::GetVarInt32(PP_Var var, int32_t* out_value) { 91 bool JsFs::GetVarInt32(PP_Var var, int32_t* out_value) {
97 switch (var.type) { 92 switch (var.type) {
98 case PP_VARTYPE_INT32: 93 case PP_VARTYPE_INT32:
99 *out_value = var.value.as_int; 94 *out_value = var.value.as_int;
(...skipping 29 matching lines...) Expand all
129 *out_value = var.value.as_int; 124 *out_value = var.value.as_int;
130 return true; 125 return true;
131 126
132 case PP_VARTYPE_DOUBLE: 127 case PP_VARTYPE_DOUBLE:
133 *out_value = static_cast<int64_t>(var.value.as_double); 128 *out_value = static_cast<int64_t>(var.value.as_double);
134 return true; 129 return true;
135 130
136 case PP_VARTYPE_ARRAY: { 131 case PP_VARTYPE_ARRAY: {
137 uint32_t len = array_iface_->GetLength(var); 132 uint32_t len = array_iface_->GetLength(var);
138 if (len != 2) { 133 if (len != 2) {
139 ERROR("Expected int64 array type to have 2 elements, not %d", len); 134 LOG_ERROR("Expected int64 array type to have 2 elements, not %d", len);
140 return false; 135 return false;
141 } 136 }
142 137
143 PP_Var high_int_var = array_iface_->Get(var, 0); 138 PP_Var high_int_var = array_iface_->Get(var, 0);
144 ScopedVar scoped_high_int_var(ppapi_, high_int_var); 139 ScopedVar scoped_high_int_var(ppapi_, high_int_var);
145 uint32_t high_int; 140 uint32_t high_int;
146 if (!GetVarUint32(high_int_var, &high_int)) 141 if (!GetVarUint32(high_int_var, &high_int))
147 return false; 142 return false;
148 143
149 PP_Var low_int_var = array_iface_->Get(var, 1); 144 PP_Var low_int_var = array_iface_->Get(var, 1);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 case 'd': 178 case 'd':
184 value_var = PP_MakeInt32(va_arg(args, int32_t)); 179 value_var = PP_MakeInt32(va_arg(args, int32_t));
185 break; 180 break;
186 case 'u': 181 case 'u':
187 value_var = PP_MakeInt32(va_arg(args, uint32_t)); 182 value_var = PP_MakeInt32(va_arg(args, uint32_t));
188 break; 183 break;
189 case 's': { 184 case 's': {
190 const char* value = va_arg(args, const char*); 185 const char* value = va_arg(args, const char*);
191 value_var = var_iface_->VarFromUtf8(value, strlen(value)); 186 value_var = var_iface_->VarFromUtf8(value, strlen(value));
192 if (value_var.type != PP_VARTYPE_STRING) { 187 if (value_var.type != PP_VARTYPE_STRING) {
193 ERROR("Unable to create \"%s\" string var.", value); 188 LOG_ERROR("Unable to create \"%s\" string var.", value);
194 return PP_MakeNull(); 189 return PP_MakeNull();
195 } 190 }
196 break; 191 break;
197 } 192 }
198 case 'p': 193 case 'p':
199 value_var = *va_arg(args, const PP_Var*); 194 value_var = *va_arg(args, const PP_Var*);
200 var_iface_->AddRef(value_var); 195 var_iface_->AddRef(value_var);
201 break; 196 break;
202 case 'l': { 197 case 'l': {
203 // Only '%lld' is supported. 198 // Only '%lld' is supported.
204 ++p; 199 ++p;
205 assert(*p == 'l'); 200 assert(*p == 'l');
206 ++p; 201 ++p;
207 assert(*p == 'd'); 202 assert(*p == 'd');
208 203
209 int64_t value = va_arg(args, int64_t); 204 int64_t value = va_arg(args, int64_t);
210 if (value >= INT_MIN && value <= INT_MAX) { 205 if (value >= INT_MIN && value <= INT_MAX) {
211 // Send as an int. 206 // Send as an int.
212 value_var = PP_MakeInt32(static_cast<int32_t>(value)); 207 value_var = PP_MakeInt32(static_cast<int32_t>(value));
213 } else { 208 } else {
214 // Send as an array of two ints: [high int32, low int32]. 209 // Send as an array of two ints: [high int32, low int32].
215 value_var = array_iface_->Create(); 210 value_var = array_iface_->Create();
216 if (!array_iface_->SetLength(value_var, 2)) { 211 if (!array_iface_->SetLength(value_var, 2)) {
217 ERROR("Unable to set length of s64 array."); 212 LOG_ERROR("Unable to set length of s64 array.");
218 return PP_MakeNull(); 213 return PP_MakeNull();
219 } 214 }
220 215
221 if (!array_iface_->Set(value_var, 0, PP_MakeInt32(value >> 32))) { 216 if (!array_iface_->Set(value_var, 0, PP_MakeInt32(value >> 32))) {
222 ERROR("Unable to set of high int32 of s64 array."); 217 LOG_ERROR("Unable to set of high int32 of s64 array.");
223 return PP_MakeNull(); 218 return PP_MakeNull();
224 } 219 }
225 220
226 if (!array_iface_->Set( 221 if (!array_iface_->Set(
227 value_var, 1, PP_MakeInt32(value & 0xffffffff))) { 222 value_var, 1, PP_MakeInt32(value & 0xffffffff))) {
228 ERROR("Unable to set of low int32 of s64 array."); 223 LOG_ERROR("Unable to set of low int32 of s64 array.");
229 return PP_MakeNull(); 224 return PP_MakeNull();
230 } 225 }
231 } 226 }
232 227
233 break; 228 break;
234 } 229 }
235 default: 230 default:
236 ERROR("Unknown format specifier %%\"%s\"", p); 231 LOG_ERROR("Unknown format specifier %%\"%s\"", p);
237 assert(0); 232 assert(0);
238 return PP_MakeNull(); 233 return PP_MakeNull();
239 } 234 }
240 235
241 ++p; 236 ++p;
242 237
243 if (!SetDictVar(dict, key, value_var)) 238 if (!SetDictVar(dict, key, value_var))
244 return PP_MakeNull(); 239 return PP_MakeNull();
245 240
246 // Unconditionally release the value var. It is legal to do this even for 241 // Unconditionally release the value var. It is legal to do this even for
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 va_list args; 280 va_list args;
286 va_start(args, format); 281 va_start(args, format);
287 bool result = VSendRequestAndWait(out_response, format, args); 282 bool result = VSendRequestAndWait(out_response, format, args);
288 va_end(args); 283 va_end(args);
289 return result; 284 return result;
290 } 285 }
291 286
292 Error JsFs::ErrorFromResponse(const ScopedVar& response) { 287 Error JsFs::ErrorFromResponse(const ScopedVar& response) {
293 int32_t error; 288 int32_t error;
294 if (ScanVar(response.pp_var(), "%d", "error", &error) != 1) { 289 if (ScanVar(response.pp_var(), "%d", "error", &error) != 1) {
295 ERROR("Expected \"error\" field in response."); 290 LOG_ERROR("Expected \"error\" field in response.");
296 return EINVAL; 291 return EINVAL;
297 } 292 }
298 293
299 return error; 294 return error;
300 } 295 }
301 296
302 int JsFs::ScanVar(PP_Var var, const char* format, ...) { 297 int JsFs::ScanVar(PP_Var var, const char* format, ...) {
303 va_list args; 298 va_list args;
304 va_start(args, format); 299 va_start(args, format);
305 int result = VScanVar(var, format, args); 300 int result = VScanVar(var, format, args);
306 va_end(args); 301 va_end(args);
307 return result; 302 return result;
308 } 303 }
309 304
310 int JsFs::VScanVar(PP_Var dict_var, const char* format, va_list args) { 305 int JsFs::VScanVar(PP_Var dict_var, const char* format, va_list args) {
311 if (dict_var.type != PP_VARTYPE_DICTIONARY) { 306 if (dict_var.type != PP_VARTYPE_DICTIONARY) {
312 ERROR("Expected var of type dictionary, not %d.", dict_var.type); 307 LOG_ERROR("Expected var of type dictionary, not %d.", dict_var.type);
313 return 0; 308 return 0;
314 } 309 }
315 310
316 int num_values = 0; 311 int num_values = 0;
317 312
318 const char* p = format; 313 const char* p = format;
319 while (*p) { 314 while (*p) {
320 assert(*p == '%'); 315 assert(*p == '%');
321 ++p; 316 ++p;
322 317
323 const char* key = va_arg(args, const char*); 318 const char* key = va_arg(args, const char*);
324 PP_Var value_var = GetDictVar(dict_var, key); 319 PP_Var value_var = GetDictVar(dict_var, key);
325 ScopedVar scoped_value_var(ppapi_, value_var); 320 ScopedVar scoped_value_var(ppapi_, value_var);
326 321
327 if (value_var.type == PP_VARTYPE_UNDEFINED) 322 if (value_var.type == PP_VARTYPE_UNDEFINED)
328 break; 323 break;
329 324
330 bool ok = true; 325 bool ok = true;
331 326
332 switch (*p) { 327 switch (*p) {
333 case 'd': { 328 case 'd': {
334 int32_t* value = va_arg(args, int32_t*); 329 int32_t* value = va_arg(args, int32_t*);
335 if (!GetVarInt32(value_var, value)) { 330 if (!GetVarInt32(value_var, value)) {
336 ERROR("Expected int32_t value for key \"%s\"", key); 331 LOG_ERROR("Expected int32_t value for key \"%s\"", key);
337 ok = false; 332 ok = false;
338 } 333 }
339 break; 334 break;
340 } 335 }
341 case 'u': { 336 case 'u': {
342 uint32_t* value = va_arg(args, uint32_t*); 337 uint32_t* value = va_arg(args, uint32_t*);
343 if (!GetVarUint32(value_var, value)) { 338 if (!GetVarUint32(value_var, value)) {
344 ERROR("Expected uint32_t value for key \"%s\"", key); 339 LOG_ERROR("Expected uint32_t value for key \"%s\"", key);
345 ok = false; 340 ok = false;
346 } 341 }
347 break; 342 break;
348 } 343 }
349 case 'l': { 344 case 'l': {
350 // Only '%lld' is supported. 345 // Only '%lld' is supported.
351 ++p; 346 ++p;
352 assert(*p == 'l'); 347 assert(*p == 'l');
353 ++p; 348 ++p;
354 assert(*p == 'd'); 349 assert(*p == 'd');
355 350
356 int64_t* value = va_arg(args, int64_t*); 351 int64_t* value = va_arg(args, int64_t*);
357 if (!GetVarInt64(value_var, value)) { 352 if (!GetVarInt64(value_var, value)) {
358 ERROR("Expected int64_t value for key \"%s\"", key); 353 LOG_ERROR("Expected int64_t value for key \"%s\"", key);
359 ok = false; 354 ok = false;
360 } 355 }
361 break; 356 break;
362 } 357 }
363 case 'p': { 358 case 'p': {
364 PP_Var* value = va_arg(args, PP_Var*); 359 PP_Var* value = va_arg(args, PP_Var*);
365 *value = scoped_value_var.Release(); 360 *value = scoped_value_var.Release();
366 break; 361 break;
367 } 362 }
368 default: 363 default:
369 ERROR("Unknown format specifier %%\"%s\"", p); 364 LOG_ERROR("Unknown format specifier %%\"%s\"", p);
370 assert(0); 365 assert(0);
371 ok = false; 366 ok = false;
372 break; 367 break;
373 } 368 }
374 369
375 if (!ok) 370 if (!ok)
376 break; 371 break;
377 372
378 p++; 373 p++;
379 num_values++; 374 num_values++;
(...skipping 15 matching lines...) Expand all
395 pthread_cond_wait(&response_cond_, lock_.mutex()); 390 pthread_cond_wait(&response_cond_, lock_.mutex());
396 } 391 }
397 } 392 }
398 393
399 Error JsFs::Access(const Path& path, int a_mode) { 394 Error JsFs::Access(const Path& path, int a_mode) {
400 ScopedVar response(ppapi_); 395 ScopedVar response(ppapi_);
401 if (!SendRequestAndWait(&response, "%s%s%d", 396 if (!SendRequestAndWait(&response, "%s%s%d",
402 "cmd", "access", 397 "cmd", "access",
403 "path", path.Join().c_str(), 398 "path", path.Join().c_str(),
404 "amode", a_mode)) { 399 "amode", a_mode)) {
405 ERROR("Failed to send request."); 400 LOG_ERROR("Failed to send request.");
406 return EINVAL; 401 return EINVAL;
407 } 402 }
408 403
409 return ErrorFromResponse(response); 404 return ErrorFromResponse(response);
410 } 405 }
411 406
412 Error JsFs::Open(const Path& path, int open_flags, ScopedNode* out_node) { 407 Error JsFs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
413 out_node->reset(NULL); 408 out_node->reset(NULL);
414 ScopedVar response(ppapi_); 409 ScopedVar response(ppapi_);
415 if (!SendRequestAndWait(&response, "%s%s%d", 410 if (!SendRequestAndWait(&response, "%s%s%d",
416 "cmd", "open", 411 "cmd", "open",
417 "path", path.Join().c_str(), 412 "path", path.Join().c_str(),
418 "oflag", open_flags)) { 413 "oflag", open_flags)) {
419 ERROR("Failed to send request."); 414 LOG_ERROR("Failed to send request.");
420 return EINVAL; 415 return EINVAL;
421 } 416 }
422 417
423 int32_t error; 418 int32_t error;
424 int32_t fd; 419 int32_t fd;
425 int result = ScanVar(response.pp_var(), "%d%d", "error", &error, "fd", &fd); 420 int result = ScanVar(response.pp_var(), "%d%d", "error", &error, "fd", &fd);
426 if (result >= 1 && error) 421 if (result >= 1 && error)
427 return error; 422 return error;
428 423
429 if (result != 2) { 424 if (result != 2) {
430 ERROR("Expected \"error\" and \"fd\" fields in response."); 425 LOG_ERROR("Expected \"error\" and \"fd\" fields in response.");
431 return EINVAL; 426 return EINVAL;
432 } 427 }
433 428
434 out_node->reset(new JsFsNode(this, fd)); 429 out_node->reset(new JsFsNode(this, fd));
435 return 0; 430 return 0;
436 } 431 }
437 432
438 Error JsFs::Unlink(const Path& path) { 433 Error JsFs::Unlink(const Path& path) {
439 ScopedVar response(ppapi_); 434 ScopedVar response(ppapi_);
440 if (!SendRequestAndWait( 435 if (!SendRequestAndWait(
441 &response, "%s%s", "cmd", "unlink", "path", path.Join().c_str())) { 436 &response, "%s%s", "cmd", "unlink", "path", path.Join().c_str())) {
442 ERROR("Failed to send request."); 437 LOG_ERROR("Failed to send request.");
443 return EINVAL; 438 return EINVAL;
444 } 439 }
445 440
446 return ErrorFromResponse(response); 441 return ErrorFromResponse(response);
447 } 442 }
448 443
449 Error JsFs::Mkdir(const Path& path, int perm) { 444 Error JsFs::Mkdir(const Path& path, int perm) {
450 ScopedVar response(ppapi_); 445 ScopedVar response(ppapi_);
451 if (!SendRequestAndWait(&response, "%s%s%d", 446 if (!SendRequestAndWait(&response, "%s%s%d",
452 "cmd", "mkdir", 447 "cmd", "mkdir",
453 "path", path.Join().c_str(), 448 "path", path.Join().c_str(),
454 "mode", perm)) { 449 "mode", perm)) {
455 ERROR("Failed to send request."); 450 LOG_ERROR("Failed to send request.");
456 return EINVAL; 451 return EINVAL;
457 } 452 }
458 453
459 return ErrorFromResponse(response); 454 return ErrorFromResponse(response);
460 } 455 }
461 456
462 Error JsFs::Rmdir(const Path& path) { 457 Error JsFs::Rmdir(const Path& path) {
463 ScopedVar response(ppapi_); 458 ScopedVar response(ppapi_);
464 if (!SendRequestAndWait( 459 if (!SendRequestAndWait(
465 &response, "%s%s", "cmd", "rmdir", "path", path.Join().c_str())) { 460 &response, "%s%s", "cmd", "rmdir", "path", path.Join().c_str())) {
466 ERROR("Failed to send request."); 461 LOG_ERROR("Failed to send request.");
467 return EINVAL; 462 return EINVAL;
468 } 463 }
469 464
470 return ErrorFromResponse(response); 465 return ErrorFromResponse(response);
471 } 466 }
472 467
473 Error JsFs::Remove(const Path& path) { 468 Error JsFs::Remove(const Path& path) {
474 ScopedVar response(ppapi_); 469 ScopedVar response(ppapi_);
475 if (!SendRequestAndWait( 470 if (!SendRequestAndWait(
476 &response, "%s%s", "cmd", "remove", "path", path.Join().c_str())) { 471 &response, "%s%s", "cmd", "remove", "path", path.Join().c_str())) {
477 ERROR("Failed to send request."); 472 LOG_ERROR("Failed to send request.");
478 return EINVAL; 473 return EINVAL;
479 } 474 }
480 475
481 return ErrorFromResponse(response); 476 return ErrorFromResponse(response);
482 } 477 }
483 478
484 Error JsFs::Rename(const Path& path, const Path& newpath) { 479 Error JsFs::Rename(const Path& path, const Path& newpath) {
485 ScopedVar response(ppapi_); 480 ScopedVar response(ppapi_);
486 if (!SendRequestAndWait(&response, "%s%s%s", 481 if (!SendRequestAndWait(&response, "%s%s%s",
487 "cmd", "rename", 482 "cmd", "rename",
488 "old", path.Join().c_str(), 483 "old", path.Join().c_str(),
489 "new", newpath.Join().c_str())) { 484 "new", newpath.Join().c_str())) {
490 ERROR("Failed to send request."); 485 LOG_ERROR("Failed to send request.");
491 return EINVAL; 486 return EINVAL;
492 } 487 }
493 488
494 return ErrorFromResponse(response); 489 return ErrorFromResponse(response);
495 } 490 }
496 491
497 Error JsFs::Filesystem_VIoctl(int request, va_list args) { 492 Error JsFs::Filesystem_VIoctl(int request, va_list args) {
498 if (request != NACL_IOC_HANDLEMESSAGE) { 493 if (request != NACL_IOC_HANDLEMESSAGE) {
499 ERROR("Unknown ioctl: %#x", request); 494 LOG_ERROR("Unknown ioctl: %#x", request);
500 return EINVAL; 495 return EINVAL;
501 } 496 }
502 497
503 PP_Var response = *va_arg(args, PP_Var*); 498 PP_Var response = *va_arg(args, PP_Var*);
504 499
505 AUTO_LOCK(lock_); 500 AUTO_LOCK(lock_);
506 501
507 RequestId response_id; 502 RequestId response_id;
508 if (ScanVar(response, "%d", "id", &response_id) != 1) { 503 if (ScanVar(response, "%d", "id", &response_id) != 1) {
509 TRACE("ioctl with no \"id\", ignoring.\n"); 504 LOG_TRACE("ioctl with no \"id\", ignoring.\n");
510 return EINVAL; 505 return EINVAL;
511 } 506 }
512 507
513 responses_.insert(ResponseMap_t::value_type(response_id, response)); 508 responses_.insert(ResponseMap_t::value_type(response_id, response));
514 pthread_cond_broadcast(&response_cond_); 509 pthread_cond_broadcast(&response_cond_);
515 return 0; 510 return 0;
516 } 511 }
517 512
518 } // namespace nacl_io 513 } // namespace nacl_io
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698