diff options
author | Paul Osborne <osbpau@gmail.com> | 2016-10-29 17:04:37 -0500 |
---|---|---|
committer | Paul Osborne <osbpau@gmail.com> | 2017-01-15 22:40:23 -0600 |
commit | 4e5d3768a470084752783b8af577251327ce5baf (patch) | |
tree | b36627a4f9219cbe5eaf875d9fda5923da25cd4a /src/unistd.rs | |
parent | 1fbf1fe75b5b69553e7fa9eb0780d36bb24c0aa9 (diff) | |
download | nix-4e5d3768a470084752783b8af577251327ce5baf.zip |
unistd: add docs for gethostname and tweak API
Although the underlying C API does take a pointer to a set of
characters, it is a requirement of almost every operating system
that these bytes not contain a premature NUL character or other
special characters. In other words, you want a `&str`. Changing
this to make the API make a bit more sense.
Signed-off-by: Paul Osborne <osbpau@gmail.com>
Diffstat (limited to 'src/unistd.rs')
-rw-r--r-- | src/unistd.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/unistd.rs b/src/unistd.rs index f7efbdee..30180108 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -480,7 +480,14 @@ pub fn daemon(nochdir: bool, noclose: bool) -> Result<()> { Errno::result(res).map(drop) } -pub fn sethostname(name: &[u8]) -> Result<()> { +/// Set the system host name (see +/// [gethostname(2)](http://man7.org/linux/man-pages/man2/gethostname.2.html)). +/// +/// Given a name, attempt to update the system host name to the given string. +/// On some systems, the host name is limited to as few as 64 bytes. An error +/// will be return if the name is not valid or the current process does not have +/// permissions to update the host name. +pub fn sethostname(name: &str) -> Result<()> { // Handle some differences in type of the len arg across platforms. cfg_if! { if #[cfg(any(target_os = "dragonfly", |