{"action":"created","comment":{"url":"https://api.github.com/repos/coreos/rkt/pulls/comments/89593425","pull_request_review_id":10138091,"id":89593425,"diff_hunk":"@@ -0,0 +1,122 @@\n+// Copyright 2016 The rkt Authors\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+package mount\n+\n+import (\n+\t\"bufio\"\n+\t\"errors\"\n+\t\"fmt\"\n+\t\"io\"\n+\t\"os\"\n+\t\"sort\"\n+\t\"strconv\"\n+\t\"strings\"\n+\n+\t\"github.com/hashicorp/errwrap\"\n+)\n+\n+// GetMountsForPrefix returns all mountpoints associated with a process mount namespace,\n+// filtered by prefix. If no prefixPath is specified, all mounts are returned.\n+// The special value 0 as pid argument is used to specify the current process.\n+func GetMountsForPrefix(prefixPath string, pid uint) (Mounts, error) {\n+\tvar procPath string\n+\tif pid == 0 {\n+\t\tprocPath = \"/proc/self/mountinfo\"\n+\t} else {\n+\t\tprocPath = fmt.Sprintf(\"/proc/%d/mountinfo\", pid)\n+\t}\n+\n+\tif prefixPath == \"\" {\n+\t\tprefixPath = \"/\"\n+\t}\n+\n+\tmi, err := os.Open(procPath)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\tdefer mi.Close()\n+\n+\tmnts, err := getMountsForPrefix(prefixPath, mi)\n+\tif err != nil {\n+\t\treturn nil, errwrap.Wrap(fmt.Errorf(\"error getting sub-mounts under %q from mountinfo\", prefixPath), err)\n+\t}\n+\n+\treturn mnts, nil\n+}\n+\n+// getMountsForPrefix parses mi (/proc/<pid>/mountinfo) and returns mounts for path prefix\n+func getMountsForPrefix(path string, mi io.Reader) (Mounts, error) {\n+\tvar podMounts Mounts\n+\tsc := bufio.NewScanner(mi)\n+\tvar (\n+\t\tmountID    int\n+\t\tparentID   int\n+\t\tmountPoint string\n+\t\topt        map[string]struct{}\n+\t)\n+\n+\tfor sc.Scan() {\n+\t\tline := sc.Text()\n+\t\tlineResult := strings.Split(line, \" \")\n+\t\tif len(lineResult) < 7 {\n+\t\t\treturn nil, fmt.Errorf(\"Not enough fields from line %q: %+v\", line, lineResult)\n+\t\t}\n+\n+\t\topt = map[string]struct{}{}\n+\t\tfor i, s := range lineResult {\n+\t\t\tif s == \"-\" {\n+\t\t\t\tbreak\n+\t\t\t}\n+\t\t\tvar err error\n+\t\t\tswitch i {\n+\t\t\tcase 0:\n+\t\t\t\tmountID, err = strconv.Atoi(s)\n+\t\t\tcase 1:\n+\t\t\t\tparentID, err = strconv.Atoi(s)\n+\t\t\tcase 2, 3:","path":"pkg/mount/mount.go","position":88,"original_position":88,"commit_id":"a4a11a92819badbf3c2b225f704d38a616beccd6","original_commit_id":"a4a11a92819badbf3c2b225f704d38a616beccd6","user":{"login":"squeed","id":551378,"avatar_url":"https://avatars.githubusercontent.com/u/551378?v=3","gravatar_id":"","url":"https://api.github.com/users/squeed","html_url":"https://github.com/squeed","followers_url":"https://api.github.com/users/squeed/followers","following_url":"https://api.github.com/users/squeed/following{/other_user}","gists_url":"https://api.github.com/users/squeed/gists{/gist_id}","starred_url":"https://api.github.com/users/squeed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/squeed/subscriptions","organizations_url":"https://api.github.com/users/squeed/orgs","repos_url":"https://api.github.com/users/squeed/repos","events_url":"https://api.github.com/users/squeed/events{/privacy}","received_events_url":"https://api.github.com/users/squeed/received_events","type":"User","site_admin":false},"body":"Actually, would you mind parsing major:minor? I might need it for runc.","created_at":"2016-11-25T10:15:49Z","updated_at":"2016-11-25T10:15:49Z","html_url":"https://github.com/coreos/rkt/pull/3415#discussion_r89593425","pull_request_url":"https://api.github.com/repos/coreos/rkt/pulls/3415","_links":{"self":{"href":"https://api.github.com/repos/coreos/rkt/pulls/comments/89593425"},"html":{"href":"https://github.com/coreos/rkt/pull/3415#discussion_r89593425"},"pull_request":{"href":"https://api.github.com/repos/coreos/rkt/pulls/3415"}}},"pull_request":{"url":"https://api.github.com/repos/coreos/rkt/pulls/3415","id":95198712,"html_url":"https://github.com/coreos/rkt/pull/3415","diff_url":"https://github.com/coreos/rkt/pull/3415.diff","patch_url":"https://github.com/coreos/rkt/pull/3415.patch","issue_url":"https://api.github.com/repos/coreos/rkt/issues/3415","number":3415,"state":"open","locked":false,"title":"pkg/mount: move mountinfo parser to its own package","user":{"login":"lucab","id":98086,"avatar_url":"https://avatars.githubusercontent.com/u/98086?v=3","gravatar_id":"","url":"https://api.github.com/users/lucab","html_url":"https://github.com/lucab","followers_url":"https://api.github.com/users/lucab/followers","following_url":"https://api.github.com/users/lucab/following{/other_user}","gists_url":"https://api.github.com/users/lucab/gists{/gist_id}","starred_url":"https://api.github.com/users/lucab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucab/subscriptions","organizations_url":"https://api.github.com/users/lucab/orgs","repos_url":"https://api.github.com/users/lucab/repos","events_url":"https://api.github.com/users/lucab/events{/privacy}","received_events_url":"https://api.github.com/users/lucab/received_events","type":"User","site_admin":false},"body":"This PR deduplicates and moves all our `/proc/<pid>/mountinfo` parsing logic to its own package.\r\nIt will be later needed for https://github.com/coreos/rkt/issues/3411.","created_at":"2016-11-24T15:40:08Z","updated_at":"2016-11-25T10:15:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"007bf61704d408bb3f86834b3a4dfdb40d1b770f","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/coreos/rkt/milestones/55","html_url":"https://github.com/coreos/rkt/milestones/v1.21.0","labels_url":"https://api.github.com/repos/coreos/rkt/milestones/55/labels","id":2125178,"number":55,"title":"v1.21.0","description":"","creator":{"login":"lucab","id":98086,"avatar_url":"https://avatars.githubusercontent.com/u/98086?v=3","gravatar_id":"","url":"https://api.github.com/users/lucab","html_url":"https://github.com/lucab","followers_url":"https://api.github.com/users/lucab/followers","following_url":"https://api.github.com/users/lucab/following{/other_user}","gists_url":"https://api.github.com/users/lucab/gists{/gist_id}","starred_url":"https://api.github.com/users/lucab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucab/subscriptions","organizations_url":"https://api.github.com/users/lucab/orgs","repos_url":"https://api.github.com/users/lucab/repos","events_url":"https://api.github.com/users/lucab/events{/privacy}","received_events_url":"https://api.github.com/users/lucab/received_events","type":"User","site_admin":false},"open_issues":24,"closed_issues":2,"state":"open","created_at":"2016-11-09T16:54:44Z","updated_at":"2016-11-25T08:27:05Z","due_on":"2016-12-08T00:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/coreos/rkt/pulls/3415/commits","review_comments_url":"https://api.github.com/repos/coreos/rkt/pulls/3415/comments","review_comment_url":"https://api.github.com/repos/coreos/rkt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coreos/rkt/issues/3415/comments","statuses_url":"https://api.github.com/repos/coreos/rkt/statuses/a4a11a92819badbf3c2b225f704d38a616beccd6","head":{"label":"lucab:to-upstream/pkg-mount","ref":"to-upstream/pkg-mount","sha":"a4a11a92819badbf3c2b225f704d38a616beccd6","user":{"login":"lucab","id":98086,"avatar_url":"https://avatars.githubusercontent.com/u/98086?v=3","gravatar_id":"","url":"https://api.github.com/users/lucab","html_url":"https://github.com/lucab","followers_url":"https://api.github.com/users/lucab/followers","following_url":"https://api.github.com/users/lucab/following{/other_user}","gists_url":"https://api.github.com/users/lucab/gists{/gist_id}","starred_url":"https://api.github.com/users/lucab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucab/subscriptions","organizations_url":"https://api.github.com/users/lucab/orgs","repos_url":"https://api.github.com/users/lucab/repos","events_url":"https://api.github.com/users/lucab/events{/privacy}","received_events_url":"https://api.github.com/users/lucab/received_events","type":"User","site_admin":false},"repo":{"id":56424415,"name":"rkt","full_name":"lucab/rkt","owner":{"login":"lucab","id":98086,"avatar_url":"https://avatars.githubusercontent.com/u/98086?v=3","gravatar_id":"","url":"https://api.github.com/users/lucab","html_url":"https://github.com/lucab","followers_url":"https://api.github.com/users/lucab/followers","following_url":"https://api.github.com/users/lucab/following{/other_user}","gists_url":"https://api.github.com/users/lucab/gists{/gist_id}","starred_url":"https://api.github.com/users/lucab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucab/subscriptions","organizations_url":"https://api.github.com/users/lucab/orgs","repos_url":"https://api.github.com/users/lucab/repos","events_url":"https://api.github.com/users/lucab/events{/privacy}","received_events_url":"https://api.github.com/users/lucab/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lucab/rkt","description":"rkt is an App Container runtime for Linux","fork":true,"url":"https://api.github.com/repos/lucab/rkt","forks_url":"https://api.github.com/repos/lucab/rkt/forks","keys_url":"https://api.github.com/repos/lucab/rkt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lucab/rkt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lucab/rkt/teams","hooks_url":"https://api.github.com/repos/lucab/rkt/hooks","issue_events_url":"https://api.github.com/repos/lucab/rkt/issues/events{/number}","events_url":"https://api.github.com/repos/lucab/rkt/events","assignees_url":"https://api.github.com/repos/lucab/rkt/assignees{/user}","branches_url":"https://api.github.com/repos/lucab/rkt/branches{/branch}","tags_url":"https://api.github.com/repos/lucab/rkt/tags","blobs_url":"https://api.github.com/repos/lucab/rkt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lucab/rkt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lucab/rkt/git/refs{/sha}","trees_url":"https://api.github.com/repos/lucab/rkt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lucab/rkt/statuses/{sha}","languages_url":"https://api.github.com/repos/lucab/rkt/languages","stargazers_url":"https://api.github.com/repos/lucab/rkt/stargazers","contributors_url":"https://api.github.com/repos/lucab/rkt/contributors","subscribers_url":"https://api.github.com/repos/lucab/rkt/subscribers","subscription_url":"https://api.github.com/repos/lucab/rkt/subscription","commits_url":"https://api.github.com/repos/lucab/rkt/commits{/sha}","git_commits_url":"https://api.github.com/repos/lucab/rkt/git/commits{/sha}","comments_url":"https://api.github.com/repos/lucab/rkt/comments{/number}","issue_comment_url":"https://api.github.com/repos/lucab/rkt/issues/comments{/number}","contents_url":"https://api.github.com/repos/lucab/rkt/contents/{+path}","compare_url":"https://api.github.com/repos/lucab/rkt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lucab/rkt/merges","archive_url":"https://api.github.com/repos/lucab/rkt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lucab/rkt/downloads","issues_url":"https://api.github.com/repos/lucab/rkt/issues{/number}","pulls_url":"https://api.github.com/repos/lucab/rkt/pulls{/number}","milestones_url":"https://api.github.com/repos/lucab/rkt/milestones{/number}","notifications_url":"https://api.github.com/repos/lucab/rkt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lucab/rkt/labels{/name}","releases_url":"https://api.github.com/repos/lucab/rkt/releases{/id}","deployments_url":"https://api.github.com/repos/lucab/rkt/deployments","created_at":"2016-04-17T07:29:59Z","updated_at":"2016-04-17T07:30:02Z","pushed_at":"2016-11-24T15:32:51Z","git_url":"git://github.com/lucab/rkt.git","ssh_url":"git@github.com:lucab/rkt.git","clone_url":"https://github.com/lucab/rkt.git","svn_url":"https://github.com/lucab/rkt","homepage":"","size":24149,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"coreos:master","ref":"master","sha":"98251677e64b40e86cf4055372bc5a3b941c9a52","user":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"repo":{"id":26509369,"name":"rkt","full_name":"coreos/rkt","owner":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coreos/rkt","description":"rkt is a container engine for Linux designed to be composable, secure, and built on standards","fork":false,"url":"https://api.github.com/repos/coreos/rkt","forks_url":"https://api.github.com/repos/coreos/rkt/forks","keys_url":"https://api.github.com/repos/coreos/rkt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coreos/rkt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coreos/rkt/teams","hooks_url":"https://api.github.com/repos/coreos/rkt/hooks","issue_events_url":"https://api.github.com/repos/coreos/rkt/issues/events{/number}","events_url":"https://api.github.com/repos/coreos/rkt/events","assignees_url":"https://api.github.com/repos/coreos/rkt/assignees{/user}","branches_url":"https://api.github.com/repos/coreos/rkt/branches{/branch}","tags_url":"https://api.github.com/repos/coreos/rkt/tags","blobs_url":"https://api.github.com/repos/coreos/rkt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coreos/rkt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coreos/rkt/git/refs{/sha}","trees_url":"https://api.github.com/repos/coreos/rkt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coreos/rkt/statuses/{sha}","languages_url":"https://api.github.com/repos/coreos/rkt/languages","stargazers_url":"https://api.github.com/repos/coreos/rkt/stargazers","contributors_url":"https://api.github.com/repos/coreos/rkt/contributors","subscribers_url":"https://api.github.com/repos/coreos/rkt/subscribers","subscription_url":"https://api.github.com/repos/coreos/rkt/subscription","commits_url":"https://api.github.com/repos/coreos/rkt/commits{/sha}","git_commits_url":"https://api.github.com/repos/coreos/rkt/git/commits{/sha}","comments_url":"https://api.github.com/repos/coreos/rkt/comments{/number}","issue_comment_url":"https://api.github.com/repos/coreos/rkt/issues/comments{/number}","contents_url":"https://api.github.com/repos/coreos/rkt/contents/{+path}","compare_url":"https://api.github.com/repos/coreos/rkt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coreos/rkt/merges","archive_url":"https://api.github.com/repos/coreos/rkt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coreos/rkt/downloads","issues_url":"https://api.github.com/repos/coreos/rkt/issues{/number}","pulls_url":"https://api.github.com/repos/coreos/rkt/pulls{/number}","milestones_url":"https://api.github.com/repos/coreos/rkt/milestones{/number}","notifications_url":"https://api.github.com/repos/coreos/rkt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coreos/rkt/labels{/name}","releases_url":"https://api.github.com/repos/coreos/rkt/releases{/id}","deployments_url":"https://api.github.com/repos/coreos/rkt/deployments","created_at":"2014-11-11T23:13:18Z","updated_at":"2016-11-25T09:43:15Z","pushed_at":"2016-11-25T08:27:05Z","git_url":"git://github.com/coreos/rkt.git","ssh_url":"git@github.com:coreos/rkt.git","clone_url":"https://github.com/coreos/rkt.git","svn_url":"https://github.com/coreos/rkt","homepage":"","size":35405,"stargazers_count":6455,"watchers_count":6455,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":625,"mirror_url":null,"open_issues_count":398,"forks":625,"open_issues":398,"watchers":6455,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coreos/rkt/pulls/3415"},"html":{"href":"https://github.com/coreos/rkt/pull/3415"},"issue":{"href":"https://api.github.com/repos/coreos/rkt/issues/3415"},"comments":{"href":"https://api.github.com/repos/coreos/rkt/issues/3415/comments"},"review_comments":{"href":"https://api.github.com/repos/coreos/rkt/pulls/3415/comments"},"review_comment":{"href":"https://api.github.com/repos/coreos/rkt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coreos/rkt/pulls/3415/commits"},"statuses":{"href":"https://api.github.com/repos/coreos/rkt/statuses/a4a11a92819badbf3c2b225f704d38a616beccd6"}}}}
{"actor":{"display_login":"squeed"}}