Unverified Commit 8a0a156e by Christian Brauner Committed by GitHub

Merge pull request #1952 from marcosps/duplicated_sethostname

utils.h: Avoid duplicated sethostname implementation
parents 7baea1c1 ac181b5c
...@@ -122,19 +122,6 @@ static int pivot_root(const char * new_root, const char * put_old) ...@@ -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); extern int pivot_root(const char * new_root, const char * put_old);
#endif #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 #ifndef MS_PRIVATE
#define MS_PRIVATE (1<<18) #define MS_PRIVATE (1<<18)
#endif #endif
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/syscall.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
...@@ -45,19 +44,6 @@ ...@@ -45,19 +44,6 @@
#include "network.h" #include "network.h"
#include "utils.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); lxc_log_define(lxc_unshare_ui, lxc);
struct my_iflist struct my_iflist
......
...@@ -120,6 +120,19 @@ static inline int setns(int fd, int nstype) ...@@ -120,6 +120,19 @@ static inline int setns(int fd, int nstype)
} }
#endif #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 */ /* Define unshare() if missing from the C library */
#ifndef HAVE_UNSHARE #ifndef HAVE_UNSHARE
static inline int unshare(int flags) static inline int unshare(int flags)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment