{"action":"created","comment":{"url":"https://api.github.com/repos/resin-io/node-lkl/pulls/comments/108478574","pull_request_review_id":29512060,"id":108478574,"diff_hunk":"@@ -136,125 +137,150 @@ struct lkl_dev_blk_ops lkl_js_disk_ops = {\n \t.request = js_request_entry,\n };\n \n-class MountWorker : public AsyncWorker {\n-\tpublic:\n-\t\tMountWorker(NAN_METHOD_ARGS_TYPE info, Callback *callback)\n-\t\t: AsyncWorker(callback) {\n-\t\t\treadonly = info[0]->BooleanValue();\n-\n-\t\t\tUtf8String fs_type_(info[1]);\n-\t\t\tstrncpy(fs_type, *fs_type_, sizeof(fs_type) - 1);\n-\t\t\tfs_type[sizeof(fs_type) - 1] = '\\0';\n-\n-\t\t\tpart = info[2]->Uint32Value();\n-\n-\t\t\t// FIXME: delete this object when the disk is unmounted\n-\t\t\tauto js_ops = new js_ops_t;\n-\t\t\tjs_ops->request = new Callback(info[3].As<v8::Function>());\n-\t\t\tjs_ops->get_capacity = new Callback(info[4].As<v8::Function>());\n-\n-\t\t\tdisk.ops = &lkl_js_disk_ops;\n-\t\t\tdisk.handle = js_ops;\n-\t\t}\n-\n-\t\t~MountWorker() {}\n-\n-\t\tvoid Execute () {\n-\t\t\tdisk_id = lkl_disk_add(&disk);\n-\t\t\tret = lkl_mount_dev(\n-\t\t\t\t\tdisk_id,\n-\t\t\t\t\tpart,\n-\t\t\t\t\tfs_type,\n-\t\t\t\t\treadonly ? LKL_MS_RDONLY : 0, NULL,\n-\t\t\t\t\tmountpoint,\n-\t\t\t\t\tsizeof(mountpoint)\n-\t\t\t);\n-\t\t}\n-\n-\t\tvoid HandleOKCallback () {\n-\t\t\tHandleScope scope;\n-\n-\t\t\tif (ret < 0) {\n-\t\t\t\tv8::Local<v8::Value> argv[] = {\n-\t\t\t\t\tErrnoException(-ret)\n-\t\t\t\t};\n-\t\t\t\tcallback->Call(1, argv);\n-\t\t\t} else {\n-\t\t\t\tv8::Local<v8::Object> ret2 = New<v8::Object>();\n-\t\t\t\tSet(ret2, New(\"mountpoint\").ToLocalChecked(), New(mountpoint).ToLocalChecked());\n-\t\t\t\tSet(ret2, New(\"diskId\").ToLocalChecked(), New(disk_id));\n-\t\t\t\tv8::Local<v8::Value> argv[] = { Null(), ret2 };\n-\t\t\t\tcallback->Call(2, argv);\n-\t\t\t}\n-\t\t}\n-\n-\tprivate:\n-\t\tlong ret;\n-\t\tbool readonly;\n-\t\tunsigned int part;\n-\t\tchar fs_type[10];\n-\t\tchar mountpoint[32];\n-\t\tunsigned int disk_id;\n-\t\tlkl_disk_t disk;\n+struct mount_state_t {\n+\tlong ret;\n+\tunsigned int disk_id;\n+\tchar* mountpoint;\n+\tCallback *callback;\n };\n \n+static void mount_callback(mount_state_t *s) {\n+\tHandleScope scope;\n+\tif (s->ret < 0) {\n+\t\tv8::Local<v8::Value> argv[] = {ErrnoException(-s->ret)};\n+\t\ts->callback->Call(1, argv);\n+\t} else {\n+\t\tv8::Local<v8::Object> ret2 = New<v8::Object>();\n+\t\tSet(\n+\t\t\tret2,\n+\t\t\tNew(\"mountpoint\").ToLocalChecked(),\n+\t\t\tNew(s->mountpoint).ToLocalChecked()\n+\t\t);\n+\t\tSet(ret2, New(\"diskId\").ToLocalChecked(), New(s->disk_id));\n+\t\tv8::Local<v8::Value> argv[] = { Null(), ret2 };\n+\t\ts->callback->Call(2, argv);\n+\t}\n+}\n+\n+struct mount_args_t {\n+\tlkl_disk_t disk;\n+\tbool readonly;\n+\tconst char* fs_type;\n+\tunsigned int part;\n+\tCallback *callback;\n+};\n+\n+void do_mount(mount_args_t* args) {\n+\tchar mountpoint[32];\n+\tunsigned int disk_id = lkl_disk_add(&(args->disk));\n+\tlong ret = lkl_mount_dev(\n+\t\tdisk_id,\n+\t\targs->part,\n+\t\targs->fs_type,\n+\t\targs->readonly ? LKL_MS_RDONLY : 0, NULL,\n+\t\tmountpoint,\n+\t\tsizeof(mountpoint)\n+\t);\n+\tmount_state_t s = {ret, disk_id, mountpoint, args->callback};\n+\trun_on_default_loop(mount_callback, &s);\n+\tdelete args->fs_type;\n+\tdelete args->callback;\n+\tdelete args;\n+}\n+\n+void mount_entry(NAN_METHOD_ARGS_TYPE info) {","path":"src/disk.cc","position":280,"original_position":123,"commit_id":"59d462617ff4e81fd3d4393243c10e9f840e5ff9","original_commit_id":"e6fd9e5a6b6a79a05d16ec648d92092100c122e1","user":{"login":"zvin","id":180331,"avatar_url":"https://avatars1.githubusercontent.com/u/180331?v=3","gravatar_id":"","url":"https://api.github.com/users/zvin","html_url":"https://github.com/zvin","followers_url":"https://api.github.com/users/zvin/followers","following_url":"https://api.github.com/users/zvin/following{/other_user}","gists_url":"https://api.github.com/users/zvin/gists{/gist_id}","starred_url":"https://api.github.com/users/zvin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zvin/subscriptions","organizations_url":"https://api.github.com/users/zvin/orgs","repos_url":"https://api.github.com/users/zvin/repos","events_url":"https://api.github.com/users/zvin/events{/privacy}","received_events_url":"https://api.github.com/users/zvin/received_events","type":"User","site_admin":false},"body":"no specific reason, updated","created_at":"2017-03-28T17:05:09Z","updated_at":"2017-03-28T17:05:09Z","html_url":"https://github.com/resin-io/node-lkl/pull/29#discussion_r108478574","pull_request_url":"https://api.github.com/repos/resin-io/node-lkl/pulls/29","_links":{"self":{"href":"https://api.github.com/repos/resin-io/node-lkl/pulls/comments/108478574"},"html":{"href":"https://github.com/resin-io/node-lkl/pull/29#discussion_r108478574"},"pull_request":{"href":"https://api.github.com/repos/resin-io/node-lkl/pulls/29"}}},"pull_request":{"url":"https://api.github.com/repos/resin-io/node-lkl/pulls/29","id":112809572,"html_url":"https://github.com/resin-io/node-lkl/pull/29","diff_url":"https://github.com/resin-io/node-lkl/pull/29.diff","patch_url":"https://github.com/resin-io/node-lkl/pull/29.patch","issue_url":"https://api.github.com/repos/resin-io/node-lkl/issues/29","number":29,"state":"open","locked":false,"title":"Separate disk add and mount, allow detaching disks","user":{"login":"zvin","id":180331,"avatar_url":"https://avatars1.githubusercontent.com/u/180331?v=3","gravatar_id":"","url":"https://api.github.com/users/zvin","html_url":"https://github.com/zvin","followers_url":"https://api.github.com/users/zvin/followers","following_url":"https://api.github.com/users/zvin/following{/other_user}","gists_url":"https://api.github.com/users/zvin/gists{/gist_id}","starred_url":"https://api.github.com/users/zvin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zvin/subscriptions","organizations_url":"https://api.github.com/users/zvin/orgs","repos_url":"https://api.github.com/users/zvin/repos","events_url":"https://api.github.com/users/zvin/events{/privacy}","received_events_url":"https://api.github.com/users/zvin/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-03-27T18:33:34Z","updated_at":"2017-03-28T17:05:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"08ae4d98e06a7c9adc36810b8a5e82b39e841d8f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/resin-io/node-lkl/pulls/29/commits","review_comments_url":"https://api.github.com/repos/resin-io/node-lkl/pulls/29/comments","review_comment_url":"https://api.github.com/repos/resin-io/node-lkl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/resin-io/node-lkl/issues/29/comments","statuses_url":"https://api.github.com/repos/resin-io/node-lkl/statuses/59d462617ff4e81fd3d4393243c10e9f840e5ff9","head":{"label":"resin-io:separate-disk-add-and-mount-2","ref":"separate-disk-add-and-mount-2","sha":"59d462617ff4e81fd3d4393243c10e9f840e5ff9","user":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars2.githubusercontent.com/u/6157842?v=3","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"repo":{"id":46466301,"name":"node-lkl","full_name":"resin-io/node-lkl","owner":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars2.githubusercontent.com/u/6157842?v=3","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/resin-io/node-lkl","description":"NodeJS native bindings to the Linux Kernel Library project","fork":false,"url":"https://api.github.com/repos/resin-io/node-lkl","forks_url":"https://api.github.com/repos/resin-io/node-lkl/forks","keys_url":"https://api.github.com/repos/resin-io/node-lkl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/resin-io/node-lkl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/resin-io/node-lkl/teams","hooks_url":"https://api.github.com/repos/resin-io/node-lkl/hooks","issue_events_url":"https://api.github.com/repos/resin-io/node-lkl/issues/events{/number}","events_url":"https://api.github.com/repos/resin-io/node-lkl/events","assignees_url":"https://api.github.com/repos/resin-io/node-lkl/assignees{/user}","branches_url":"https://api.github.com/repos/resin-io/node-lkl/branches{/branch}","tags_url":"https://api.github.com/repos/resin-io/node-lkl/tags","blobs_url":"https://api.github.com/repos/resin-io/node-lkl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/resin-io/node-lkl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/resin-io/node-lkl/git/refs{/sha}","trees_url":"https://api.github.com/repos/resin-io/node-lkl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/resin-io/node-lkl/statuses/{sha}","languages_url":"https://api.github.com/repos/resin-io/node-lkl/languages","stargazers_url":"https://api.github.com/repos/resin-io/node-lkl/stargazers","contributors_url":"https://api.github.com/repos/resin-io/node-lkl/contributors","subscribers_url":"https://api.github.com/repos/resin-io/node-lkl/subscribers","subscription_url":"https://api.github.com/repos/resin-io/node-lkl/subscription","commits_url":"https://api.github.com/repos/resin-io/node-lkl/commits{/sha}","git_commits_url":"https://api.github.com/repos/resin-io/node-lkl/git/commits{/sha}","comments_url":"https://api.github.com/repos/resin-io/node-lkl/comments{/number}","issue_comment_url":"https://api.github.com/repos/resin-io/node-lkl/issues/comments{/number}","contents_url":"https://api.github.com/repos/resin-io/node-lkl/contents/{+path}","compare_url":"https://api.github.com/repos/resin-io/node-lkl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/resin-io/node-lkl/merges","archive_url":"https://api.github.com/repos/resin-io/node-lkl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/resin-io/node-lkl/downloads","issues_url":"https://api.github.com/repos/resin-io/node-lkl/issues{/number}","pulls_url":"https://api.github.com/repos/resin-io/node-lkl/pulls{/number}","milestones_url":"https://api.github.com/repos/resin-io/node-lkl/milestones{/number}","notifications_url":"https://api.github.com/repos/resin-io/node-lkl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/resin-io/node-lkl/labels{/name}","releases_url":"https://api.github.com/repos/resin-io/node-lkl/releases{/id}","deployments_url":"https://api.github.com/repos/resin-io/node-lkl/deployments","created_at":"2015-11-19T03:56:59Z","updated_at":"2017-03-21T20:52:19Z","pushed_at":"2017-03-28T15:49:01Z","git_url":"git://github.com/resin-io/node-lkl.git","ssh_url":"git@github.com:resin-io/node-lkl.git","clone_url":"https://github.com/resin-io/node-lkl.git","svn_url":"https://github.com/resin-io/node-lkl","homepage":"","size":10718,"stargazers_count":10,"watchers_count":10,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":8,"forks":3,"open_issues":8,"watchers":10,"default_branch":"master"}},"base":{"label":"resin-io:master","ref":"master","sha":"bd54afac4e7c17089f03109d6f5e9032444a0b5a","user":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars2.githubusercontent.com/u/6157842?v=3","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"repo":{"id":46466301,"name":"node-lkl","full_name":"resin-io/node-lkl","owner":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars2.githubusercontent.com/u/6157842?v=3","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/resin-io/node-lkl","description":"NodeJS native bindings to the Linux Kernel Library project","fork":false,"url":"https://api.github.com/repos/resin-io/node-lkl","forks_url":"https://api.github.com/repos/resin-io/node-lkl/forks","keys_url":"https://api.github.com/repos/resin-io/node-lkl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/resin-io/node-lkl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/resin-io/node-lkl/teams","hooks_url":"https://api.github.com/repos/resin-io/node-lkl/hooks","issue_events_url":"https://api.github.com/repos/resin-io/node-lkl/issues/events{/number}","events_url":"https://api.github.com/repos/resin-io/node-lkl/events","assignees_url":"https://api.github.com/repos/resin-io/node-lkl/assignees{/user}","branches_url":"https://api.github.com/repos/resin-io/node-lkl/branches{/branch}","tags_url":"https://api.github.com/repos/resin-io/node-lkl/tags","blobs_url":"https://api.github.com/repos/resin-io/node-lkl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/resin-io/node-lkl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/resin-io/node-lkl/git/refs{/sha}","trees_url":"https://api.github.com/repos/resin-io/node-lkl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/resin-io/node-lkl/statuses/{sha}","languages_url":"https://api.github.com/repos/resin-io/node-lkl/languages","stargazers_url":"https://api.github.com/repos/resin-io/node-lkl/stargazers","contributors_url":"https://api.github.com/repos/resin-io/node-lkl/contributors","subscribers_url":"https://api.github.com/repos/resin-io/node-lkl/subscribers","subscription_url":"https://api.github.com/repos/resin-io/node-lkl/subscription","commits_url":"https://api.github.com/repos/resin-io/node-lkl/commits{/sha}","git_commits_url":"https://api.github.com/repos/resin-io/node-lkl/git/commits{/sha}","comments_url":"https://api.github.com/repos/resin-io/node-lkl/comments{/number}","issue_comment_url":"https://api.github.com/repos/resin-io/node-lkl/issues/comments{/number}","contents_url":"https://api.github.com/repos/resin-io/node-lkl/contents/{+path}","compare_url":"https://api.github.com/repos/resin-io/node-lkl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/resin-io/node-lkl/merges","archive_url":"https://api.github.com/repos/resin-io/node-lkl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/resin-io/node-lkl/downloads","issues_url":"https://api.github.com/repos/resin-io/node-lkl/issues{/number}","pulls_url":"https://api.github.com/repos/resin-io/node-lkl/pulls{/number}","milestones_url":"https://api.github.com/repos/resin-io/node-lkl/milestones{/number}","notifications_url":"https://api.github.com/repos/resin-io/node-lkl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/resin-io/node-lkl/labels{/name}","releases_url":"https://api.github.com/repos/resin-io/node-lkl/releases{/id}","deployments_url":"https://api.github.com/repos/resin-io/node-lkl/deployments","created_at":"2015-11-19T03:56:59Z","updated_at":"2017-03-21T20:52:19Z","pushed_at":"2017-03-28T15:49:01Z","git_url":"git://github.com/resin-io/node-lkl.git","ssh_url":"git@github.com:resin-io/node-lkl.git","clone_url":"https://github.com/resin-io/node-lkl.git","svn_url":"https://github.com/resin-io/node-lkl","homepage":"","size":10718,"stargazers_count":10,"watchers_count":10,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":8,"forks":3,"open_issues":8,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/resin-io/node-lkl/pulls/29"},"html":{"href":"https://github.com/resin-io/node-lkl/pull/29"},"issue":{"href":"https://api.github.com/repos/resin-io/node-lkl/issues/29"},"comments":{"href":"https://api.github.com/repos/resin-io/node-lkl/issues/29/comments"},"review_comments":{"href":"https://api.github.com/repos/resin-io/node-lkl/pulls/29/comments"},"review_comment":{"href":"https://api.github.com/repos/resin-io/node-lkl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/resin-io/node-lkl/pulls/29/commits"},"statuses":{"href":"https://api.github.com/repos/resin-io/node-lkl/statuses/59d462617ff4e81fd3d4393243c10e9f840e5ff9"}}}}
{"actor":{"display_login":"zvin"}}