{"action":"created","comment":{"url":"https://api.github.com/repos/pachyderm/pachyderm/pulls/comments/35594993","id":35594993,"diff_hunk":"@@ -0,0 +1,127 @@\n+package fuse\n+\n+import (\n+\t\"fmt\"\n+\t\"log\"\n+\t\"os\"\n+\t\"path/filepath\"\n+\n+\t\"bazil.org/fuse\"\n+\t\"bazil.org/fuse/fs\"\n+\t\"github.com/pachyderm/pachyderm/src/pfs\"\n+\t\"github.com/pachyderm/pachyderm/src/pfs/pfsutil\"\n+\t\"golang.org/x/net/context\"\n+)\n+\n+func Mount(apiClient pfs.ApiClient, repositoryName string, commitID string, mountPoint string) error {\n+\tif err := os.MkdirAll(mountPoint, 0777); err != nil {\n+\t\treturn err\n+\t}\n+\tc, err := fuse.Mount(\n+\t\tmountPoint,\n+\t\tfuse.FSName(\"pfs\"),\n+\t\tfuse.Subtype(\"pfs\"),\n+\t\tfuse.VolumeName(\"pfs://\"+repositoryName),\n+\t)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\tdefer c.Close()\n+\n+\tif err := fs.Serve(c, &filesystem{apiClient, repositoryName, commitID}); err != nil {\n+\t\treturn err\n+\t}\n+\n+\t// check if the mount process has an error to report\n+\t<-c.Ready\n+\treturn c.MountError\n+}\n+\n+func Unmount(mountPoint string) error {\n+\treturn nil\n+}\n+\n+type filesystem struct {\n+\tapiClient      pfs.ApiClient\n+\trepositoryName string\n+\tcommitID       string\n+}\n+\n+func (f *filesystem) Root() (fs.Node, error) {\n+\treturn &directory{f, \"/\"}, nil\n+}\n+\n+type directory struct {\n+\tfs   *filesystem\n+\tpath string\n+}\n+\n+func (*directory) Attr(ctx context.Context, a *fuse.Attr) error {\n+\ta.Inode = 1\n+\ta.Mode = os.ModeDir | 0555\n+\treturn nil\n+}\n+\n+func nodeFromFileInfo(fs *filesystem, fileInfo *pfs.FileInfo) (fs.Node, error) {\n+\tswitch fileInfo.FileType {\n+\tcase pfs.FileType_FILE_TYPE_NONE:\n+\t\tlog.Print(\"FileType_FILE_TYPE_NONE\")\n+\t\treturn nil, fuse.ENOENT\n+\tcase pfs.FileType_FILE_TYPE_OTHER:\n+\t\tlog.Print(\"FileType_FILE_TYPE_OTHER\")\n+\t\treturn nil, fuse.ENOENT\n+\tcase pfs.FileType_FILE_TYPE_REGULAR:\n+\t\treturn &file{fs, fileInfo.Path.Path, fileInfo.SizeBytes}, nil\n+\tcase pfs.FileType_FILE_TYPE_DIR:\n+\t\treturn &directory{fs, fileInfo.Path.Path}, nil\n+\tdefault:\n+\t\treturn nil, fmt.Errorf(\"Unrecognized FileType.\")\n+\t}\n+}\n+\n+func (d *directory) Lookup(ctx context.Context, name string) (fs.Node, error) {\n+\tresponse, err := pfsutil.GetFileInfo(\n+\t\td.fs.apiClient,\n+\t\td.fs.repositoryName,\n+\t\td.fs.commitID,\n+\t\tfilepath.Join(d.path, name),\n+\t)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\treturn nodeFromFileInfo(d.fs, response.GetFileInfo())\n+}\n+\n+func (d *directory) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {\n+\tresponse, err := pfsutil.ListFiles(d.fs.apiClient, d.fs.repositoryName, d.fs.commitID, d.path, 0, 1)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\tvar result []fuse.Dirent","path":"src/pfs/fuse/fuse.go","position":101,"original_position":100,"commit_id":"2048f0feed8674bc3f884cd76ba5337c9fad72c0","original_commit_id":"a5c7ed0b0720bfa43d6ea61e90b93c168403efec","user":{"login":"jdoliner","id":43867,"avatar_url":"https://avatars.githubusercontent.com/u/43867?v=3","gravatar_id":"","url":"https://api.github.com/users/jdoliner","html_url":"https://github.com/jdoliner","followers_url":"https://api.github.com/users/jdoliner/followers","following_url":"https://api.github.com/users/jdoliner/following{/other_user}","gists_url":"https://api.github.com/users/jdoliner/gists{/gist_id}","starred_url":"https://api.github.com/users/jdoliner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdoliner/subscriptions","organizations_url":"https://api.github.com/users/jdoliner/orgs","repos_url":"https://api.github.com/users/jdoliner/repos","events_url":"https://api.github.com/users/jdoliner/events{/privacy}","received_events_url":"https://api.github.com/users/jdoliner/received_events","type":"User","site_admin":false},"body":"K did the latter.\r\n:white_check_mark:","created_at":"2015-07-27T22:25:12Z","updated_at":"2015-07-27T22:25:12Z","html_url":"https://github.com/pachyderm/pachyderm/pull/128#discussion_r35594993","pull_request_url":"https://api.github.com/repos/pachyderm/pachyderm/pulls/128","_links":{"self":{"href":"https://api.github.com/repos/pachyderm/pachyderm/pulls/comments/35594993"},"html":{"href":"https://github.com/pachyderm/pachyderm/pull/128#discussion_r35594993"},"pull_request":{"href":"https://api.github.com/repos/pachyderm/pachyderm/pulls/128"}}},"pull_request":{"url":"https://api.github.com/repos/pachyderm/pachyderm/pulls/128","id":40822491,"html_url":"https://github.com/pachyderm/pachyderm/pull/128","diff_url":"https://github.com/pachyderm/pachyderm/pull/128.diff","patch_url":"https://github.com/pachyderm/pachyderm/pull/128.patch","issue_url":"https://api.github.com/repos/pachyderm/pachyderm/issues/128","number":128,"state":"open","locked":false,"title":"Fuse","user":{"login":"jdoliner","id":43867,"avatar_url":"https://avatars.githubusercontent.com/u/43867?v=3","gravatar_id":"","url":"https://api.github.com/users/jdoliner","html_url":"https://github.com/jdoliner","followers_url":"https://api.github.com/users/jdoliner/followers","following_url":"https://api.github.com/users/jdoliner/following{/other_user}","gists_url":"https://api.github.com/users/jdoliner/gists{/gist_id}","starred_url":"https://api.github.com/users/jdoliner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdoliner/subscriptions","organizations_url":"https://api.github.com/users/jdoliner/orgs","repos_url":"https://api.github.com/users/jdoliner/repos","events_url":"https://api.github.com/users/jdoliner/events{/privacy}","received_events_url":"https://api.github.com/users/jdoliner/received_events","type":"User","site_admin":false},"body":"This pr adds support for mounting a pfs repo as a local filesystem using fuse.\r\n\r\nIt's currently very incomplete.","created_at":"2015-07-24T22:41:08Z","updated_at":"2015-07-27T22:25:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6186ebbe28ae436bc6db326b55d092dae6372cc5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pachyderm/pachyderm/pulls/128/commits","review_comments_url":"https://api.github.com/repos/pachyderm/pachyderm/pulls/128/comments","review_comment_url":"https://api.github.com/repos/pachyderm/pachyderm/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pachyderm/pachyderm/issues/128/comments","statuses_url":"https://api.github.com/repos/pachyderm/pachyderm/statuses/2048f0feed8674bc3f884cd76ba5337c9fad72c0","head":{"label":"pachyderm:fuse","ref":"fuse","sha":"2048f0feed8674bc3f884cd76ba5337c9fad72c0","user":{"login":"pachyderm","id":10432478,"avatar_url":"https://avatars.githubusercontent.com/u/10432478?v=3","gravatar_id":"","url":"https://api.github.com/users/pachyderm","html_url":"https://github.com/pachyderm","followers_url":"https://api.github.com/users/pachyderm/followers","following_url":"https://api.github.com/users/pachyderm/following{/other_user}","gists_url":"https://api.github.com/users/pachyderm/gists{/gist_id}","starred_url":"https://api.github.com/users/pachyderm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pachyderm/subscriptions","organizations_url":"https://api.github.com/users/pachyderm/orgs","repos_url":"https://api.github.com/users/pachyderm/repos","events_url":"https://api.github.com/users/pachyderm/events{/privacy}","received_events_url":"https://api.github.com/users/pachyderm/received_events","type":"Organization","site_admin":false},"repo":{"id":23653453,"name":"pachyderm","full_name":"pachyderm/pachyderm","owner":{"login":"pachyderm","id":10432478,"avatar_url":"https://avatars.githubusercontent.com/u/10432478?v=3","gravatar_id":"","url":"https://api.github.com/users/pachyderm","html_url":"https://github.com/pachyderm","followers_url":"https://api.github.com/users/pachyderm/followers","following_url":"https://api.github.com/users/pachyderm/following{/other_user}","gists_url":"https://api.github.com/users/pachyderm/gists{/gist_id}","starred_url":"https://api.github.com/users/pachyderm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pachyderm/subscriptions","organizations_url":"https://api.github.com/users/pachyderm/orgs","repos_url":"https://api.github.com/users/pachyderm/repos","events_url":"https://api.github.com/users/pachyderm/events{/privacy}","received_events_url":"https://api.github.com/users/pachyderm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pachyderm/pachyderm","description":"Containerized Data Analytics","fork":false,"url":"https://api.github.com/repos/pachyderm/pachyderm","forks_url":"https://api.github.com/repos/pachyderm/pachyderm/forks","keys_url":"https://api.github.com/repos/pachyderm/pachyderm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pachyderm/pachyderm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pachyderm/pachyderm/teams","hooks_url":"https://api.github.com/repos/pachyderm/pachyderm/hooks","issue_events_url":"https://api.github.com/repos/pachyderm/pachyderm/issues/events{/number}","events_url":"https://api.github.com/repos/pachyderm/pachyderm/events","assignees_url":"https://api.github.com/repos/pachyderm/pachyderm/assignees{/user}","branches_url":"https://api.github.com/repos/pachyderm/pachyderm/branches{/branch}","tags_url":"https://api.github.com/repos/pachyderm/pachyderm/tags","blobs_url":"https://api.github.com/repos/pachyderm/pachyderm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pachyderm/pachyderm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pachyderm/pachyderm/git/refs{/sha}","trees_url":"https://api.github.com/repos/pachyderm/pachyderm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pachyderm/pachyderm/statuses/{sha}","languages_url":"https://api.github.com/repos/pachyderm/pachyderm/languages","stargazers_url":"https://api.github.com/repos/pachyderm/pachyderm/stargazers","contributors_url":"https://api.github.com/repos/pachyderm/pachyderm/contributors","subscribers_url":"https://api.github.com/repos/pachyderm/pachyderm/subscribers","subscription_url":"https://api.github.com/repos/pachyderm/pachyderm/subscription","commits_url":"https://api.github.com/repos/pachyderm/pachyderm/commits{/sha}","git_commits_url":"https://api.github.com/repos/pachyderm/pachyderm/git/commits{/sha}","comments_url":"https://api.github.com/repos/pachyderm/pachyderm/comments{/number}","issue_comment_url":"https://api.github.com/repos/pachyderm/pachyderm/issues/comments{/number}","contents_url":"https://api.github.com/repos/pachyderm/pachyderm/contents/{+path}","compare_url":"https://api.github.com/repos/pachyderm/pachyderm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pachyderm/pachyderm/merges","archive_url":"https://api.github.com/repos/pachyderm/pachyderm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pachyderm/pachyderm/downloads","issues_url":"https://api.github.com/repos/pachyderm/pachyderm/issues{/number}","pulls_url":"https://api.github.com/repos/pachyderm/pachyderm/pulls{/number}","milestones_url":"https://api.github.com/repos/pachyderm/pachyderm/milestones{/number}","notifications_url":"https://api.github.com/repos/pachyderm/pachyderm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pachyderm/pachyderm/labels{/name}","releases_url":"https://api.github.com/repos/pachyderm/pachyderm/releases{/id}","created_at":"2014-09-04T07:50:02Z","updated_at":"2015-07-26T20:43:58Z","pushed_at":"2015-07-27T22:11:17Z","git_url":"git://github.com/pachyderm/pachyderm.git","ssh_url":"git@github.com:pachyderm/pachyderm.git","clone_url":"https://github.com/pachyderm/pachyderm.git","svn_url":"https://github.com/pachyderm/pachyderm","homepage":"Http://www.pachyderm.io","size":6658,"stargazers_count":780,"watchers_count":780,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":41,"mirror_url":null,"open_issues_count":12,"forks":41,"open_issues":12,"watchers":780,"default_branch":"master"}},"base":{"label":"pachyderm:master","ref":"master","sha":"11dd472792c09f4eefced9e4d33c9c4a9975541c","user":{"login":"pachyderm","id":10432478,"avatar_url":"https://avatars.githubusercontent.com/u/10432478?v=3","gravatar_id":"","url":"https://api.github.com/users/pachyderm","html_url":"https://github.com/pachyderm","followers_url":"https://api.github.com/users/pachyderm/followers","following_url":"https://api.github.com/users/pachyderm/following{/other_user}","gists_url":"https://api.github.com/users/pachyderm/gists{/gist_id}","starred_url":"https://api.github.com/users/pachyderm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pachyderm/subscriptions","organizations_url":"https://api.github.com/users/pachyderm/orgs","repos_url":"https://api.github.com/users/pachyderm/repos","events_url":"https://api.github.com/users/pachyderm/events{/privacy}","received_events_url":"https://api.github.com/users/pachyderm/received_events","type":"Organization","site_admin":false},"repo":{"id":23653453,"name":"pachyderm","full_name":"pachyderm/pachyderm","owner":{"login":"pachyderm","id":10432478,"avatar_url":"https://avatars.githubusercontent.com/u/10432478?v=3","gravatar_id":"","url":"https://api.github.com/users/pachyderm","html_url":"https://github.com/pachyderm","followers_url":"https://api.github.com/users/pachyderm/followers","following_url":"https://api.github.com/users/pachyderm/following{/other_user}","gists_url":"https://api.github.com/users/pachyderm/gists{/gist_id}","starred_url":"https://api.github.com/users/pachyderm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pachyderm/subscriptions","organizations_url":"https://api.github.com/users/pachyderm/orgs","repos_url":"https://api.github.com/users/pachyderm/repos","events_url":"https://api.github.com/users/pachyderm/events{/privacy}","received_events_url":"https://api.github.com/users/pachyderm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pachyderm/pachyderm","description":"Containerized Data Analytics","fork":false,"url":"https://api.github.com/repos/pachyderm/pachyderm","forks_url":"https://api.github.com/repos/pachyderm/pachyderm/forks","keys_url":"https://api.github.com/repos/pachyderm/pachyderm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pachyderm/pachyderm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pachyderm/pachyderm/teams","hooks_url":"https://api.github.com/repos/pachyderm/pachyderm/hooks","issue_events_url":"https://api.github.com/repos/pachyderm/pachyderm/issues/events{/number}","events_url":"https://api.github.com/repos/pachyderm/pachyderm/events","assignees_url":"https://api.github.com/repos/pachyderm/pachyderm/assignees{/user}","branches_url":"https://api.github.com/repos/pachyderm/pachyderm/branches{/branch}","tags_url":"https://api.github.com/repos/pachyderm/pachyderm/tags","blobs_url":"https://api.github.com/repos/pachyderm/pachyderm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pachyderm/pachyderm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pachyderm/pachyderm/git/refs{/sha}","trees_url":"https://api.github.com/repos/pachyderm/pachyderm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pachyderm/pachyderm/statuses/{sha}","languages_url":"https://api.github.com/repos/pachyderm/pachyderm/languages","stargazers_url":"https://api.github.com/repos/pachyderm/pachyderm/stargazers","contributors_url":"https://api.github.com/repos/pachyderm/pachyderm/contributors","subscribers_url":"https://api.github.com/repos/pachyderm/pachyderm/subscribers","subscription_url":"https://api.github.com/repos/pachyderm/pachyderm/subscription","commits_url":"https://api.github.com/repos/pachyderm/pachyderm/commits{/sha}","git_commits_url":"https://api.github.com/repos/pachyderm/pachyderm/git/commits{/sha}","comments_url":"https://api.github.com/repos/pachyderm/pachyderm/comments{/number}","issue_comment_url":"https://api.github.com/repos/pachyderm/pachyderm/issues/comments{/number}","contents_url":"https://api.github.com/repos/pachyderm/pachyderm/contents/{+path}","compare_url":"https://api.github.com/repos/pachyderm/pachyderm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pachyderm/pachyderm/merges","archive_url":"https://api.github.com/repos/pachyderm/pachyderm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pachyderm/pachyderm/downloads","issues_url":"https://api.github.com/repos/pachyderm/pachyderm/issues{/number}","pulls_url":"https://api.github.com/repos/pachyderm/pachyderm/pulls{/number}","milestones_url":"https://api.github.com/repos/pachyderm/pachyderm/milestones{/number}","notifications_url":"https://api.github.com/repos/pachyderm/pachyderm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pachyderm/pachyderm/labels{/name}","releases_url":"https://api.github.com/repos/pachyderm/pachyderm/releases{/id}","created_at":"2014-09-04T07:50:02Z","updated_at":"2015-07-26T20:43:58Z","pushed_at":"2015-07-27T22:11:17Z","git_url":"git://github.com/pachyderm/pachyderm.git","ssh_url":"git@github.com:pachyderm/pachyderm.git","clone_url":"https://github.com/pachyderm/pachyderm.git","svn_url":"https://github.com/pachyderm/pachyderm","homepage":"Http://www.pachyderm.io","size":6658,"stargazers_count":780,"watchers_count":780,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":41,"mirror_url":null,"open_issues_count":12,"forks":41,"open_issues":12,"watchers":780,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pachyderm/pachyderm/pulls/128"},"html":{"href":"https://github.com/pachyderm/pachyderm/pull/128"},"issue":{"href":"https://api.github.com/repos/pachyderm/pachyderm/issues/128"},"comments":{"href":"https://api.github.com/repos/pachyderm/pachyderm/issues/128/comments"},"review_comments":{"href":"https://api.github.com/repos/pachyderm/pachyderm/pulls/128/comments"},"review_comment":{"href":"https://api.github.com/repos/pachyderm/pachyderm/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pachyderm/pachyderm/pulls/128/commits"},"statuses":{"href":"https://api.github.com/repos/pachyderm/pachyderm/statuses/2048f0feed8674bc3f884cd76ba5337c9fad72c0"}}}}