]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
utils.h: Avoid duplicated sethostname implementation 1952/head
authorMarcos Paulo de Souza <marcos.souza.org@gmail.com>
Tue, 28 Nov 2017 01:48:57 +0000 (23:48 -0200)
committerMarcos Paulo de Souza <marcos.souza.org@gmail.com>
Tue, 28 Nov 2017 02:13:49 +0000 (00:13 -0200)
Move duplicated implementatin of sethostname from conf.c and
lxc_unshare.c to utils.h

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
src/lxc/conf.c
src/lxc/tools/lxc_unshare.c
src/lxc/utils.h

index 2d2a3fca225975cae3a99dd8b7beb8e435105f90..ae30b5b8726cf55cd737cba2adb2cb2e3d1c8f48 100644 (file)
@@ -122,19 +122,6 @@ static int pivot_root(const char * new_root, const char * put_old)
 extern int pivot_root(const char * new_root, const char * put_old);
 #endif
 
-/* Define sethostname() if missing from the C library */
-#ifndef HAVE_SETHOSTNAME
-static int sethostname(const char * name, size_t len)
-{
-#ifdef __NR_sethostname
-       return syscall(__NR_sethostname, name, len);
-#else
-       errno = ENOSYS;
-       return -1;
-#endif
-}
-#endif
-
 #ifndef MS_PRIVATE
 #define MS_PRIVATE (1<<18)
 #endif
index 25af9711946eb4b20689d36d14a593c27f6fc58a..1c790737b19533c6c8ecb09a330c42b3ea427438 100644 (file)
@@ -32,7 +32,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/socket.h>
-#include <sys/syscall.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <unistd.h>
 #include "network.h"
 #include "utils.h"
 
-/* Define sethostname() if missing from the C library */
-#ifndef HAVE_SETHOSTNAME
-static int sethostname(const char * name, size_t len)
-{
-#ifdef __NR_sethostname
-return syscall(__NR_sethostname, name, len);
-#else
-errno = ENOSYS;
-return -1;
-#endif
-}
-#endif
-
 lxc_log_define(lxc_unshare_ui, lxc);
 
 struct my_iflist
index 94646326fdf1b6ff97655f682219f11ce7c69614..5273203cf972d399ec04dfc5e5a85b52a5b24bc4 100644 (file)
@@ -120,6 +120,19 @@ static inline int setns(int fd, int nstype)
 }
 #endif
 
+/* Define sethostname() if missing from the C library */
+#ifndef HAVE_SETHOSTNAME
+static int sethostname(const char * name, size_t len)
+{
+#ifdef __NR_sethostname
+return syscall(__NR_sethostname, name, len);
+#else
+errno = ENOSYS;
+return -1;
+#endif
+}
+#endif
+
 /* Define unshare() if missing from the C library */
 #ifndef HAVE_UNSHARE
 static inline int unshare(int flags)