Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
ed754cd2
Unverified
Commit
ed754cd2
authored
Mar 18, 2020
by
Stéphane Graber
Committed by
GitHub
Mar 18, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3304 from brauner/2020-03-18/fixes
tree-wide: introduce and use syscall number header
parents
ee555b28
bed09c9c
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
507 additions
and
205 deletions
+507
-205
Makefile.am
src/lxc/Makefile.am
+6
-0
cgroup2_devices.h
src/lxc/cgroups/cgroup2_devices.h
+7
-33
lxccontainer.c
src/lxc/lxccontainer.c
+0
-13
raw_syscalls.c
src/lxc/raw_syscalls.c
+2
-11
raw_syscalls.h
src/lxc/raw_syscalls.h
+1
-1
seccomp.c
src/lxc/seccomp.c
+0
-5
syscall_numbers.h
src/lxc/syscall_numbers.h
+478
-0
syscall_wrappers.h
src/lxc/syscall_wrappers.h
+12
-123
lxc_unshare.c
src/lxc/tools/lxc_unshare.c
+1
-19
No files found.
src/lxc/Makefile.am
View file @
ed754cd2
...
...
@@ -43,6 +43,7 @@ noinst_HEADERS = api_extensions.h \
storage/storage_utils.h
\
storage/zfs.h
\
string_utils.h
\
syscall_numbers.h
\
syscall_wrappers.h
\
terminal.h
\
../tests/lxctest.h
\
...
...
@@ -145,6 +146,7 @@ liblxc_la_SOURCES = af_unix.c af_unix.h \
storage/zfs.c storage/zfs.h
\
string_utils.c string_utils.h
\
sync.c sync.h
\
syscall_numbers.h
\
syscall_wrappers.h
\
terminal.c
\
utils.c utils.h
\
...
...
@@ -360,6 +362,7 @@ lxc_top_SOURCES = tools/lxc_top.c \
lxc_unfreeze_SOURCES
=
tools/lxc_unfreeze.c
\
tools/arguments.c tools/arguments.h
lxc_unshare_SOURCES
=
tools/lxc_unshare.c
\
syscall_numbers.h
\
tools/arguments.c tools/arguments.h
lxc_wait_SOURCES
=
tools/lxc_wait.c
\
tools/arguments.c tools/arguments.h
...
...
@@ -381,6 +384,7 @@ init_lxc_SOURCES = cmd/lxc_init.c \
memory_utils.h
\
parse.c parse.h
\
raw_syscalls.c raw_syscalls.h
\
syscall_numbers.h
\
string_utils.c string_utils.h
init_lxc_LDFLAGS
=
-pthread
...
...
@@ -391,6 +395,7 @@ lxc_monitord_SOURCES = cmd/lxc_monitord.c \
mainloop.c mainloop.h
\
monitor.c monitor.h
\
raw_syscalls.c raw_syscalls.h
\
syscall_numbers.h
\
utils.c utils.h
lxc_user_nic_SOURCES
=
cmd/lxc_user_nic.c
\
../include/netns_ifaddrs.c ../include/netns_ifaddrs.h
\
...
...
@@ -399,6 +404,7 @@ lxc_user_nic_SOURCES = cmd/lxc_user_nic.c \
network.c network.h
\
parse.c parse.h
\
raw_syscalls.c raw_syscalls.h
\
syscall_numbers.h
\
file_utils.c file_utils.h
\
string_utils.c string_utils.h
\
syscall_wrappers.h
...
...
src/lxc/cgroups/cgroup2_devices.h
View file @
ed754cd2
...
...
@@ -17,50 +17,24 @@
#include "conf.h"
#include "config.h"
#include "syscall_numbers.h"
#ifdef HAVE_STRUCT_BPF_CGROUP_DEV_CTX
#include <linux/bpf.h>
#include <linux/filter.h>
#endif
#if !HAVE_BPF
#if !(defined __NR_bpf && __NR_bpf > 0)
#if defined __NR_bpf
#undef __NR_bpf
#endif
#if defined __i386__
#define __NR_bpf 357
#elif defined __x86_64__
#define __NR_bpf 321
#elif defined __aarch64__
#define __NR_bpf 280
#elif defined __arm__
#define __NR_bpf 386
#elif defined __sparc__
#define __NR_bpf 349
#elif defined __s390__
#define __NR_bpf 351
#elif defined __tilegx__
#define __NR_bpf 280
#else
#warning "__NR_bpf not defined for your architecture"
#endif
#endif
#ifndef HAVE_BPF
union
bpf_attr
;
static
inline
int
missing_bpf
(
int
cmd
,
union
bpf_attr
*
attr
,
size_t
size
)
{
#ifdef __NR_bpf
return
(
int
)
syscall
(
__NR_bpf
,
cmd
,
attr
,
size
);
#else
errno
=
ENOSYS
;
return
-
1
;
#endif
return
syscall
(
__NR_bpf
,
cmd
,
attr
,
size
);
}
#define bpf missing_bpf
#endif
#endif
/* HAVE_BPF */
struct
bpf_program
{
int
device_list_type
;
...
...
@@ -70,7 +44,7 @@ struct bpf_program {
size_t
n_instructions
;
#ifdef HAVE_STRUCT_BPF_CGROUP_DEV_CTX
struct
bpf_insn
*
instructions
;
#endif
#endif
/* HAVE_STRUCT_BPF_CGROUP_DEV_CTX */
char
*
attached_path
;
int
attached_type
;
...
...
@@ -97,7 +71,7 @@ static inline void __auto_bpf_program_free__(struct bpf_program **prog)
}
}
int
bpf_list_add_device
(
struct
lxc_conf
*
conf
,
struct
device_item
*
device
);
#else
#else
/* !HAVE_STRUCT_BPF_CGROUP_DEV_CTX */
static
inline
struct
bpf_program
*
bpf_program_new
(
uint32_t
prog_type
)
{
errno
=
ENOSYS
;
...
...
@@ -160,7 +134,7 @@ static inline int bpf_list_add_device(struct lxc_conf *conf,
errno
=
ENOSYS
;
return
-
1
;
}
#endif
#endif
/* !HAVE_STRUCT_BPF_CGROUP_DEV_CTX */
#define __do_bpf_program_free \
__attribute__((__cleanup__(__auto_bpf_program_free__)))
...
...
src/lxc/lxccontainer.c
View file @
ed754cd2
...
...
@@ -81,19 +81,6 @@
#include "include/strlcpy.h"
#endif
/* Define faccessat() if missing from the C library */
#ifndef HAVE_FACCESSAT
static
int
faccessat
(
int
__fd
,
const
char
*
__file
,
int
__type
,
int
__flag
)
{
#ifdef __NR_faccessat
return
syscall
(
__NR_faccessat
,
__fd
,
__file
,
__type
,
__flag
);
#else
errno
=
ENOSYS
;
return
-
1
;
#endif
}
#endif
lxc_log_define
(
lxccontainer
,
lxc
);
static
bool
do_lxcapi_destroy
(
struct
lxc_container
*
c
);
...
...
src/lxc/raw_syscalls.c
View file @
ed754cd2
...
...
@@ -15,16 +15,12 @@
#include "config.h"
#include "macro.h"
#include "raw_syscalls.h"
#include "syscall_numbers.h"
int
lxc_raw_execveat
(
int
dirfd
,
const
char
*
pathname
,
char
*
const
argv
[],
char
*
const
envp
[],
int
flags
)
{
#ifdef __NR_execveat
syscall
(
__NR_execveat
,
dirfd
,
pathname
,
argv
,
envp
,
flags
);
#else
errno
=
ENOSYS
;
#endif
return
-
1
;
return
syscall
(
__NR_execveat
,
dirfd
,
pathname
,
argv
,
envp
,
flags
);
}
/*
...
...
@@ -123,11 +119,6 @@ pid_t lxc_raw_clone_cb(int (*fn)(void *), void *args, unsigned long flags,
return
pid
;
}
/* For all the architectures we care about it's the same syscall number. */
#ifndef __NR_pidfd_send_signal
#define __NR_pidfd_send_signal 424
#endif
int
lxc_raw_pidfd_send_signal
(
int
pidfd
,
int
sig
,
siginfo_t
*
info
,
unsigned
int
flags
)
{
...
...
src/lxc/raw_syscalls.h
View file @
ed754cd2
...
...
@@ -81,7 +81,7 @@ static inline pid_t lxc_raw_getpid(void)
static
inline
pid_t
lxc_raw_gettid
(
void
)
{
#if
def __NR_gettid
#if
__NR_gettid > 0
return
syscall
(
__NR_gettid
);
#else
return
lxc_raw_getpid
();
...
...
src/lxc/seccomp.c
View file @
ed754cd2
...
...
@@ -38,12 +38,7 @@ lxc_log_define(seccomp, lxc);
static
inline
int
__seccomp
(
unsigned
int
operation
,
unsigned
int
flags
,
void
*
args
)
{
#ifdef __NR_seccomp
return
syscall
(
__NR_seccomp
,
operation
,
flags
,
args
);
#else
errno
=
ENOSYS
;
return
-
1
;
#endif
}
#endif
...
...
src/lxc/syscall_numbers.h
0 → 100644
View file @
ed754cd2
/* SPDX-License-Identifier: LGPL-2.1+ */
#ifndef __LXC_SYSCALL_NUMBERS_H
#define __LXC_SYSCALL_NUMBERS_H
#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif
#include <asm/unistd.h>
#include <errno.h>
#include <linux/keyctl.h>
#include <sched.h>
#include <stdint.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#ifdef HAVE_LINUX_MEMFD_H
#include <linux/memfd.h>
#endif
#ifdef HAVE_SYS_SIGNALFD_H
#include <sys/signalfd.h>
#endif
#ifndef __NR_keyctl
#if defined __i386__
#define __NR_keyctl 288
#elif defined __x86_64__
#define __NR_keyctl 250
#elif defined __arm__
#define __NR_keyctl 311
#elif defined __aarch64__
#define __NR_keyctl 311
#elif defined __s390__
#define __NR_keyctl 280
#elif defined __powerpc__
#define __NR_keyctl 271
#elif defined __sparc__
#define __NR_keyctl 283
#elif defined __ia64__
#define __NR_keyctl 249
#elif defined _MIPS_SIM
#if _MIPS_SIM == _MIPS_SIM_ABI32
/* o32 */
#define __NR_keyctl 4282
#endif
#if _MIPS_SIM == _MIPS_SIM_NABI32
/* n32 */
#define __NR_keyctl 6245
#endif
#if _MIPS_SIM == _MIPS_SIM_ABI64
/* n64 */
#define __NR_keyctl 5241
#endif
#else
#define -1
#warning "__NR_keyctl not defined for your architecture"
#endif
#endif
#ifndef __NR_memfd_create
#if defined __i386__
#define __NR_memfd_create 356
#elif defined __x86_64__
#define __NR_memfd_create 319
#elif defined __arm__
#define __NR_memfd_create 385
#elif defined __aarch64__
#define __NR_memfd_create 279
#elif defined __s390__
#define __NR_memfd_create 350
#elif defined __powerpc__
#define __NR_memfd_create 360
#elif defined __sparc__
#define __NR_memfd_create 348
#elif defined __blackfin__
#define __NR_memfd_create 390
#elif defined __ia64__
#define __NR_memfd_create 1340
#elif defined _MIPS_SIM
#if _MIPS_SIM == _MIPS_SIM_ABI32
#define __NR_memfd_create 4354
#endif
#if _MIPS_SIM == _MIPS_SIM_NABI32
#define __NR_memfd_create 6318
#endif
#if _MIPS_SIM == _MIPS_SIM_ABI64
#define __NR_memfd_create 5314
#endif
#else
#define -1
#warning "__NR_memfd_create not defined for your architecture"
#endif
#endif
#ifndef __NR_pivot_root
#if defined __i386__
#define __NR_pivot_root 217
#elif defined __x86_64__
#define __NR_pivot_root 155
#elif defined __arm__
#define __NR_pivot_root 218
#elif defined __aarch64__
#define __NR_pivot_root 218
#elif defined __s390__
#define __NR_pivot_root 217
#elif defined __powerpc__
#define __NR_pivot_root 203
#elif defined __sparc__
#define __NR_pivot_root 146
#elif defined __ia64__
#define __NR_pivot_root 183
#elif defined _MIPS_SIM
#if _MIPS_SIM == _MIPS_SIM_ABI32
/* o32 */
#define __NR_pivot_root 4216
#endif
#if _MIPS_SIM == _MIPS_SIM_NABI32
/* n32 */
#define __NR_pivot_root 6151
#endif
#if _MIPS_SIM == _MIPS_SIM_ABI64
/* n64 */
#define __NR_pivot_root 5151
#endif
#else
#define -1
#warning "__NR_pivot_root not defined for your architecture"
#endif
#endif
#ifndef __NR_setns
#if defined __i386__
#define __NR_setns 346
#elif defined __x86_64__
#define __NR_setns 308
#elif defined __arm__
#define __NR_setns 375
#elif defined __aarch64__
#define __NR_setns 375
#elif defined __s390__
#define __NR_setns 339
#elif defined __powerpc__
#define __NR_setns 350
#elif defined __sparc__
#define __NR_setns 337
#elif defined __ia64__
#define __NR_setns 306
#elif defined _MIPS_SIM
#if _MIPS_SIM == _MIPS_SIM_ABI32
/* o32 */
#define __NR_setns 4344
#endif
#if _MIPS_SIM == _MIPS_SIM_NABI32
/* n32 */
#define __NR_setns 6308
#endif
#if _MIPS_SIM == _MIPS_SIM_ABI64
/* n64 */
#define __NR_setns 5303
#endif
#else
#define -1
#warning "__NR_setns not defined for your architecture"
#endif
#endif
#ifndef __NR_sethostname
#if defined __i386__
#define __NR_sethostname 74
#elif defined __x86_64__
#define __NR_sethostname 170
#elif defined __arm__
#define __NR_sethostname 74
#elif defined __aarch64__
#define __NR_sethostname 74
#elif defined __s390__
#define __NR_sethostname 74
#elif defined __powerpc__
#define __NR_sethostname 74
#elif defined __sparc__
#define __NR_sethostname 88
#elif defined __ia64__
#define __NR_sethostname 59
#elif defined _MIPS_SIM
#if _MIPS_SIM == _MIPS_SIM_ABI32
/* o32 */
#define __NR_sethostname 474
#endif
#if _MIPS_SIM == _MIPS_SIM_NABI32
/* n32 */
#define __NR_sethostname 6165
#endif
#if _MIPS_SIM == _MIPS_SIM_ABI64
/* n64 */
#define __NR_sethostname 5165
#endif
#else
#define -1
#warning "__NR_sethostname not defined for your architecture"
#endif
#endif
#ifndef __NR_signalfd
#if defined __i386__
#define __NR_signalfd 321
#elif defined __x86_64__
#define __NR_signalfd 282
#elif defined __arm__
#define __NR_signalfd 349
#elif defined __aarch64__
#define __NR_signalfd 349
#elif defined __s390__
#define __NR_signalfd 316
#elif defined __powerpc__
#define __NR_signalfd 305
#elif defined __sparc__
#define __NR_signalfd 311
#elif defined __ia64__
#define __NR_signalfd 283
#elif defined _MIPS_SIM
#if _MIPS_SIM == _MIPS_SIM_ABI32
/* o32 */
#define __NR_signalfd 4317
#endif
#if _MIPS_SIM == _MIPS_SIM_NABI32
/* n32 */
#define __NR_signalfd 6280
#endif
#if _MIPS_SIM == _MIPS_SIM_ABI64
/* n64 */
#define __NR_signalfd 5276
#endif
#else
#define -1
#warning "__NR_signalfd not defined for your architecture"
#endif
#endif
#ifndef __NR_signalfd4
#if defined __i386__
#define __NR_signalfd4 327
#elif defined __x86_64__
#define __NR_signalfd4 289
#elif defined __arm__
#define __NR_signalfd4 355
#elif defined __aarch64__
#define __NR_signalfd4 355
#elif defined __s390__
#define __NR_signalfd4 322
#elif defined __powerpc__
#define __NR_signalfd4 313
#elif defined __sparc__
#define __NR_signalfd4 317
#elif defined __ia64__
#define __NR_signalfd4 289
#elif defined _MIPS_SIM
#if _MIPS_SIM == _MIPS_SIM_ABI32
/* o32 */
#define __NR_signalfd4 4324
#endif
#if _MIPS_SIM == _MIPS_SIM_NABI32
/* n32 */
#define __NR_signalfd4 6287
#endif
#if _MIPS_SIM == _MIPS_SIM_ABI64
/* n64 */
#define __NR_signalfd4 5283
#endif
#else
#define -1
#warning "__NR_signalfd4 not defined for your architecture"
#endif
#endif
#ifndef __NR_unshare
#if defined __i386__
#define __NR_unshare 310
#elif defined __x86_64__
#define __NR_unshare 272
#elif defined __arm__
#define __NR_unshare 337
#elif defined __aarch64__
#define __NR_unshare 337
#elif defined __s390__
#define __NR_unshare 303
#elif defined __powerpc__
#define __NR_unshare 282
#elif defined __sparc__
#define __NR_unshare 299
#elif defined __ia64__
#define __NR_unshare 272
#elif defined _MIPS_SIM
#if _MIPS_SIM == _MIPS_SIM_ABI32
/* o32 */
#define __NR_unshare 4303
#endif
#if _MIPS_SIM == _MIPS_SIM_NABI32
/* n32 */
#define __NR_unshare 6266
#endif
#if _MIPS_SIM == _MIPS_SIM_ABI64
/* n64 */
#define __NR_unshare 5262
#endif
#else
#define -1
#warning "__NR_unshare not defined for your architecture"
#endif
#endif
#ifndef __NR_bpf
#if defined __i386__
#define __NR_bpf 357
#elif defined __x86_64__
#define __NR_bpf 321
#elif defined __arm__
#define __NR_bpf 386
#elif defined __aarch64__
#define __NR_bpf 386
#elif defined __s390__
#define __NR_bpf 351
#elif defined __powerpc__
#define __NR_bpf 361
#elif defined __sparc__
#define __NR_bpf 349
#elif defined __ia64__
#define __NR_bpf 317
#elif defined _MIPS_SIM
#if _MIPS_SIM == _MIPS_SIM_ABI32
/* o32 */
#define __NR_bpf 4355
#endif
#if _MIPS_SIM == _MIPS_SIM_NABI32
/* n32 */
#define __NR_bpf 6319
#endif
#if _MIPS_SIM == _MIPS_SIM_ABI64
/* n64 */
#define __NR_bpf 5315
#endif
#else
#define -1
#warning "__NR_bpf not defined for your architecture"
#endif
#endif
#ifndef __NR_faccessat
#if defined __i386__
#define __NR_faccessat 307
#elif defined __x86_64__
#define __NR_faccessat 269
#elif defined __arm__
#define __NR_faccessat 334
#elif defined __aarch64__
#define __NR_faccessat 334
#elif defined __s390__
#define __NR_faccessat 300
#elif defined __powerpc__
#define __NR_faccessat 298
#elif defined __sparc__
#define __NR_faccessat 296
#elif defined __ia64__
#define __NR_faccessat 269
#elif defined _MIPS_SIM
#if _MIPS_SIM == _MIPS_SIM_ABI32
/* o32 */
#define __NR_faccessat 4300
#endif
#if _MIPS_SIM == _MIPS_SIM_NABI32
/* n32 */
#define __NR_faccessat 6263
#endif
#if _MIPS_SIM == _MIPS_SIM_ABI64
/* n64 */
#define __NR_faccessat 5259
#endif
#else
#define -1
#warning "__NR_faccessat not defined for your architecture"
#endif
#endif
#ifndef __NR_pidfd_send_signal
#if defined __alpha__
#define __NR_pidfd_send_signal 534
#elif defined _MIPS_SIM
#if _MIPS_SIM == _MIPS_SIM_ABI32
/* o32 */
#define __NR_pidfd_send_signal 4424
#endif
#if _MIPS_SIM == _MIPS_SIM_NABI32
/* n32 */
#define __NR_pidfd_send_signal 6424
#endif
#if _MIPS_SIM == _MIPS_SIM_ABI64
/* n64 */
#define __NR_pidfd_send_signal 5424
#endif
#else
#define __NR_pidfd_send_signal 424
#endif
#endif
#ifndef __NR_seccomp
#if defined __i386__
#define __NR_seccomp 354
#elif defined __x86_64__
#define __NR_seccomp 317
#elif defined __arm__
#define __NR_seccomp 383
#elif defined __aarch64__
#define __NR_seccomp 383
#elif defined __s390__
#define __NR_seccomp 348
#elif defined __powerpc__
#define __NR_seccomp 358
#elif defined __sparc__
#define __NR_seccomp 346
#elif defined __ia64__
#define __NR_seccomp 329
#elif defined _MIPS_SIM
#if _MIPS_SIM == _MIPS_SIM_ABI32
/* o32 */
#define __NR_seccomp 4352
#endif
#if _MIPS_SIM == _MIPS_SIM_NABI32
/* n32 */
#define __NR_seccomp 6316
#endif
#if _MIPS_SIM == _MIPS_SIM_ABI64
/* n64 */
#define __NR_seccomp 5312
#endif
#else
#define -1
#warning "__NR_seccomp not defined for your architecture"
#endif
#endif
#ifndef __NR_gettid
#if defined __i386__
#define __NR_gettid 224
#elif defined __x86_64__
#define __NR_gettid 186
#elif defined __arm__
#define __NR_gettid 224
#elif defined __aarch64__
#define __NR_gettid 224
#elif defined __s390__
#define __NR_gettid 236
#elif defined __powerpc__
#define __NR_gettid 207
#elif defined __sparc__
#define __NR_gettid 143
#elif defined __ia64__
#define __NR_gettid 81
#elif defined _MIPS_SIM
#if _MIPS_SIM == _MIPS_SIM_ABI32
/* o32 */
#define __NR_gettid 4222
#endif
#if _MIPS_SIM == _MIPS_SIM_NABI32
/* n32 */
#define __NR_gettid 6178
#endif
#if _MIPS_SIM == _MIPS_SIM_ABI64
/* n64 */
#define __NR_gettid 5178
#endif
#else
#define -1
#warning "__NR_gettid not defined for your architecture"
#endif
#endif
#ifndef __NR_execveat
#if defined __i386__
#define __NR_execveat 358
#elif defined __x86_64__
#ifdef __ILP32__
/* x32 */
#define __NR_execveat 545
#else
#define __NR_execveat 322
#endif
#elif defined __arm__
#define __NR_execveat 387
#elif defined __aarch64__
#define __NR_execveat 387
#elif defined __s390__
#define __NR_execveat 354
#elif defined __powerpc__
#define __NR_execveat 362
#elif defined __sparc__
#define __NR_execveat 350
#elif defined __ia64__
#define __NR_execveat 318
#elif defined _MIPS_SIM
#if _MIPS_SIM == _MIPS_SIM_ABI32
/* o32 */
#define __NR_execveat 4356
#endif
#if _MIPS_SIM == _MIPS_SIM_NABI32
/* n32 */
#define __NR_execveat 6320
#endif
#if _MIPS_SIM == _MIPS_SIM_ABI64
/* n64 */
#define __NR_execveat 5316
#endif
#else
#define -1
#warning "__NR_execveat not defined for your architecture"
#endif
#endif
#endif
/* __LXC_SYSCALL_NUMBERS_H */
src/lxc/syscall_wrappers.h
View file @
ed754cd2
...
...
@@ -16,6 +16,7 @@
#include <unistd.h>
#include "config.h"
#include "syscall_numbers.h"
#ifdef HAVE_LINUX_MEMFD_H
#include <linux/memfd.h>
...
...
@@ -31,12 +32,7 @@ typedef int32_t key_serial_t;
static
inline
long
__keyctl
(
int
cmd
,
unsigned
long
arg2
,
unsigned
long
arg3
,
unsigned
long
arg4
,
unsigned
long
arg5
)
{
#ifdef __NR_keyctl
return
syscall
(
__NR_keyctl
,
cmd
,
arg2
,
arg3
,
arg4
,
arg5
);
#else
errno
=
ENOSYS
;
return
-
1
;
#endif
}
#define keyctl __keyctl
#endif
...
...
@@ -56,90 +52,29 @@ static inline long __keyctl(int cmd, unsigned long arg2, unsigned long arg3,
#endif
#ifndef HAVE_MEMFD_CREATE
static
inline
int
memfd_create_lxc
(
const
char
*
name
,
unsigned
int
flags
)
{
#ifndef __NR_memfd_create
#if defined __i386__
#define __NR_memfd_create 356
#elif defined __x86_64__
#define __NR_memfd_create 319
#elif defined __arm__
#define __NR_memfd_create 385
#elif defined __aarch64__
#define __NR_memfd_create 279
#elif defined __s390__
#define __NR_memfd_create 350
#elif defined __powerpc__
#define __NR_memfd_create 360
#elif defined __sparc__
#define __NR_memfd_create 348
#elif defined __blackfin__
#define __NR_memfd_create 390
#elif defined __ia64__
#define __NR_memfd_create 1340
#elif defined _MIPS_SIM
#if _MIPS_SIM == _MIPS_SIM_ABI32
#define __NR_memfd_create 4354
#endif
#if _MIPS_SIM == _MIPS_SIM_NABI32
#define __NR_memfd_create 6318
#endif
#if _MIPS_SIM == _MIPS_SIM_ABI64
#define __NR_memfd_create 5314
#endif
#endif
#endif
#ifdef __NR_memfd_create
static
inline
int
memfd_create_lxc
(
const
char
*
name
,
unsigned
int
flags
)
{
return
syscall
(
__NR_memfd_create
,
name
,
flags
);
#else
errno
=
ENOSYS
;
return
-
1
;
#endif
}
#define memfd_create memfd_create_lxc
#else
extern
int
memfd_create
(
const
char
*
name
,
unsigned
int
flags
);
#endif
#if
!
HAVE_PIVOT_ROOT
#if
ndef
HAVE_PIVOT_ROOT
static
int
pivot_root
(
const
char
*
new_root
,
const
char
*
put_old
)
{
#ifdef __NR_pivot_root
return
syscall
(
__NR_pivot_root
,
new_root
,
put_old
);
#else
errno
=
ENOSYS
;
return
-
1
;
#endif
}
#else
extern
int
pivot_root
(
const
char
*
new_root
,
const
char
*
put_old
);
#endif
#if !defined(__NR_setns) && !defined(__NR_set_ns)
#if defined(__x86_64__)
#define __NR_setns 308
#elif defined(__i386__)
#define __NR_setns 346
#elif defined(__arm__)
#define __NR_setns 375
#elif defined(__aarch64__)
#define __NR_setns 375
#elif defined(__powerpc__)
#define __NR_setns 350
#elif defined(__s390__)
#define __NR_setns 339
#endif
#endif
/* Define sethostname() if missing from the C library */
#ifndef HAVE_SETHOSTNAME
static
inline
int
sethostname
(
const
char
*
name
,
size_t
len
)
{
#ifdef __NR_sethostname
return
syscall
(
__NR_sethostname
,
name
,
len
);
#else
errno
=
ENOSYS
;
return
-
1
;
#endif
}
#endif
...
...
@@ -147,14 +82,7 @@ static inline int sethostname(const char *name, size_t len)
#ifndef HAVE_SETNS
static
inline
int
setns
(
int
fd
,
int
nstype
)
{
#ifdef __NR_setns
return
syscall
(
__NR_setns
,
fd
,
nstype
);
#elif defined(__NR_set_ns)
return
syscall
(
__NR_set_ns
,
fd
,
nstype
);
#else
errno
=
ENOSYS
;
return
-
1
;
#endif
}
#endif
...
...
@@ -179,48 +107,6 @@ struct signalfd_siginfo {
uint8_t
__pad
[
48
];
};
#ifndef __NR_signalfd4
/* assume kernel headers are too old */
#if __i386__
#define __NR_signalfd4 327
#elif __x86_64__
#define __NR_signalfd4 289
#elif __powerpc__
#define __NR_signalfd4 313
#elif __s390x__
#define __NR_signalfd4 322
#elif __arm__
#define __NR_signalfd4 355
#elif __mips__ && _MIPS_SIM == _ABIO32
#define __NR_signalfd4 4324
#elif __mips__ && _MIPS_SIM == _ABI64
#define __NR_signalfd4 5283
#elif __mips__ && _MIPS_SIM == _ABIN32
#define __NR_signalfd4 6287
#endif
#endif
#ifndef __NR_signalfd
/* assume kernel headers are too old */
#if __i386__
#define __NR_signalfd 321
#elif __x86_64__
#define __NR_signalfd 282
#elif __powerpc__
#define __NR_signalfd 305
#elif __s390x__
#define __NR_signalfd 316
#elif __arm__
#define __NR_signalfd 349
#elif __mips__ && _MIPS_SIM == _ABIO32
#define __NR_signalfd 4317
#elif __mips__ && _MIPS_SIM == _ABI64
#define __NR_signalfd 5276
#elif __mips__ && _MIPS_SIM == _ABIN32
#define __NR_signalfd 6280
#endif
#endif
static
inline
int
signalfd
(
int
fd
,
const
sigset_t
*
mask
,
int
flags
)
{
int
retval
;
...
...
@@ -237,15 +123,18 @@ static inline int signalfd(int fd, const sigset_t *mask, int flags)
#ifndef HAVE_UNSHARE
static
inline
int
unshare
(
int
flags
)
{
#ifdef __NR_unshare
return
syscall
(
__NR_unshare
,
flags
);
#else
errno
=
ENOSYS
;
return
-
1
;
#endif
}
#else
extern
int
unshare
(
int
);
#endif
/* Define faccessat() if missing from the C library */
#ifndef HAVE_FACCESSAT
static
int
faccessat
(
int
__fd
,
const
char
*
__file
,
int
__type
,
int
__flag
)
{
return
syscall
(
__NR_faccessat
,
__fd
,
__file
,
__type
,
__flag
);
}
#endif
#endif
/* __LXC_SYSCALL_WRAPPER_H */
src/lxc/tools/lxc_unshare.c
View file @
ed754cd2
...
...
@@ -41,7 +41,6 @@ struct start_arg {
};
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
);
static
inline
int
sethostname_including_android
(
const
char
*
name
,
size_t
len
);
static
int
get_namespace_flags
(
char
*
namespaces
);
static
bool
lookup_user
(
const
char
*
oparg
,
uid_t
*
uid
);
static
int
mount_fs
(
const
char
*
source
,
const
char
*
target
,
const
char
*
type
);
...
...
@@ -129,23 +128,6 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)
return
0
;
}
/* Define sethostname() if missing from the C library also workaround some
* quirky with having this defined in multiple places.
*/
static
inline
int
sethostname_including_android
(
const
char
*
name
,
size_t
len
)
{
#ifndef HAVE_SETHOSTNAME
#ifdef __NR_sethostname
return
syscall
(
__NR_sethostname
,
name
,
len
);
#else
errno
=
ENOSYS
;
return
-
1
;
#endif
#else
return
sethostname
(
name
,
len
);
#endif
}
static
int
get_namespace_flags
(
char
*
namespaces
)
{
int
flags
=
0
;
...
...
@@ -266,7 +248,7 @@ static int do_start(void *arg)
lxc_setup_fs
();
if
((
start_arg
->
flags
&
CLONE_NEWUTS
)
&&
want_hostname
)
if
(
sethostname
_including_android
(
want_hostname
,
strlen
(
want_hostname
))
<
0
)
{
if
(
sethostname
(
want_hostname
,
strlen
(
want_hostname
))
<
0
)
{
SYSERROR
(
"Failed to set hostname %s"
,
want_hostname
);
_exit
(
EXIT_FAILURE
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment