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

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 kEmptyDirSize = 4096;
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 151
150 PP_FileInfo info; 152 PP_FileInfo info;
151 int32_t result = 153 int32_t result =
152 file_ref_iface_->Query(fileref_resource_, &info, PP_BlockUntilComplete()); 154 file_ref_iface_->Query(fileref_resource_, &info, PP_BlockUntilComplete());
153 if (result != PP_OK) 155 if (result != PP_OK)
154 return PPERROR_TO_ERRNO(result); 156 return PPERROR_TO_ERRNO(result);
155 157
156 // Fill in known info here. 158 // Fill in known info here.
157 memcpy(stat, &stat_, sizeof(stat_)); 159 memcpy(stat, &stat_, sizeof(stat_));
158 160
161 stat->st_size = static_cast<off_t>(info.size);
162
159 // Fill in the additional info from ppapi. 163 // Fill in the additional info from ppapi.
160 switch (info.type) { 164 switch (info.type) {
161 case PP_FILETYPE_REGULAR: 165 case PP_FILETYPE_REGULAR:
162 stat->st_mode |= S_IFREG; 166 stat->st_mode |= S_IFREG;
163 break; 167 break;
164 case PP_FILETYPE_DIRECTORY: 168 case PP_FILETYPE_DIRECTORY:
165 stat->st_mode |= S_IFDIR; 169 stat->st_mode |= S_IFDIR;
170 // Hack the directory size
171 // In Linux, even a empty directory has size 4096
172 // info.size is always zero for directories
173 stat->st_size = kEmptyDirSize;
166 break; 174 break;
167 case PP_FILETYPE_OTHER: 175 case PP_FILETYPE_OTHER:
168 default: 176 default:
169 break; 177 break;
170 } 178 }
171 stat->st_size = static_cast<off_t>(info.size);
172 stat->st_atime = info.last_access_time; 179 stat->st_atime = info.last_access_time;
173 stat->st_mtime = info.last_modified_time; 180 stat->st_mtime = info.last_modified_time;
174 stat->st_ctime = info.creation_time; 181 stat->st_ctime = info.creation_time;
175 182
176 return 0; 183 return 0;
177 } 184 }
178 185
179 Error Html5FsNode::Read(const HandleAttr& attr, 186 Error Html5FsNode::Read(const HandleAttr& attr,
180 void* buf, 187 void* buf,
181 size_t count, 188 size_t count,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 fileref_resource_ = 0; 323 fileref_resource_ = 0;
317 Node::Destroy(); 324 Node::Destroy();
318 } 325 }
319 326
320 Error Html5FsNode::Fchmod(mode_t mode) { 327 Error Html5FsNode::Fchmod(mode_t mode) {
321 // html5fs does not support any kinds of permissions or mode bits. 328 // html5fs does not support any kinds of permissions or mode bits.
322 return 0; 329 return 0;
323 } 330 }
324 331
325 } // namespace nacl_io 332 } // 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