{"action":"created","comment":{"url":"https://api.github.com/repos/OP-TEE/optee_os/pulls/comments/39499904","id":39499904,"diff_hunk":"@@ -1128,73 +1143,124 @@ tee_fs_off_t tee_fs_common_lseek(struct tee_fs_fd *fdp,\n }\n \n /*\n- * To ensure atomic ftruncate operation, we can:\n+ * To ensure atomic truncate operation, we can:\n  *\n  *  - update file length to new length\n  *  - commit new meta\n+ *  - free unused blocks\n  *\n- * (Any failure in above steps is considered as update failed,\n- *  and the file content will not be updated)\n+ * To ensure atomic extend operation, we can:\n  *\n- * After previous step the update is considered complete, but\n- * we should do the following clean-up step(s):\n+ *  - update file length to new length\n+ *  - allocate and fill zero data to new blocks\n+ *  - commit new meta\n  *\n- *  - free the trucated file blocks\n+ * Any failure before committing new meta is considered as\n+ * update failed, and the file content will not be updated\n  *\n- * (Any failure in above steps is considered as a successfully\n- *  update)\n  */\n int tee_fs_common_ftruncate(struct tee_fs_fd *fdp,\n \t\t\t\ttee_fs_off_t new_file_len)\n {\n \tint res = -1;\n-\tsize_t old_file_len;\n-\tint old_block_num, new_block_num, diff_blocks, i = 0;\n+\tsize_t old_file_len = fdp->meta->info.length;\n \tstruct tee_fs_file_meta *new_meta = NULL;\n+\tuint8_t *buf = NULL;\n \n \tif (!fdp)\n-\t\tgoto exit;\n+\t\treturn -1;\n \n-\tif (fdp->flags & TEE_FS_O_RDONLY)\n-\t\tgoto exit;\n+\tif (fdp->flags & TEE_FS_O_RDONLY) {\n+\t\tEMSG(\"Read only\");","path":"core/tee/tee_fs_common.c","position":159,"original_position":159,"commit_id":"8effffba6c585b408a0c34ef3975095b6e9aa58f","original_commit_id":"8effffba6c585b408a0c34ef3975095b6e9aa58f","user":{"login":"jbech-linaro","id":6168937,"avatar_url":"https://avatars.githubusercontent.com/u/6168937?v=3","gravatar_id":"","url":"https://api.github.com/users/jbech-linaro","html_url":"https://github.com/jbech-linaro","followers_url":"https://api.github.com/users/jbech-linaro/followers","following_url":"https://api.github.com/users/jbech-linaro/following{/other_user}","gists_url":"https://api.github.com/users/jbech-linaro/gists{/gist_id}","starred_url":"https://api.github.com/users/jbech-linaro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbech-linaro/subscriptions","organizations_url":"https://api.github.com/users/jbech-linaro/orgs","repos_url":"https://api.github.com/users/jbech-linaro/repos","events_url":"https://api.github.com/users/jbech-linaro/events{/privacy}","received_events_url":"https://api.github.com/users/jbech-linaro/received_events","type":"User","site_admin":false},"body":"A bit vague error message, but OK ...","created_at":"2015-09-15T11:37:12Z","updated_at":"2015-09-15T11:37:12Z","html_url":"https://github.com/OP-TEE/optee_os/pull/467#discussion_r39499904","pull_request_url":"https://api.github.com/repos/OP-TEE/optee_os/pulls/467","_links":{"self":{"href":"https://api.github.com/repos/OP-TEE/optee_os/pulls/comments/39499904"},"html":{"href":"https://github.com/OP-TEE/optee_os/pull/467#discussion_r39499904"},"pull_request":{"href":"https://api.github.com/repos/OP-TEE/optee_os/pulls/467"}}},"pull_request":{"url":"https://api.github.com/repos/OP-TEE/optee_os/pulls/467","id":44521260,"html_url":"https://github.com/OP-TEE/optee_os/pull/467","diff_url":"https://github.com/OP-TEE/optee_os/pull/467.diff","patch_url":"https://github.com/OP-TEE/optee_os/pull/467.patch","issue_url":"https://api.github.com/repos/OP-TEE/optee_os/issues/467","number":467,"state":"open","locked":false,"title":"Secure Storage: Support extending file size by truncate operation","user":{"login":"jamescfkung","id":10397509,"avatar_url":"https://avatars.githubusercontent.com/u/10397509?v=3","gravatar_id":"","url":"https://api.github.com/users/jamescfkung","html_url":"https://github.com/jamescfkung","followers_url":"https://api.github.com/users/jamescfkung/followers","following_url":"https://api.github.com/users/jamescfkung/following{/other_user}","gists_url":"https://api.github.com/users/jamescfkung/gists{/gist_id}","starred_url":"https://api.github.com/users/jamescfkung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamescfkung/subscriptions","organizations_url":"https://api.github.com/users/jamescfkung/orgs","repos_url":"https://api.github.com/users/jamescfkung/repos","events_url":"https://api.github.com/users/jamescfkung/events{/privacy}","received_events_url":"https://api.github.com/users/jamescfkung/received_events","type":"User","site_admin":false},"body":"Signed-off-by: James Kung <james.kung@linaro.org>\r\nTested-by: James Kung <james.kung@linaro.org> (QEMU, MT8173 EVB)","created_at":"2015-09-09T08:12:46Z","updated_at":"2015-09-15T11:37:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8fcc83a1d13d3479be7bb9270e9972a36978df6e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/OP-TEE/optee_os/pulls/467/commits","review_comments_url":"https://api.github.com/repos/OP-TEE/optee_os/pulls/467/comments","review_comment_url":"https://api.github.com/repos/OP-TEE/optee_os/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OP-TEE/optee_os/issues/467/comments","statuses_url":"https://api.github.com/repos/OP-TEE/optee_os/statuses/8effffba6c585b408a0c34ef3975095b6e9aa58f","head":{"label":"jamescfkung:extend_file_size","ref":"extend_file_size","sha":"8effffba6c585b408a0c34ef3975095b6e9aa58f","user":{"login":"jamescfkung","id":10397509,"avatar_url":"https://avatars.githubusercontent.com/u/10397509?v=3","gravatar_id":"","url":"https://api.github.com/users/jamescfkung","html_url":"https://github.com/jamescfkung","followers_url":"https://api.github.com/users/jamescfkung/followers","following_url":"https://api.github.com/users/jamescfkung/following{/other_user}","gists_url":"https://api.github.com/users/jamescfkung/gists{/gist_id}","starred_url":"https://api.github.com/users/jamescfkung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamescfkung/subscriptions","organizations_url":"https://api.github.com/users/jamescfkung/orgs","repos_url":"https://api.github.com/users/jamescfkung/repos","events_url":"https://api.github.com/users/jamescfkung/events{/privacy}","received_events_url":"https://api.github.com/users/jamescfkung/received_events","type":"User","site_admin":false},"repo":{"id":31949420,"name":"optee_os","full_name":"jamescfkung/optee_os","owner":{"login":"jamescfkung","id":10397509,"avatar_url":"https://avatars.githubusercontent.com/u/10397509?v=3","gravatar_id":"","url":"https://api.github.com/users/jamescfkung","html_url":"https://github.com/jamescfkung","followers_url":"https://api.github.com/users/jamescfkung/followers","following_url":"https://api.github.com/users/jamescfkung/following{/other_user}","gists_url":"https://api.github.com/users/jamescfkung/gists{/gist_id}","starred_url":"https://api.github.com/users/jamescfkung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamescfkung/subscriptions","organizations_url":"https://api.github.com/users/jamescfkung/orgs","repos_url":"https://api.github.com/users/jamescfkung/repos","events_url":"https://api.github.com/users/jamescfkung/events{/privacy}","received_events_url":"https://api.github.com/users/jamescfkung/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jamescfkung/optee_os","description":"Trusted side of the TEE","fork":true,"url":"https://api.github.com/repos/jamescfkung/optee_os","forks_url":"https://api.github.com/repos/jamescfkung/optee_os/forks","keys_url":"https://api.github.com/repos/jamescfkung/optee_os/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jamescfkung/optee_os/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jamescfkung/optee_os/teams","hooks_url":"https://api.github.com/repos/jamescfkung/optee_os/hooks","issue_events_url":"https://api.github.com/repos/jamescfkung/optee_os/issues/events{/number}","events_url":"https://api.github.com/repos/jamescfkung/optee_os/events","assignees_url":"https://api.github.com/repos/jamescfkung/optee_os/assignees{/user}","branches_url":"https://api.github.com/repos/jamescfkung/optee_os/branches{/branch}","tags_url":"https://api.github.com/repos/jamescfkung/optee_os/tags","blobs_url":"https://api.github.com/repos/jamescfkung/optee_os/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jamescfkung/optee_os/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jamescfkung/optee_os/git/refs{/sha}","trees_url":"https://api.github.com/repos/jamescfkung/optee_os/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jamescfkung/optee_os/statuses/{sha}","languages_url":"https://api.github.com/repos/jamescfkung/optee_os/languages","stargazers_url":"https://api.github.com/repos/jamescfkung/optee_os/stargazers","contributors_url":"https://api.github.com/repos/jamescfkung/optee_os/contributors","subscribers_url":"https://api.github.com/repos/jamescfkung/optee_os/subscribers","subscription_url":"https://api.github.com/repos/jamescfkung/optee_os/subscription","commits_url":"https://api.github.com/repos/jamescfkung/optee_os/commits{/sha}","git_commits_url":"https://api.github.com/repos/jamescfkung/optee_os/git/commits{/sha}","comments_url":"https://api.github.com/repos/jamescfkung/optee_os/comments{/number}","issue_comment_url":"https://api.github.com/repos/jamescfkung/optee_os/issues/comments{/number}","contents_url":"https://api.github.com/repos/jamescfkung/optee_os/contents/{+path}","compare_url":"https://api.github.com/repos/jamescfkung/optee_os/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jamescfkung/optee_os/merges","archive_url":"https://api.github.com/repos/jamescfkung/optee_os/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jamescfkung/optee_os/downloads","issues_url":"https://api.github.com/repos/jamescfkung/optee_os/issues{/number}","pulls_url":"https://api.github.com/repos/jamescfkung/optee_os/pulls{/number}","milestones_url":"https://api.github.com/repos/jamescfkung/optee_os/milestones{/number}","notifications_url":"https://api.github.com/repos/jamescfkung/optee_os/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jamescfkung/optee_os/labels{/name}","releases_url":"https://api.github.com/repos/jamescfkung/optee_os/releases{/id}","created_at":"2015-03-10T09:42:01Z","updated_at":"2015-04-16T03:06:45Z","pushed_at":"2015-09-14T18:18:14Z","git_url":"git://github.com/jamescfkung/optee_os.git","ssh_url":"git@github.com:jamescfkung/optee_os.git","clone_url":"https://github.com/jamescfkung/optee_os.git","svn_url":"https://github.com/jamescfkung/optee_os","homepage":null,"size":6180,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"OP-TEE:master","ref":"master","sha":"bfc6487bfeeeb48c61c2a756b97d719f5401edd5","user":{"login":"OP-TEE","id":7488961,"avatar_url":"https://avatars.githubusercontent.com/u/7488961?v=3","gravatar_id":"","url":"https://api.github.com/users/OP-TEE","html_url":"https://github.com/OP-TEE","followers_url":"https://api.github.com/users/OP-TEE/followers","following_url":"https://api.github.com/users/OP-TEE/following{/other_user}","gists_url":"https://api.github.com/users/OP-TEE/gists{/gist_id}","starred_url":"https://api.github.com/users/OP-TEE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OP-TEE/subscriptions","organizations_url":"https://api.github.com/users/OP-TEE/orgs","repos_url":"https://api.github.com/users/OP-TEE/repos","events_url":"https://api.github.com/users/OP-TEE/events{/privacy}","received_events_url":"https://api.github.com/users/OP-TEE/received_events","type":"Organization","site_admin":false},"repo":{"id":20193261,"name":"optee_os","full_name":"OP-TEE/optee_os","owner":{"login":"OP-TEE","id":7488961,"avatar_url":"https://avatars.githubusercontent.com/u/7488961?v=3","gravatar_id":"","url":"https://api.github.com/users/OP-TEE","html_url":"https://github.com/OP-TEE","followers_url":"https://api.github.com/users/OP-TEE/followers","following_url":"https://api.github.com/users/OP-TEE/following{/other_user}","gists_url":"https://api.github.com/users/OP-TEE/gists{/gist_id}","starred_url":"https://api.github.com/users/OP-TEE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OP-TEE/subscriptions","organizations_url":"https://api.github.com/users/OP-TEE/orgs","repos_url":"https://api.github.com/users/OP-TEE/repos","events_url":"https://api.github.com/users/OP-TEE/events{/privacy}","received_events_url":"https://api.github.com/users/OP-TEE/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OP-TEE/optee_os","description":"Trusted side of the TEE","fork":false,"url":"https://api.github.com/repos/OP-TEE/optee_os","forks_url":"https://api.github.com/repos/OP-TEE/optee_os/forks","keys_url":"https://api.github.com/repos/OP-TEE/optee_os/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OP-TEE/optee_os/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OP-TEE/optee_os/teams","hooks_url":"https://api.github.com/repos/OP-TEE/optee_os/hooks","issue_events_url":"https://api.github.com/repos/OP-TEE/optee_os/issues/events{/number}","events_url":"https://api.github.com/repos/OP-TEE/optee_os/events","assignees_url":"https://api.github.com/repos/OP-TEE/optee_os/assignees{/user}","branches_url":"https://api.github.com/repos/OP-TEE/optee_os/branches{/branch}","tags_url":"https://api.github.com/repos/OP-TEE/optee_os/tags","blobs_url":"https://api.github.com/repos/OP-TEE/optee_os/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OP-TEE/optee_os/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OP-TEE/optee_os/git/refs{/sha}","trees_url":"https://api.github.com/repos/OP-TEE/optee_os/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OP-TEE/optee_os/statuses/{sha}","languages_url":"https://api.github.com/repos/OP-TEE/optee_os/languages","stargazers_url":"https://api.github.com/repos/OP-TEE/optee_os/stargazers","contributors_url":"https://api.github.com/repos/OP-TEE/optee_os/contributors","subscribers_url":"https://api.github.com/repos/OP-TEE/optee_os/subscribers","subscription_url":"https://api.github.com/repos/OP-TEE/optee_os/subscription","commits_url":"https://api.github.com/repos/OP-TEE/optee_os/commits{/sha}","git_commits_url":"https://api.github.com/repos/OP-TEE/optee_os/git/commits{/sha}","comments_url":"https://api.github.com/repos/OP-TEE/optee_os/comments{/number}","issue_comment_url":"https://api.github.com/repos/OP-TEE/optee_os/issues/comments{/number}","contents_url":"https://api.github.com/repos/OP-TEE/optee_os/contents/{+path}","compare_url":"https://api.github.com/repos/OP-TEE/optee_os/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OP-TEE/optee_os/merges","archive_url":"https://api.github.com/repos/OP-TEE/optee_os/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OP-TEE/optee_os/downloads","issues_url":"https://api.github.com/repos/OP-TEE/optee_os/issues{/number}","pulls_url":"https://api.github.com/repos/OP-TEE/optee_os/pulls{/number}","milestones_url":"https://api.github.com/repos/OP-TEE/optee_os/milestones{/number}","notifications_url":"https://api.github.com/repos/OP-TEE/optee_os/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OP-TEE/optee_os/labels{/name}","releases_url":"https://api.github.com/repos/OP-TEE/optee_os/releases{/id}","created_at":"2014-05-26T17:18:57Z","updated_at":"2015-09-14T09:40:17Z","pushed_at":"2015-09-15T09:43:32Z","git_url":"git://github.com/OP-TEE/optee_os.git","ssh_url":"git@github.com:OP-TEE/optee_os.git","clone_url":"https://github.com/OP-TEE/optee_os.git","svn_url":"https://github.com/OP-TEE/optee_os","homepage":null,"size":10423,"stargazers_count":61,"watchers_count":61,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":58,"mirror_url":null,"open_issues_count":16,"forks":58,"open_issues":16,"watchers":61,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OP-TEE/optee_os/pulls/467"},"html":{"href":"https://github.com/OP-TEE/optee_os/pull/467"},"issue":{"href":"https://api.github.com/repos/OP-TEE/optee_os/issues/467"},"comments":{"href":"https://api.github.com/repos/OP-TEE/optee_os/issues/467/comments"},"review_comments":{"href":"https://api.github.com/repos/OP-TEE/optee_os/pulls/467/comments"},"review_comment":{"href":"https://api.github.com/repos/OP-TEE/optee_os/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OP-TEE/optee_os/pulls/467/commits"},"statuses":{"href":"https://api.github.com/repos/OP-TEE/optee_os/statuses/8effffba6c585b408a0c34ef3975095b6e9aa58f"}}}}