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

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

Issue 1293543006: Make the default directory size returned by stat to be 4096 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/html5fs/html5_fs.h"
20 #include "nacl_io/kernel_handle.h" 20 #include "nacl_io/kernel_handle.h"
21 #include "nacl_io/osdirent.h" 21 #include "nacl_io/osdirent.h"
22 #include "nacl_io/pepper_interface.h" 22 #include "nacl_io/pepper_interface.h"
23 #include "sdk_util/auto_lock.h" 23 #include "sdk_util/auto_lock.h"
24 24
25 namespace nacl_io { 25 namespace nacl_io {
26 26
27 namespace { 27 namespace {
28 28
29 const int DIR_SIZE = 4096;
Sam Clegg 2015/08/13 21:33:48 How about EMPTY_DIR_SIZE?
binji 2015/08/13 21:44:52 Actually, Chromium style would be more like kEmpty
zhitingzhu 2015/08/13 22:26:00 Done.
30
29 struct OutputBuffer { 31 struct OutputBuffer {
30 void* data; 32 void* data;
31 int element_count; 33 int element_count;
32 }; 34 };
33 35
34 void* GetOutputBuffer(void* user_data, uint32_t count, uint32_t size) { 36 void* GetOutputBuffer(void* user_data, uint32_t count, uint32_t size) {
35 OutputBuffer* output = static_cast<OutputBuffer*>(user_data); 37 OutputBuffer* output = static_cast<OutputBuffer*>(user_data);
36 output->element_count = count; 38 output->element_count = count;
37 if (count) { 39 if (count) {
38 output->data = malloc(count * size); 40 output->data = malloc(count * size);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 stat->st_mode |= S_IFREG; 164 stat->st_mode |= S_IFREG;
163 break; 165 break;
164 case PP_FILETYPE_DIRECTORY: 166 case PP_FILETYPE_DIRECTORY:
165 stat->st_mode |= S_IFDIR; 167 stat->st_mode |= S_IFDIR;
166 break; 168 break;
167 case PP_FILETYPE_OTHER: 169 case PP_FILETYPE_OTHER:
168 default: 170 default:
169 break; 171 break;
170 } 172 }
171 stat->st_size = static_cast<off_t>(info.size); 173 stat->st_size = static_cast<off_t>(info.size);
174 // Hack the directory size
175 // In Linux, even a empty directory has size 4096
176 if (info.type == PP_FILETYPE_DIRECTORY && info.size == 0)
177 stat->st_size = DIR_SIZE;
Sam Clegg 2015/08/13 21:33:48 Move this up into the existing switch statement?
zhitingzhu 2015/08/13 22:26:00 I try to look at the source code to see how the di
172 stat->st_atime = info.last_access_time; 178 stat->st_atime = info.last_access_time;
173 stat->st_mtime = info.last_modified_time; 179 stat->st_mtime = info.last_modified_time;
174 stat->st_ctime = info.creation_time; 180 stat->st_ctime = info.creation_time;
175 181
176 return 0; 182 return 0;
177 } 183 }
178 184
179 Error Html5FsNode::Read(const HandleAttr& attr, 185 Error Html5FsNode::Read(const HandleAttr& attr,
180 void* buf, 186 void* buf,
181 size_t count, 187 size_t count,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 fileref_resource_ = 0; 322 fileref_resource_ = 0;
317 Node::Destroy(); 323 Node::Destroy();
318 } 324 }
319 325
320 Error Html5FsNode::Fchmod(mode_t mode) { 326 Error Html5FsNode::Fchmod(mode_t mode) {
321 // html5fs does not support any kinds of permissions or mode bits. 327 // html5fs does not support any kinds of permissions or mode bits.
322 return 0; 328 return 0;
323 } 329 }
324 330
325 } // namespace nacl_io 331 } // namespace nacl_io
OLDNEW
« no previous file with comments | « no previous file | 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