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
5d4dfde9
Unverified
Commit
5d4dfde9
authored
Oct 18, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: move memfd_create() definition
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
3feb8712
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
57 deletions
+57
-57
conf.c
src/lxc/conf.c
+0
-57
utils.h
src/lxc/utils.h
+57
-0
No files found.
src/lxc/conf.c
View file @
5d4dfde9
...
@@ -68,10 +68,6 @@
...
@@ -68,10 +68,6 @@
#include <../include/openpty.h>
#include <../include/openpty.h>
#endif
#endif
#ifdef HAVE_LINUX_MEMFD_H
#include <linux/memfd.h>
#endif
#include "af_unix.h"
#include "af_unix.h"
#include "caps.h"
/* for lxc_caps_last_cap() */
#include "caps.h"
/* for lxc_caps_last_cap() */
#include "cgroup.h"
#include "cgroup.h"
...
@@ -178,59 +174,6 @@ static int sethostname(const char * name, size_t len)
...
@@ -178,59 +174,6 @@ static int sethostname(const char * name, size_t len)
#define MS_LAZYTIME (1<<25)
#define MS_LAZYTIME (1<<25)
#endif
#endif
/* memfd_create() */
#ifndef MFD_CLOEXEC
#define MFD_CLOEXEC 0x0001U
#endif
#ifndef MFD_ALLOW_SEALING
#define MFD_ALLOW_SEALING 0x0002U
#endif
#ifndef HAVE_MEMFD_CREATE
static
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
char
*
lxchook_names
[
NUM_LXC_HOOKS
]
=
{
"pre-start"
,
"pre-mount"
,
"mount"
,
char
*
lxchook_names
[
NUM_LXC_HOOKS
]
=
{
"pre-start"
,
"pre-mount"
,
"mount"
,
"autodev"
,
"start"
,
"stop"
,
"autodev"
,
"start"
,
"stop"
,
"post-stop"
,
"clone"
,
"destroy"
};
"post-stop"
,
"clone"
,
"destroy"
};
...
...
src/lxc/utils.h
View file @
5d4dfde9
...
@@ -39,6 +39,10 @@
...
@@ -39,6 +39,10 @@
#include <sys/types.h>
#include <sys/types.h>
#include <sys/vfs.h>
#include <sys/vfs.h>
#ifdef HAVE_LINUX_MEMFD_H
#include <linux/memfd.h>
#endif
#include "initutils.h"
#include "initutils.h"
/* Define __S_ISTYPE if missing from the C library. */
/* Define __S_ISTYPE if missing from the C library. */
...
@@ -184,6 +188,59 @@ static inline int signalfd(int fd, const sigset_t *mask, int flags)
...
@@ -184,6 +188,59 @@ static inline int signalfd(int fd, const sigset_t *mask, int flags)
#define LOOP_CTL_GET_FREE 0x4C82
#define LOOP_CTL_GET_FREE 0x4C82
#endif
#endif
/* memfd_create() */
#ifndef MFD_CLOEXEC
#define MFD_CLOEXEC 0x0001U
#endif
#ifndef MFD_ALLOW_SEALING
#define MFD_ALLOW_SEALING 0x0002U
#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
/* Struct to carry child pid from lxc_popen() to lxc_pclose().
/* Struct to carry child pid from lxc_popen() to lxc_pclose().
* Not an opaque struct to allow direct access to the underlying FILE *
* Not an opaque struct to allow direct access to the underlying FILE *
* (i.e., struct lxc_popen_FILE *file; fgets(buf, sizeof(buf), file->f))
* (i.e., struct lxc_popen_FILE *file; fgets(buf, sizeof(buf), file->f))
...
...
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