Commit 865a65ad authored by binji's avatar binji Committed by Commit bot

[NaCl SDK] nacl_io: Fix html5fs stat on directories

This used to return RWX, but regressed as of
314a240e.

BUG=none
R=sbc@chromium.org
R=bradnelson@chromium.org

Review URL: https://codereview.chromium.org/587933003

Cr-Commit-Position: refs/heads/master@{#295844}
parent e193568d
......@@ -268,13 +268,17 @@ Error Html5FsNode::Init(int open_flags) {
return EIO;
}
// Set all files and directories to RWX.
SetMode(S_IWALL | S_IRALL | S_IXALL);
// First query the FileRef to see if it is a file or directory.
PP_FileInfo file_info;
int32_t query_result = file_ref_iface_->Query(
fileref_resource_, &file_info, PP_BlockUntilComplete());
// If this is a directory, do not get a FileIO.
if (query_result == PP_OK && file_info.type == PP_FILETYPE_DIRECTORY)
if (query_result == PP_OK && file_info.type == PP_FILETYPE_DIRECTORY) {
return 0;
}
fileio_resource_ =
file_io_iface_->Create(filesystem_->ppapi()->GetInstance());
......
......@@ -389,8 +389,7 @@ TEST_F(Html5FsTest, GetStat) {
struct stat statbuf;
EXPECT_EQ(0, node->GetStat(&statbuf));
EXPECT_EQ(S_IFREG, statbuf.st_mode & S_IFMT);
EXPECT_EQ(S_IRUSR | S_IRGRP | S_IROTH |
S_IWUSR | S_IWGRP | S_IWOTH, statbuf.st_mode & ~S_IFMT);
EXPECT_EQ(S_IRALL | S_IWALL | S_IXALL, statbuf.st_mode & ~S_IFMT);
EXPECT_EQ(strlen(contents), statbuf.st_size);
EXPECT_EQ(access_time, statbuf.st_atime);
EXPECT_EQ(creation_time, statbuf.st_ctime);
......@@ -408,8 +407,7 @@ TEST_F(Html5FsTest, GetStat) {
EXPECT_EQ(0, fs->Open(Path("/dir"), O_RDONLY, &node));
EXPECT_EQ(0, node->GetStat(&statbuf));
EXPECT_EQ(S_IFDIR, statbuf.st_mode & S_IFMT);
EXPECT_EQ(S_IRUSR | S_IRGRP | S_IROTH |
S_IWUSR | S_IWGRP | S_IWOTH, statbuf.st_mode & ~S_IFMT);
EXPECT_EQ(S_IRALL | S_IWALL | S_IXALL, statbuf.st_mode & ~S_IFMT);
EXPECT_EQ(0, statbuf.st_size);
EXPECT_EQ(access_time, statbuf.st_atime);
EXPECT_EQ(creation_time, statbuf.st_ctime);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment