{"action":"created","comment":{"url":"https://api.github.com/repos/opencontainers/runc/pulls/comments/58166734","id":58166734,"diff_hunk":"@@ -58,16 +57,30 @@ func getSelinuxMountPoint() string {\n \t}\n \tselinuxfs = \"\"\n \n-\tmounts, err := mount.GetMounts()\n+\tf, err := os.Open(\"/proc/self/mountinfo\")\n \tif err != nil {\n \t\treturn selinuxfs\n \t}\n-\tfor _, mount := range mounts {\n-\t\tif mount.Fstype == \"selinuxfs\" {\n-\t\t\tselinuxfs = mount.Mountpoint\n-\t\t\tbreak\n+\tdefer f.Close()\n+\n+\tscanner := bufio.NewScanner(f)\n+\tfor scanner.Scan() {\n+\t\ttxt := scanner.Text()\n+\t\tsepIdx := strings.Index(txt, \" - \")","path":"libcontainer/selinux/selinux.go","position":null,"original_position":26,"commit_id":"57fa063b292e368be53a382a5fbdee8e9fff9deb","original_commit_id":"962a0eb9c1718a0e579d754ea04a38e7c9c718c4","user":{"login":"inatatsu","id":9817764,"avatar_url":"https://avatars.githubusercontent.com/u/9817764?v=3","gravatar_id":"","url":"https://api.github.com/users/inatatsu","html_url":"https://github.com/inatatsu","followers_url":"https://api.github.com/users/inatatsu/followers","following_url":"https://api.github.com/users/inatatsu/following{/other_user}","gists_url":"https://api.github.com/users/inatatsu/gists{/gist_id}","starred_url":"https://api.github.com/users/inatatsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inatatsu/subscriptions","organizations_url":"https://api.github.com/users/inatatsu/orgs","repos_url":"https://api.github.com/users/inatatsu/repos","events_url":"https://api.github.com/users/inatatsu/events{/privacy}","received_events_url":"https://api.github.com/users/inatatsu/received_events","type":"User","site_admin":false},"body":"@cyphar Thanks. Replicated the original [comment](https://github.com/docker/docker/blob/4a7bd7eaef0038b006cf23adface84081e5aab3b/pkg/mount/mountinfo_linux.go#L65).","created_at":"2016-04-01T06:30:36Z","updated_at":"2016-04-01T06:30:36Z","html_url":"https://github.com/opencontainers/runc/pull/608#discussion_r58166734","pull_request_url":"https://api.github.com/repos/opencontainers/runc/pulls/608","_links":{"self":{"href":"https://api.github.com/repos/opencontainers/runc/pulls/comments/58166734"},"html":{"href":"https://github.com/opencontainers/runc/pull/608#discussion_r58166734"},"pull_request":{"href":"https://api.github.com/repos/opencontainers/runc/pulls/608"}}},"pull_request":{"url":"https://api.github.com/repos/opencontainers/runc/pulls/608","id":61371029,"html_url":"https://github.com/opencontainers/runc/pull/608","diff_url":"https://github.com/opencontainers/runc/pull/608.diff","patch_url":"https://github.com/opencontainers/runc/pull/608.patch","issue_url":"https://api.github.com/repos/opencontainers/runc/issues/608","number":608,"state":"open","locked":false,"title":"Eliminate redundant parsing of mountinfo","user":{"login":"inatatsu","id":9817764,"avatar_url":"https://avatars.githubusercontent.com/u/9817764?v=3","gravatar_id":"","url":"https://api.github.com/users/inatatsu","html_url":"https://github.com/inatatsu","followers_url":"https://api.github.com/users/inatatsu/followers","following_url":"https://api.github.com/users/inatatsu/following{/other_user}","gists_url":"https://api.github.com/users/inatatsu/gists{/gist_id}","starred_url":"https://api.github.com/users/inatatsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inatatsu/subscriptions","organizations_url":"https://api.github.com/users/inatatsu/orgs","repos_url":"https://api.github.com/users/inatatsu/repos","events_url":"https://api.github.com/users/inatatsu/events{/privacy}","received_events_url":"https://api.github.com/users/inatatsu/received_events","type":"User","site_admin":false},"body":"Fixes #631 (and the corresponding issue docker/docker#20851). The solutions here are:\r\n\r\n1. Skip parsing of `mountinfo` in [FindCgroupMountpoint()](https://github.com/opencontainers/runc/blob/177f2c405cc0f4fc027f7210675350e9be2b515c/libcontainer/cgroups/utils.go#L22) and [FindCgroupMountpointAndRoot()](https://github.com/opencontainers/runc/blob/177f2c405cc0f4fc027f7210675350e9be2b515c/libcontainer/cgroups/utils.go#L49) when a given cgroup subsystem is not enabled. The check is done by testing the subsystem is included in a result of [ParseCgroupFile()](https://github.com/opencontainers/runc/blob/177f2c405cc0f4fc027f7210675350e9be2b515c/libcontainer/cgroups/utils.go#L246).\r\n2. Break the parsing loop in [FindCgroupMountpointDir()](https://github.com/opencontainers/runc/blob/177f2c405cc0f4fc027f7210675350e9be2b515c/libcontainer/cgroups/utils.go#L73) when all the cgroup subsystems are found.\r\n3. Skip parsing of `mountinfo` in [getSelinuxMountPoint()](https://github.com/opencontainers/runc/blob/177f2c405cc0f4fc027f7210675350e9be2b515c/libcontainer/selinux/selinux.go#L55) when the mount point is found, instead of invoking [mount.GetMounts()](https://github.com/opencontainers/runc/blob/177f2c405cc0f4fc027f7210675350e9be2b515c/libcontainer/selinux/selinux.go#L61).\r\n4. Postpone parsing `mountinfo` by invoking [rootfsParentMountPrivate()](https://github.com/opencontainers/runc/blob/177f2c405cc0f4fc027f7210675350e9be2b515c/libcontainer/rootfs_linux.go#L507) and [getParentMount()](https://github.com/opencontainers/runc/blob/177f2c405cc0f4fc027f7210675350e9be2b515c/libcontainer/rootfs_linux.go#L475) until `pivot_root()` actually fails.","created_at":"2016-03-02T09:17:03Z","updated_at":"2016-04-01T06:30:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e95afefe1c745f690a2fc84b1c844cb0d570b546","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/opencontainers/runc/pulls/608/commits","review_comments_url":"https://api.github.com/repos/opencontainers/runc/pulls/608/comments","review_comment_url":"https://api.github.com/repos/opencontainers/runc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/opencontainers/runc/issues/608/comments","statuses_url":"https://api.github.com/repos/opencontainers/runc/statuses/57fa063b292e368be53a382a5fbdee8e9fff9deb","head":{"label":"inatatsu:reduce-parsing-mountinfo","ref":"reduce-parsing-mountinfo","sha":"57fa063b292e368be53a382a5fbdee8e9fff9deb","user":{"login":"inatatsu","id":9817764,"avatar_url":"https://avatars.githubusercontent.com/u/9817764?v=3","gravatar_id":"","url":"https://api.github.com/users/inatatsu","html_url":"https://github.com/inatatsu","followers_url":"https://api.github.com/users/inatatsu/followers","following_url":"https://api.github.com/users/inatatsu/following{/other_user}","gists_url":"https://api.github.com/users/inatatsu/gists{/gist_id}","starred_url":"https://api.github.com/users/inatatsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inatatsu/subscriptions","organizations_url":"https://api.github.com/users/inatatsu/orgs","repos_url":"https://api.github.com/users/inatatsu/repos","events_url":"https://api.github.com/users/inatatsu/events{/privacy}","received_events_url":"https://api.github.com/users/inatatsu/received_events","type":"User","site_admin":false},"repo":{"id":50971776,"name":"runc","full_name":"inatatsu/runc","owner":{"login":"inatatsu","id":9817764,"avatar_url":"https://avatars.githubusercontent.com/u/9817764?v=3","gravatar_id":"","url":"https://api.github.com/users/inatatsu","html_url":"https://github.com/inatatsu","followers_url":"https://api.github.com/users/inatatsu/followers","following_url":"https://api.github.com/users/inatatsu/following{/other_user}","gists_url":"https://api.github.com/users/inatatsu/gists{/gist_id}","starred_url":"https://api.github.com/users/inatatsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inatatsu/subscriptions","organizations_url":"https://api.github.com/users/inatatsu/orgs","repos_url":"https://api.github.com/users/inatatsu/repos","events_url":"https://api.github.com/users/inatatsu/events{/privacy}","received_events_url":"https://api.github.com/users/inatatsu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/inatatsu/runc","description":"runc container cli tools","fork":true,"url":"https://api.github.com/repos/inatatsu/runc","forks_url":"https://api.github.com/repos/inatatsu/runc/forks","keys_url":"https://api.github.com/repos/inatatsu/runc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/inatatsu/runc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/inatatsu/runc/teams","hooks_url":"https://api.github.com/repos/inatatsu/runc/hooks","issue_events_url":"https://api.github.com/repos/inatatsu/runc/issues/events{/number}","events_url":"https://api.github.com/repos/inatatsu/runc/events","assignees_url":"https://api.github.com/repos/inatatsu/runc/assignees{/user}","branches_url":"https://api.github.com/repos/inatatsu/runc/branches{/branch}","tags_url":"https://api.github.com/repos/inatatsu/runc/tags","blobs_url":"https://api.github.com/repos/inatatsu/runc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/inatatsu/runc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/inatatsu/runc/git/refs{/sha}","trees_url":"https://api.github.com/repos/inatatsu/runc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/inatatsu/runc/statuses/{sha}","languages_url":"https://api.github.com/repos/inatatsu/runc/languages","stargazers_url":"https://api.github.com/repos/inatatsu/runc/stargazers","contributors_url":"https://api.github.com/repos/inatatsu/runc/contributors","subscribers_url":"https://api.github.com/repos/inatatsu/runc/subscribers","subscription_url":"https://api.github.com/repos/inatatsu/runc/subscription","commits_url":"https://api.github.com/repos/inatatsu/runc/commits{/sha}","git_commits_url":"https://api.github.com/repos/inatatsu/runc/git/commits{/sha}","comments_url":"https://api.github.com/repos/inatatsu/runc/comments{/number}","issue_comment_url":"https://api.github.com/repos/inatatsu/runc/issues/comments{/number}","contents_url":"https://api.github.com/repos/inatatsu/runc/contents/{+path}","compare_url":"https://api.github.com/repos/inatatsu/runc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/inatatsu/runc/merges","archive_url":"https://api.github.com/repos/inatatsu/runc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/inatatsu/runc/downloads","issues_url":"https://api.github.com/repos/inatatsu/runc/issues{/number}","pulls_url":"https://api.github.com/repos/inatatsu/runc/pulls{/number}","milestones_url":"https://api.github.com/repos/inatatsu/runc/milestones{/number}","notifications_url":"https://api.github.com/repos/inatatsu/runc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/inatatsu/runc/labels{/name}","releases_url":"https://api.github.com/repos/inatatsu/runc/releases{/id}","deployments_url":"https://api.github.com/repos/inatatsu/runc/deployments","created_at":"2016-02-03T03:41:41Z","updated_at":"2016-02-03T03:41:42Z","pushed_at":"2016-04-01T06:28:12Z","git_url":"git://github.com/inatatsu/runc.git","ssh_url":"git@github.com:inatatsu/runc.git","clone_url":"https://github.com/inatatsu/runc.git","svn_url":"https://github.com/inatatsu/runc","homepage":"","size":2958,"stargazers_count":0,"watchers_count":0,"language":"Go","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":"opencontainers:master","ref":"master","sha":"89ab7f2ccc1e45ddf6485eaa802c35dcf321dfc8","user":{"login":"opencontainers","id":12563465,"avatar_url":"https://avatars.githubusercontent.com/u/12563465?v=3","gravatar_id":"","url":"https://api.github.com/users/opencontainers","html_url":"https://github.com/opencontainers","followers_url":"https://api.github.com/users/opencontainers/followers","following_url":"https://api.github.com/users/opencontainers/following{/other_user}","gists_url":"https://api.github.com/users/opencontainers/gists{/gist_id}","starred_url":"https://api.github.com/users/opencontainers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opencontainers/subscriptions","organizations_url":"https://api.github.com/users/opencontainers/orgs","repos_url":"https://api.github.com/users/opencontainers/repos","events_url":"https://api.github.com/users/opencontainers/events{/privacy}","received_events_url":"https://api.github.com/users/opencontainers/received_events","type":"Organization","site_admin":false},"repo":{"id":36960321,"name":"runc","full_name":"opencontainers/runc","owner":{"login":"opencontainers","id":12563465,"avatar_url":"https://avatars.githubusercontent.com/u/12563465?v=3","gravatar_id":"","url":"https://api.github.com/users/opencontainers","html_url":"https://github.com/opencontainers","followers_url":"https://api.github.com/users/opencontainers/followers","following_url":"https://api.github.com/users/opencontainers/following{/other_user}","gists_url":"https://api.github.com/users/opencontainers/gists{/gist_id}","starred_url":"https://api.github.com/users/opencontainers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opencontainers/subscriptions","organizations_url":"https://api.github.com/users/opencontainers/orgs","repos_url":"https://api.github.com/users/opencontainers/repos","events_url":"https://api.github.com/users/opencontainers/events{/privacy}","received_events_url":"https://api.github.com/users/opencontainers/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opencontainers/runc","description":"runc container cli tools","fork":false,"url":"https://api.github.com/repos/opencontainers/runc","forks_url":"https://api.github.com/repos/opencontainers/runc/forks","keys_url":"https://api.github.com/repos/opencontainers/runc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opencontainers/runc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opencontainers/runc/teams","hooks_url":"https://api.github.com/repos/opencontainers/runc/hooks","issue_events_url":"https://api.github.com/repos/opencontainers/runc/issues/events{/number}","events_url":"https://api.github.com/repos/opencontainers/runc/events","assignees_url":"https://api.github.com/repos/opencontainers/runc/assignees{/user}","branches_url":"https://api.github.com/repos/opencontainers/runc/branches{/branch}","tags_url":"https://api.github.com/repos/opencontainers/runc/tags","blobs_url":"https://api.github.com/repos/opencontainers/runc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opencontainers/runc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opencontainers/runc/git/refs{/sha}","trees_url":"https://api.github.com/repos/opencontainers/runc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opencontainers/runc/statuses/{sha}","languages_url":"https://api.github.com/repos/opencontainers/runc/languages","stargazers_url":"https://api.github.com/repos/opencontainers/runc/stargazers","contributors_url":"https://api.github.com/repos/opencontainers/runc/contributors","subscribers_url":"https://api.github.com/repos/opencontainers/runc/subscribers","subscription_url":"https://api.github.com/repos/opencontainers/runc/subscription","commits_url":"https://api.github.com/repos/opencontainers/runc/commits{/sha}","git_commits_url":"https://api.github.com/repos/opencontainers/runc/git/commits{/sha}","comments_url":"https://api.github.com/repos/opencontainers/runc/comments{/number}","issue_comment_url":"https://api.github.com/repos/opencontainers/runc/issues/comments{/number}","contents_url":"https://api.github.com/repos/opencontainers/runc/contents/{+path}","compare_url":"https://api.github.com/repos/opencontainers/runc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opencontainers/runc/merges","archive_url":"https://api.github.com/repos/opencontainers/runc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opencontainers/runc/downloads","issues_url":"https://api.github.com/repos/opencontainers/runc/issues{/number}","pulls_url":"https://api.github.com/repos/opencontainers/runc/pulls{/number}","milestones_url":"https://api.github.com/repos/opencontainers/runc/milestones{/number}","notifications_url":"https://api.github.com/repos/opencontainers/runc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opencontainers/runc/labels{/name}","releases_url":"https://api.github.com/repos/opencontainers/runc/releases{/id}","deployments_url":"https://api.github.com/repos/opencontainers/runc/deployments","created_at":"2015-06-05T23:30:45Z","updated_at":"2016-04-01T04:59:28Z","pushed_at":"2016-04-01T06:28:12Z","git_url":"git://github.com/opencontainers/runc.git","ssh_url":"git@github.com:opencontainers/runc.git","clone_url":"https://github.com/opencontainers/runc.git","svn_url":"https://github.com/opencontainers/runc","homepage":"","size":5268,"stargazers_count":2621,"watchers_count":2621,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":328,"mirror_url":null,"open_issues_count":50,"forks":328,"open_issues":50,"watchers":2621,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/opencontainers/runc/pulls/608"},"html":{"href":"https://github.com/opencontainers/runc/pull/608"},"issue":{"href":"https://api.github.com/repos/opencontainers/runc/issues/608"},"comments":{"href":"https://api.github.com/repos/opencontainers/runc/issues/608/comments"},"review_comments":{"href":"https://api.github.com/repos/opencontainers/runc/pulls/608/comments"},"review_comment":{"href":"https://api.github.com/repos/opencontainers/runc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/opencontainers/runc/pulls/608/commits"},"statuses":{"href":"https://api.github.com/repos/opencontainers/runc/statuses/57fa063b292e368be53a382a5fbdee8e9fff9deb"}}}}