diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 194acee..93d285c 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -1561,6 +1561,17 @@ static int s3fs_chmod(const char* path, mode_t mode) return -EIO; } StatCache::getStatCacheData()->DelStat(nowcache); + + // check opened file handle. + // + // If we have already opened file handle, should set mode to it. + // And new mode is set when the file handle is closed. + // + FdEntity* ent; + if(NULL != (ent = FdManager::get()->ExistOpen(path))){ + ent->SetMode(mode); // Set new mode to opened fd. + FdManager::get()->Close(ent); + } } S3FS_MALLOCTRIM(0); diff --git a/test/integration-test-main.sh b/test/integration-test-main.sh index 693d5fc..b9618ea 100755 --- a/test/integration-test-main.sh +++ b/test/integration-test-main.sh @@ -207,8 +207,13 @@ function test_chown { # if they're the same, we have a problem. if [ $(stat --format=%u:%g $TEST_TEXT_FILE) == $ORIGINAL_PERMISSIONS ] then - echo "Could not modify $TEST_TEXT_FILE ownership" - return 1 + if [ $ORIGINAL_PERMISSIONS == "1000:1000" ] + then + echo "Could not be strict check because original file permission 1000:1000" + else + echo "Could not modify $TEST_TEXT_FILE ownership($ORIGINAL_PERMISSIONS to 1000:1000)" + return 1 + fi fi # clean up