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
20d81c40
Unverified
Commit
20d81c40
authored
Jul 22, 2020
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mount_utils: add mount_filesystem() helper
that translates between the two mount apis. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
827eb586
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
+32
-0
mount_utils.c
src/lxc/mount_utils.c
+30
-0
mount_utils.h
src/lxc/mount_utils.h
+2
-0
No files found.
src/lxc/mount_utils.c
View file @
20d81c40
...
@@ -3,16 +3,22 @@
...
@@ -3,16 +3,22 @@
#ifndef _GNU_SOURCE
#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#define _GNU_SOURCE 1
#endif
#endif
#include <fcntl.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <sys/mount.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "log.h"
#include "macro.h"
#include "macro.h"
#include "memory_utils.h"
#include "memory_utils.h"
#include "mount_utils.h"
#include "mount_utils.h"
#include "syscall_numbers.h"
#include "syscall_numbers.h"
#include "syscall_wrappers.h"
#include "syscall_wrappers.h"
lxc_log_define
(
mount_utils
,
lxc
);
int
mnt_attributes_new
(
unsigned
int
old_flags
,
unsigned
int
*
new_flags
)
int
mnt_attributes_new
(
unsigned
int
old_flags
,
unsigned
int
*
new_flags
)
{
{
unsigned
int
flags
=
0
;
unsigned
int
flags
=
0
;
...
@@ -108,3 +114,27 @@ int mnt_attributes_old(unsigned int new_flags, unsigned int *old_flags)
...
@@ -108,3 +114,27 @@ int mnt_attributes_old(unsigned int new_flags, unsigned int *old_flags)
*
old_flags
|=
flags
;
*
old_flags
|=
flags
;
return
new_flags
;
return
new_flags
;
}
}
int
mount_filesystem
(
const
char
*
fs_name
,
const
char
*
path
,
unsigned
int
attr_flags
)
{
__do_close
int
fsfd
=
-
EBADF
;
unsigned
int
old_flags
=
0
;
fsfd
=
fsopen
(
fs_name
,
FSOPEN_CLOEXEC
);
if
(
fsfd
>=
0
)
{
__do_close
int
mfd
=
-
EBADF
;
if
(
fsconfig
(
fsfd
,
FSCONFIG_CMD_CREATE
,
NULL
,
NULL
,
0
))
return
-
1
;
mfd
=
fsmount
(
fsfd
,
FSMOUNT_CLOEXEC
,
attr_flags
);
if
(
mfd
<
0
)
return
-
1
;
return
move_mount
(
mfd
,
""
,
AT_FDCWD
,
path
,
MOVE_MOUNT_F_EMPTY_PATH
);
}
TRACE
(
"Falling back to old mount api"
);
mnt_attributes_old
(
attr_flags
,
&
old_flags
);
return
mount
(
"none"
,
path
,
fs_name
,
old_flags
,
NULL
);
}
src/lxc/mount_utils.h
View file @
20d81c40
...
@@ -148,4 +148,6 @@ __hidden extern int mnt_attributes_new(unsigned int old_flags, unsigned int *new
...
@@ -148,4 +148,6 @@ __hidden extern int mnt_attributes_new(unsigned int old_flags, unsigned int *new
__hidden
extern
int
mnt_attributes_old
(
unsigned
int
new_flags
,
unsigned
int
*
old_flags
);
__hidden
extern
int
mnt_attributes_old
(
unsigned
int
new_flags
,
unsigned
int
*
old_flags
);
__hidden
extern
int
mount_filesystem
(
const
char
*
fs_name
,
const
char
*
path
,
unsigned
int
attr_flags
);
#endif
/* __LXC_MOUNT_UTILS_H */
#endif
/* __LXC_MOUNT_UTILS_H */
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