{"action":"created","comment":{"url":"https://api.github.com/repos/nix-rust/nix/pulls/comments/86009913","pull_request_review_id":6690938,"id":86009913,"diff_hunk":"@@ -402,12 +476,39 @@ pub fn sethostname(name: &[u8]) -> Result<()> {\n     Errno::result(res).map(drop)\n }\n \n-pub fn gethostname(name: &mut [u8]) -> Result<()> {\n-    let ptr = name.as_mut_ptr() as *mut c_char;\n-    let len = name.len() as size_t;\n+/// Get the host name and store it int the provided buffer, returning the actual\n+/// length stored in the buffer (see\n+/// [gethostname(2)](http://man7.org/linux/man-pages/man2/gethostname.2.html)).\n+///\n+/// This function call attempts to get the host name for the running system and\n+/// store it in a provided buffer.  The buffer will be populated with bytes up\n+/// to the length of the provided slice including a NUL terminating byte.  If\n+/// the hostname is longer than the length provided, no error will be provided.\n+/// The posix specification does not specify whether implementations will\n+/// null-terminate in this case, but the nix implementation will ensure that the\n+/// buffer is null terminated in this case.\n+///\n+/// The return size is the number of bytes actually written into the slice\n+/// including the NULL terminator.  Here's an example of how you might actually\n+/// use this in practice:\n+///\n+/// ```no_run\n+/// use nix::unistd;\n+///\n+/// let mut buf = [0u8; 64];\n+/// let hostname_cstr = unistd::gethostname(&mut buf).expect(\"Failed getting hostname\");\n+/// let hostname = hostname_cstr.to_str().expect(\"Hostname wasn't valid UTF-8\");\n+/// println!(\"Hostname: {}\", hostname);\n+/// ```\n+pub fn gethostname<'a>(buffer: &'a mut [u8]) -> Result<&'a CStr> {\n+    let ptr = buffer.as_mut_ptr() as *mut c_char;","path":"src/unistd.rs","position":149,"original_position":149,"commit_id":"99a17260e42e673d000028e03d3f7cad32cf45f6","original_commit_id":"99a17260e42e673d000028e03d3f7cad32cf45f6","user":{"login":"kamalmarhubi","id":50936,"avatar_url":"https://avatars.githubusercontent.com/u/50936?v=3","gravatar_id":"","url":"https://api.github.com/users/kamalmarhubi","html_url":"https://github.com/kamalmarhubi","followers_url":"https://api.github.com/users/kamalmarhubi/followers","following_url":"https://api.github.com/users/kamalmarhubi/following{/other_user}","gists_url":"https://api.github.com/users/kamalmarhubi/gists{/gist_id}","starred_url":"https://api.github.com/users/kamalmarhubi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kamalmarhubi/subscriptions","organizations_url":"https://api.github.com/users/kamalmarhubi/orgs","repos_url":"https://api.github.com/users/kamalmarhubi/repos","events_url":"https://api.github.com/users/kamalmarhubi/events{/privacy}","received_events_url":"https://api.github.com/users/kamalmarhubi/received_events","type":"User","site_admin":false},"body":"Regarding this function, we cannot guarantee it is a valid `&CStr` that comes back:\r\n\r\n\r\n> gethostname() returns the null-terminated hostname in the character array name, which has a length of len bytes.  If the null-terminated hostname is too large to fit, then the name is truncated, and __no error is returned__ (but see NOTES below).  POSIX.1 says that if such truncation occurs, then __it is unspecified whether the returned buffer includes a terminating null byte__.\r\n```\r\n―http://man7.org/linux/man-pages/man2/gethostname.2.html#DESCRIPTION","created_at":"2016-11-01T19:53:06Z","updated_at":"2016-11-01T19:53:07Z","html_url":"https://github.com/nix-rust/nix/pull/452#discussion_r86009913","pull_request_url":"https://api.github.com/repos/nix-rust/nix/pulls/452","_links":{"self":{"href":"https://api.github.com/repos/nix-rust/nix/pulls/comments/86009913"},"html":{"href":"https://github.com/nix-rust/nix/pull/452#discussion_r86009913"},"pull_request":{"href":"https://api.github.com/repos/nix-rust/nix/pulls/452"}}},"pull_request":{"url":"https://api.github.com/repos/nix-rust/nix/pulls/452","id":91504279,"html_url":"https://github.com/nix-rust/nix/pull/452","diff_url":"https://github.com/nix-rust/nix/pull/452.diff","patch_url":"https://github.com/nix-rust/nix/pull/452.patch","issue_url":"https://api.github.com/repos/nix-rust/nix/issues/452","number":452,"state":"open","locked":false,"title":"Additional documentation additions","user":{"login":"posborne","id":41714,"avatar_url":"https://avatars.githubusercontent.com/u/41714?v=3","gravatar_id":"","url":"https://api.github.com/users/posborne","html_url":"https://github.com/posborne","followers_url":"https://api.github.com/users/posborne/followers","following_url":"https://api.github.com/users/posborne/following{/other_user}","gists_url":"https://api.github.com/users/posborne/gists{/gist_id}","starred_url":"https://api.github.com/users/posborne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/posborne/subscriptions","organizations_url":"https://api.github.com/users/posborne/orgs","repos_url":"https://api.github.com/users/posborne/repos","events_url":"https://api.github.com/users/posborne/events{/privacy}","received_events_url":"https://api.github.com/users/posborne/received_events","type":"User","site_admin":false},"body":"This is a second round of doc additions.  There are also some funcitonal changes to APIs for getting/setting hostname that need to be reviewed.\n\nr? @nix-rust/nix-maintainers \n","created_at":"2016-10-29T22:35:35Z","updated_at":"2016-11-01T19:53:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b9bc867362bcfd0be4be54ca0a4eb1bea035997c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/nix-rust/nix/pulls/452/commits","review_comments_url":"https://api.github.com/repos/nix-rust/nix/pulls/452/comments","review_comment_url":"https://api.github.com/repos/nix-rust/nix/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nix-rust/nix/issues/452/comments","statuses_url":"https://api.github.com/repos/nix-rust/nix/statuses/99a17260e42e673d000028e03d3f7cad32cf45f6","head":{"label":"posborne:additional-documentation-additions","ref":"additional-documentation-additions","sha":"99a17260e42e673d000028e03d3f7cad32cf45f6","user":{"login":"posborne","id":41714,"avatar_url":"https://avatars.githubusercontent.com/u/41714?v=3","gravatar_id":"","url":"https://api.github.com/users/posborne","html_url":"https://github.com/posborne","followers_url":"https://api.github.com/users/posborne/followers","following_url":"https://api.github.com/users/posborne/following{/other_user}","gists_url":"https://api.github.com/users/posborne/gists{/gist_id}","starred_url":"https://api.github.com/users/posborne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/posborne/subscriptions","organizations_url":"https://api.github.com/users/posborne/orgs","repos_url":"https://api.github.com/users/posborne/repos","events_url":"https://api.github.com/users/posborne/events{/privacy}","received_events_url":"https://api.github.com/users/posborne/received_events","type":"User","site_admin":false},"repo":{"id":34225983,"name":"nix-rust","full_name":"posborne/nix-rust","owner":{"login":"posborne","id":41714,"avatar_url":"https://avatars.githubusercontent.com/u/41714?v=3","gravatar_id":"","url":"https://api.github.com/users/posborne","html_url":"https://github.com/posborne","followers_url":"https://api.github.com/users/posborne/followers","following_url":"https://api.github.com/users/posborne/following{/other_user}","gists_url":"https://api.github.com/users/posborne/gists{/gist_id}","starred_url":"https://api.github.com/users/posborne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/posborne/subscriptions","organizations_url":"https://api.github.com/users/posborne/orgs","repos_url":"https://api.github.com/users/posborne/repos","events_url":"https://api.github.com/users/posborne/events{/privacy}","received_events_url":"https://api.github.com/users/posborne/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/posborne/nix-rust","description":"Rust friendly bindings to *nix APIs","fork":true,"url":"https://api.github.com/repos/posborne/nix-rust","forks_url":"https://api.github.com/repos/posborne/nix-rust/forks","keys_url":"https://api.github.com/repos/posborne/nix-rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/posborne/nix-rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/posborne/nix-rust/teams","hooks_url":"https://api.github.com/repos/posborne/nix-rust/hooks","issue_events_url":"https://api.github.com/repos/posborne/nix-rust/issues/events{/number}","events_url":"https://api.github.com/repos/posborne/nix-rust/events","assignees_url":"https://api.github.com/repos/posborne/nix-rust/assignees{/user}","branches_url":"https://api.github.com/repos/posborne/nix-rust/branches{/branch}","tags_url":"https://api.github.com/repos/posborne/nix-rust/tags","blobs_url":"https://api.github.com/repos/posborne/nix-rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/posborne/nix-rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/posborne/nix-rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/posborne/nix-rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/posborne/nix-rust/statuses/{sha}","languages_url":"https://api.github.com/repos/posborne/nix-rust/languages","stargazers_url":"https://api.github.com/repos/posborne/nix-rust/stargazers","contributors_url":"https://api.github.com/repos/posborne/nix-rust/contributors","subscribers_url":"https://api.github.com/repos/posborne/nix-rust/subscribers","subscription_url":"https://api.github.com/repos/posborne/nix-rust/subscription","commits_url":"https://api.github.com/repos/posborne/nix-rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/posborne/nix-rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/posborne/nix-rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/posborne/nix-rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/posborne/nix-rust/contents/{+path}","compare_url":"https://api.github.com/repos/posborne/nix-rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/posborne/nix-rust/merges","archive_url":"https://api.github.com/repos/posborne/nix-rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/posborne/nix-rust/downloads","issues_url":"https://api.github.com/repos/posborne/nix-rust/issues{/number}","pulls_url":"https://api.github.com/repos/posborne/nix-rust/pulls{/number}","milestones_url":"https://api.github.com/repos/posborne/nix-rust/milestones{/number}","notifications_url":"https://api.github.com/repos/posborne/nix-rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/posborne/nix-rust/labels{/name}","releases_url":"https://api.github.com/repos/posborne/nix-rust/releases{/id}","deployments_url":"https://api.github.com/repos/posborne/nix-rust/deployments","created_at":"2015-04-19T21:53:36Z","updated_at":"2016-02-12T16:52:21Z","pushed_at":"2016-10-29T22:34:05Z","git_url":"git://github.com/posborne/nix-rust.git","ssh_url":"git@github.com:posborne/nix-rust.git","clone_url":"https://github.com/posborne/nix-rust.git","svn_url":"https://github.com/posborne/nix-rust","homepage":"","size":3788,"stargazers_count":0,"watchers_count":0,"language":"Rust","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":"nix-rust:master","ref":"master","sha":"ff4484d343dbd8f224d767b4499cc502c4c7f016","user":{"login":"nix-rust","id":17190941,"avatar_url":"https://avatars.githubusercontent.com/u/17190941?v=3","gravatar_id":"","url":"https://api.github.com/users/nix-rust","html_url":"https://github.com/nix-rust","followers_url":"https://api.github.com/users/nix-rust/followers","following_url":"https://api.github.com/users/nix-rust/following{/other_user}","gists_url":"https://api.github.com/users/nix-rust/gists{/gist_id}","starred_url":"https://api.github.com/users/nix-rust/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nix-rust/subscriptions","organizations_url":"https://api.github.com/users/nix-rust/orgs","repos_url":"https://api.github.com/users/nix-rust/repos","events_url":"https://api.github.com/users/nix-rust/events{/privacy}","received_events_url":"https://api.github.com/users/nix-rust/received_events","type":"Organization","site_admin":false},"repo":{"id":22734848,"name":"nix","full_name":"nix-rust/nix","owner":{"login":"nix-rust","id":17190941,"avatar_url":"https://avatars.githubusercontent.com/u/17190941?v=3","gravatar_id":"","url":"https://api.github.com/users/nix-rust","html_url":"https://github.com/nix-rust","followers_url":"https://api.github.com/users/nix-rust/followers","following_url":"https://api.github.com/users/nix-rust/following{/other_user}","gists_url":"https://api.github.com/users/nix-rust/gists{/gist_id}","starred_url":"https://api.github.com/users/nix-rust/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nix-rust/subscriptions","organizations_url":"https://api.github.com/users/nix-rust/orgs","repos_url":"https://api.github.com/users/nix-rust/repos","events_url":"https://api.github.com/users/nix-rust/events{/privacy}","received_events_url":"https://api.github.com/users/nix-rust/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nix-rust/nix","description":"Rust friendly bindings to *nix APIs","fork":false,"url":"https://api.github.com/repos/nix-rust/nix","forks_url":"https://api.github.com/repos/nix-rust/nix/forks","keys_url":"https://api.github.com/repos/nix-rust/nix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nix-rust/nix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nix-rust/nix/teams","hooks_url":"https://api.github.com/repos/nix-rust/nix/hooks","issue_events_url":"https://api.github.com/repos/nix-rust/nix/issues/events{/number}","events_url":"https://api.github.com/repos/nix-rust/nix/events","assignees_url":"https://api.github.com/repos/nix-rust/nix/assignees{/user}","branches_url":"https://api.github.com/repos/nix-rust/nix/branches{/branch}","tags_url":"https://api.github.com/repos/nix-rust/nix/tags","blobs_url":"https://api.github.com/repos/nix-rust/nix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nix-rust/nix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nix-rust/nix/git/refs{/sha}","trees_url":"https://api.github.com/repos/nix-rust/nix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nix-rust/nix/statuses/{sha}","languages_url":"https://api.github.com/repos/nix-rust/nix/languages","stargazers_url":"https://api.github.com/repos/nix-rust/nix/stargazers","contributors_url":"https://api.github.com/repos/nix-rust/nix/contributors","subscribers_url":"https://api.github.com/repos/nix-rust/nix/subscribers","subscription_url":"https://api.github.com/repos/nix-rust/nix/subscription","commits_url":"https://api.github.com/repos/nix-rust/nix/commits{/sha}","git_commits_url":"https://api.github.com/repos/nix-rust/nix/git/commits{/sha}","comments_url":"https://api.github.com/repos/nix-rust/nix/comments{/number}","issue_comment_url":"https://api.github.com/repos/nix-rust/nix/issues/comments{/number}","contents_url":"https://api.github.com/repos/nix-rust/nix/contents/{+path}","compare_url":"https://api.github.com/repos/nix-rust/nix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nix-rust/nix/merges","archive_url":"https://api.github.com/repos/nix-rust/nix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nix-rust/nix/downloads","issues_url":"https://api.github.com/repos/nix-rust/nix/issues{/number}","pulls_url":"https://api.github.com/repos/nix-rust/nix/pulls{/number}","milestones_url":"https://api.github.com/repos/nix-rust/nix/milestones{/number}","notifications_url":"https://api.github.com/repos/nix-rust/nix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nix-rust/nix/labels{/name}","releases_url":"https://api.github.com/repos/nix-rust/nix/releases{/id}","deployments_url":"https://api.github.com/repos/nix-rust/nix/deployments","created_at":"2014-08-07T20:03:36Z","updated_at":"2016-11-01T09:51:02Z","pushed_at":"2016-11-01T19:10:46Z","git_url":"git://github.com/nix-rust/nix.git","ssh_url":"git@github.com:nix-rust/nix.git","clone_url":"https://github.com/nix-rust/nix.git","svn_url":"https://github.com/nix-rust/nix","homepage":"","size":4080,"stargazers_count":386,"watchers_count":386,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":126,"mirror_url":null,"open_issues_count":57,"forks":126,"open_issues":57,"watchers":386,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nix-rust/nix/pulls/452"},"html":{"href":"https://github.com/nix-rust/nix/pull/452"},"issue":{"href":"https://api.github.com/repos/nix-rust/nix/issues/452"},"comments":{"href":"https://api.github.com/repos/nix-rust/nix/issues/452/comments"},"review_comments":{"href":"https://api.github.com/repos/nix-rust/nix/pulls/452/comments"},"review_comment":{"href":"https://api.github.com/repos/nix-rust/nix/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nix-rust/nix/pulls/452/commits"},"statuses":{"href":"https://api.github.com/repos/nix-rust/nix/statuses/99a17260e42e673d000028e03d3f7cad32cf45f6"}}}}
{"actor":{"display_login":"kamalmarhubi"}}