summaryrefslogtreecommitdiff
path: root/src/hostname.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1994-05-20 13:50:43 +0000
committerJim Meyering <jim@meyering.net>1994-05-20 13:50:43 +0000
commitb98b0e107f67055d20db6005b6dee676a79c06a7 (patch)
treec8c093359626907c5ed207d60fc5d6811da8e11b /src/hostname.c
parenta0f30b3f2c9254411cce3cde1639980b623bcb75 (diff)
downloadcoreutils-b98b0e107f67055d20db6005b6dee676a79c06a7.tar.xz
merge with 1.10 + local build mods
Diffstat (limited to 'src/hostname.c')
-rw-r--r--src/hostname.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/hostname.c b/src/hostname.c
index 300dac405..441c08953 100644
--- a/src/hostname.c
+++ b/src/hostname.c
@@ -29,10 +29,32 @@
#endif
#include <stdio.h>
+#include <sys/types.h>
#include "system.h"
#include "long-options.h"
+#if !defined(HAVE_SETHOSTNAME) && defined(HAVE_SYSINFO) && \
+ defined (HAVE_SYS_SYSTEMINFO_H) && defined(HAVE_LIMITS_H)
+#include <limits.h>
+#include <sys/systeminfo.h>
+
+int
+sethostname (name, namelen)
+ char *name;
+ int namelen;
+{
+ /* Using sysinfo() is the SVR4 mechanism to set a hostname. */
+ int result;
+
+ result = sysinfo (SI_SET_HOSTNAME, name, namelen);
+
+ return (result == -1 ? result : 0);
+}
+
+#define HAVE_SETHOSTNAME 1 /* Now we have it... */
+#endif
+
void error ();
char *xgethostname ();