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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.cc

Issue 605513002: [NaCl SDK] nacl_io: Replace allocated ino with hash of path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits Created 6 years, 2 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 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/html5fs/html5_fs_node.h" 5 #include "nacl_io/html5fs/html5_fs_node.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <ppapi/c/pp_completion_callback.h> 9 #include <ppapi/c/pp_completion_callback.h>
10 #include <ppapi/c/pp_directory_entry.h> 10 #include <ppapi/c/pp_directory_entry.h>
11 #include <ppapi/c/pp_errors.h> 11 #include <ppapi/c/pp_errors.h>
12 #include <ppapi/c/pp_file_info.h> 12 #include <ppapi/c/pp_file_info.h>
13 #include <ppapi/c/ppb_file_io.h> 13 #include <ppapi/c/ppb_file_io.h>
14 #include <string.h> 14 #include <string.h>
15 #include <vector> 15 #include <vector>
16 16
17 #include "nacl_io/filesystem.h" 17 #include "nacl_io/filesystem.h"
18 #include "nacl_io/getdents_helper.h" 18 #include "nacl_io/getdents_helper.h"
19 #include "nacl_io/html5fs/html5_fs.h"
19 #include "nacl_io/kernel_handle.h" 20 #include "nacl_io/kernel_handle.h"
20 #include "nacl_io/osdirent.h" 21 #include "nacl_io/osdirent.h"
21 #include "nacl_io/pepper_interface.h" 22 #include "nacl_io/pepper_interface.h"
22 #include "sdk_util/auto_lock.h" 23 #include "sdk_util/auto_lock.h"
23 24
24 namespace nacl_io { 25 namespace nacl_io {
25 26
26 namespace { 27 namespace {
27 28
28 struct OutputBuffer { 29 struct OutputBuffer {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 119
119 uint32_t file_name_length; 120 uint32_t file_name_length;
120 const char* file_name = 121 const char* file_name =
121 var_iface_->VarToUtf8(file_name_var, &file_name_length); 122 var_iface_->VarToUtf8(file_name_var, &file_name_length);
122 123
123 if (file_name) { 124 if (file_name) {
124 file_name_length = 125 file_name_length =
125 std::min(static_cast<size_t>(file_name_length), 126 std::min(static_cast<size_t>(file_name_length),
126 MEMBER_SIZE(dirent, d_name) - 1); // -1 for NULL. 127 MEMBER_SIZE(dirent, d_name) - 1); // -1 for NULL.
127 128
128 // TODO(binji): Better handling of ino numbers. 129 // The INO is based on the running hash of fully qualified path, so
129 helper.AddDirent(1, file_name, file_name_length); 130 // a childs INO must be the parent directories hash, plus '/', plus
131 // the filename.
132 ino_t child_ino = Html5Fs::HashPathSegment(stat_.st_ino, file_name,
133 file_name_length);
134
135 helper.AddDirent(child_ino, file_name, file_name_length);
130 } 136 }
131 137
132 var_iface_->Release(file_name_var); 138 var_iface_->Release(file_name_var);
133 } 139 }
134 140
135 // Release the output buffer. 141 // Release the output buffer.
136 free(output_buf.data); 142 free(output_buf.data);
137 143
138 return helper.GetDents(offs, pdir, size, out_bytes); 144 return helper.GetDents(offs, pdir, size, out_bytes);
139 } 145 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 filesystem_->ppapi()->ReleaseResource(fileio_resource_); 311 filesystem_->ppapi()->ReleaseResource(fileio_resource_);
306 } 312 }
307 313
308 filesystem_->ppapi()->ReleaseResource(fileref_resource_); 314 filesystem_->ppapi()->ReleaseResource(fileref_resource_);
309 fileio_resource_ = 0; 315 fileio_resource_ = 0;
310 fileref_resource_ = 0; 316 fileref_resource_ = 0;
311 Node::Destroy(); 317 Node::Destroy();
312 } 318 }
313 319
314 } // namespace nacl_io 320 } // namespace nacl_io
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs.cc ('k') | native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698