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
96c7c2a9
Unverified
Commit
96c7c2a9
authored
Oct 03, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
syscall_wrappers: move memfd_create()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
2682a10f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
48 deletions
+49
-48
ringbuf.c
src/lxc/ringbuf.c
+1
-0
syscall_wrappers.h
src/lxc/syscall_wrappers.h
+48
-0
utils.h
src/lxc/utils.h
+0
-48
No files found.
src/lxc/ringbuf.c
View file @
96c7c2a9
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
#include "config.h"
#include "config.h"
#include "ringbuf.h"
#include "ringbuf.h"
#include "syscall_wrappers.h"
#include "utils.h"
#include "utils.h"
int
lxc_ringbuf_create
(
struct
lxc_ringbuf
*
buf
,
size_t
size
)
int
lxc_ringbuf_create
(
struct
lxc_ringbuf
*
buf
,
size_t
size
)
...
...
src/lxc/syscall_wrappers.h
View file @
96c7c2a9
...
@@ -32,6 +32,10 @@
...
@@ -32,6 +32,10 @@
#include "config.h"
#include "config.h"
#ifdef HAVE_LINUX_MEMFD_H
#include <linux/memfd.h>
#endif
typedef
int32_t
key_serial_t
;
typedef
int32_t
key_serial_t
;
#if !HAVE_KEYCTL
#if !HAVE_KEYCTL
...
@@ -48,6 +52,50 @@ static inline long __keyctl(int cmd, unsigned long arg2, unsigned long arg3,
...
@@ -48,6 +52,50 @@ static inline long __keyctl(int cmd, unsigned long arg2, unsigned long arg3,
#define keyctl __keyctl
#define keyctl __keyctl
#endif
#endif
#ifndef HAVE_MEMFD_CREATE
static
inline
int
memfd_create
(
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
return
syscall
(
__NR_memfd_create
,
name
,
flags
);
#else
errno
=
ENOSYS
;
return
-
1
;
#endif
}
#else
extern
int
memfd_create
(
const
char
*
name
,
unsigned
int
flags
);
#endif
#if !HAVE_PIVOT_ROOT
#if !HAVE_PIVOT_ROOT
static
int
pivot_root
(
const
char
*
new_root
,
const
char
*
put_old
)
static
int
pivot_root
(
const
char
*
new_root
,
const
char
*
put_old
)
{
{
...
...
src/lxc/utils.h
View file @
96c7c2a9
...
@@ -43,10 +43,6 @@
...
@@ -43,10 +43,6 @@
#include "raw_syscalls.h"
#include "raw_syscalls.h"
#include "string_utils.h"
#include "string_utils.h"
#ifdef HAVE_LINUX_MEMFD_H
#include <linux/memfd.h>
#endif
/* returns 1 on success, 0 if there were any failures */
/* returns 1 on success, 0 if there were any failures */
extern
int
lxc_rmdir_onedev
(
const
char
*
path
,
const
char
*
exclude
);
extern
int
lxc_rmdir_onedev
(
const
char
*
path
,
const
char
*
exclude
);
extern
int
get_u16
(
unsigned
short
*
val
,
const
char
*
arg
,
int
base
);
extern
int
get_u16
(
unsigned
short
*
val
,
const
char
*
arg
,
int
base
);
...
@@ -199,50 +195,6 @@ static inline int signalfd(int fd, const sigset_t *mask, int flags)
...
@@ -199,50 +195,6 @@ static inline int signalfd(int fd, const sigset_t *mask, int flags)
}
}
#endif
#endif
#ifndef HAVE_MEMFD_CREATE
static
inline
int
memfd_create
(
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
return
syscall
(
__NR_memfd_create
,
name
,
flags
);
#else
errno
=
ENOSYS
;
return
-
1
;
#endif
}
#else
extern
int
memfd_create
(
const
char
*
name
,
unsigned
int
flags
);
#endif
static
inline
int
lxc_set_cloexec
(
int
fd
)
static
inline
int
lxc_set_cloexec
(
int
fd
)
{
{
return
fcntl
(
fd
,
F_SETFD
,
FD_CLOEXEC
);
return
fcntl
(
fd
,
F_SETFD
,
FD_CLOEXEC
);
...
...
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