]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
utils.h: Avoid duplicated sethostname implementation
authorMarcos Paulo de Souza <marcos.souza.org@gmail.com>
Tue, 28 Nov 2017 01:48:57 +0000 (23:48 -0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 17 Dec 2017 14:22:17 +0000 (15:22 +0100)
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 9115f50e61317c3d1e0db46b3241b44a9183ddf6..898c728ad85107b6899ccb5a55f15acc61a2a3ce 100644 (file)
@@ -117,19 +117,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 b6b7f4ca5d446ad088e73c281abd0355e6936532..fe743411b16264b6be2eaec4acd5f5705a8c003f 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 94ca49f415dac559eb2e604fc9e150e278ae49b8..026599806cb6d7b46a3263206b8ab2fb823f365e 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)