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
16fca125
Unverified
Commit
16fca125
authored
Apr 25, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: move all mount options into struct lxc_mount_options
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
3b59ddb6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
29 deletions
+35
-29
conf.c
src/lxc/conf.c
+0
-1
conf.h
src/lxc/conf.h
+18
-3
confile.c
src/lxc/confile.c
+8
-9
dir.c
src/lxc/storage/dir.c
+9
-16
No files found.
src/lxc/conf.c
View file @
16fca125
...
...
@@ -4065,7 +4065,6 @@ void lxc_conf_free(struct lxc_conf *conf)
free
(
conf
->
rootfs
.
bdev_type
);
free
(
conf
->
rootfs
.
options
);
free
(
conf
->
rootfs
.
path
);
free
(
conf
->
rootfs
.
data
);
put_lxc_rootfs
(
&
conf
->
rootfs
,
true
);
free
(
conf
->
logfile
);
if
(
conf
->
logfd
!=
-
1
)
...
...
src/lxc/conf.h
View file @
16fca125
...
...
@@ -200,6 +200,9 @@ struct lxc_mount_options {
int
relative
:
1
;
char
userns_path
[
PATH_MAX
];
int
userns_fd
;
unsigned
long
mnt_flags
;
unsigned
long
prop_flags
;
char
*
data
;
};
/* Defines a structure to store the rootfs location, the
...
...
@@ -209,8 +212,6 @@ struct lxc_mount_options {
* @buf : static buffer to construct paths
* @bev_type : optional backing store type
* @options : mount options
* @mountflags : the portion of @options that are flags
* @data : the portion of @options that are not flags
* @managed : whether it is managed by LXC
* @dfd_mnt : fd for @mount
* @dfd_dev : fd for /dev of the container
...
...
@@ -230,7 +231,6 @@ struct lxc_rootfs {
char
*
bdev_type
;
char
*
options
;
unsigned
long
mountflags
;
char
*
data
;
bool
managed
;
struct
lxc_mount_options
mnt_opts
;
struct
lxc_storage
*
storage
;
...
...
@@ -585,6 +585,20 @@ static inline bool idmapped_rootfs_mnt(const struct lxc_rootfs *rootfs)
return
rootfs
->
mnt_opts
.
userns_fd
>=
0
;
}
static
inline
void
put_lxc_mount_options
(
struct
lxc_mount_options
*
mnt_opts
)
{
mnt_opts
->
create_dir
=
0
;
mnt_opts
->
create_file
=
0
;
mnt_opts
->
optional
=
0
;
mnt_opts
->
relative
=
0
;
mnt_opts
->
userns_path
[
0
]
=
'\0'
;
mnt_opts
->
mnt_flags
=
0
;
mnt_opts
->
prop_flags
=
0
;
close_prot_errno_disarm
(
mnt_opts
->
userns_fd
);
free_disarm
(
mnt_opts
->
data
);
}
static
inline
void
put_lxc_rootfs
(
struct
lxc_rootfs
*
rootfs
,
bool
unpin
)
{
if
(
rootfs
)
{
...
...
@@ -594,6 +608,7 @@ static inline void put_lxc_rootfs(struct lxc_rootfs *rootfs, bool unpin)
close_prot_errno_disarm
(
rootfs
->
mnt_opts
.
userns_fd
);
if
(
unpin
)
close_prot_errno_disarm
(
rootfs
->
fd_path_pin
);
put_lxc_mount_options
(
&
rootfs
->
mnt_opts
);
storage_put
(
rootfs
->
storage
);
rootfs
->
storage
=
NULL
;
}
...
...
src/lxc/confile.c
View file @
16fca125
...
...
@@ -2581,8 +2581,8 @@ static int set_config_rootfs_options(const char *key, const char *value,
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
{
__do_free
char
*
dup
=
NULL
,
*
mdata
=
NULL
,
*
opts
=
NULL
;
unsigned
long
mflags
=
0
,
pflags
=
0
;
struct
lxc_rootfs
*
rootfs
=
&
lxc_conf
->
rootfs
;
struct
lxc_mount_options
*
mnt_opts
=
&
rootfs
->
mnt_opts
;
int
ret
;
clr_config_rootfs_options
(
key
,
lxc_conf
,
data
);
...
...
@@ -2593,15 +2593,15 @@ static int set_config_rootfs_options(const char *key, const char *value,
if
(
!
dup
)
return
-
ENOMEM
;
ret
=
parse_lxc_mntopts
(
&
rootfs
->
mnt_opts
,
dup
);
ret
=
parse_lxc_mntopts
(
mnt_opts
,
dup
);
if
(
ret
<
0
)
return
ret
;
ret
=
parse_mntopts
(
dup
,
&
mflags
,
&
mdata
);
ret
=
parse_mntopts
(
dup
,
&
m
nt_opts
->
mnt_
flags
,
&
mdata
);
if
(
ret
<
0
)
return
ret_errno
(
EINVAL
);
ret
=
parse_propagationopts
(
dup
,
&
p
flags
);
ret
=
parse_propagationopts
(
dup
,
&
mnt_opts
->
prop_
flags
);
if
(
ret
<
0
)
return
ret_errno
(
EINVAL
);
...
...
@@ -2609,13 +2609,12 @@ static int set_config_rootfs_options(const char *key, const char *value,
if
(
ret
<
0
)
return
ret_errno
(
ENOMEM
);
if
(
rootfs
->
mnt_opts
.
create_dir
||
rootfs
->
mnt_opts
.
create_file
||
rootfs
->
mnt_opts
.
optional
||
rootfs
->
mnt_opts
.
relative
)
if
(
mnt_opts
->
create_dir
||
mnt_opts
->
create_file
||
mnt_opts
->
optional
||
mnt_opts
->
relative
)
return
syserror_set
(
-
EINVAL
,
"Invalid LXC specifc mount option for rootfs mount"
);
rootfs
->
mountflags
=
mflags
|
pflags
;
mnt_opts
->
data
=
move_ptr
(
mdata
)
;
rootfs
->
options
=
move_ptr
(
opts
);
rootfs
->
data
=
move_ptr
(
mdata
);
return
0
;
}
...
...
@@ -4569,7 +4568,7 @@ static inline int clr_config_rootfs_options(const char *key, struct lxc_conf *c,
void
*
data
)
{
free_disarm
(
c
->
rootfs
.
options
);
free_disarm
(
c
->
rootfs
.
data
);
put_lxc_mount_options
(
&
c
->
rootfs
.
mnt_opts
);
return
0
;
}
...
...
src/lxc/storage/dir.c
View file @
16fca125
...
...
@@ -127,8 +127,9 @@ bool dir_detect(const char *path)
int
dir_mount
(
struct
lxc_storage
*
bdev
)
{
struct
lxc_mount_options
*
mnt_opts
=
&
bdev
->
rootfs
->
mnt_opts
;
__do_free
char
*
mntdata
=
NULL
;
unsigned
long
mflags
=
0
,
mntflags
=
0
,
pflags
=
0
;
unsigned
long
mflags
=
0
;
int
ret
;
const
char
*
src
;
...
...
@@ -138,14 +139,6 @@ int dir_mount(struct lxc_storage *bdev)
if
(
!
bdev
->
src
||
!
bdev
->
dest
)
return
-
22
;
ret
=
parse_mntopts
(
bdev
->
mntopts
,
&
mntflags
,
&
mntdata
);
if
(
ret
<
0
)
return
log_error_errno
(
ret
,
errno
,
"Failed to parse mount options
\"
%s
\"
"
,
bdev
->
mntopts
);
ret
=
parse_propagationopts
(
bdev
->
mntopts
,
&
pflags
);
if
(
ret
<
0
)
return
log_error_errno
(
-
EINVAL
,
EINVAL
,
"Failed to parse mount propagation options
\"
%s
\"
"
,
bdev
->
mntopts
);
src
=
lxc_storage_get_path
(
bdev
->
src
,
bdev
->
type
);
if
(
can_use_bind_mounts
())
{
...
...
@@ -163,28 +156,28 @@ int dir_mount(struct lxc_storage *bdev)
PROTECT_LOOKUP_BENEATH
,
fd_target
,
""
,
PROTECT_OPATH_DIRECTORY
,
PROTECT_LOOKUP_BENEATH
,
0
,
bdev
->
rootfs
->
mnt_opts
.
userns_fd
,
true
);
mnt_opts
->
userns_fd
,
true
);
if
(
ret
<
0
)
return
syserror
(
"Failed to mount
\"
%s
\"
onto
\"
%s
\"
"
,
src
,
bdev
->
dest
);
}
else
{
ret
=
mount
(
src
,
bdev
->
dest
,
"bind"
,
MS_BIND
|
MS_REC
|
mnt
flags
|
p
flags
,
mntdata
);
ret
=
mount
(
src
,
bdev
->
dest
,
"bind"
,
MS_BIND
|
MS_REC
|
mnt
_opts
->
mnt_flags
|
mnt_opts
->
prop_
flags
,
mntdata
);
if
(
ret
<
0
)
return
log_error_errno
(
-
errno
,
errno
,
"Failed to mount
\"
%s
\"
on
\"
%s
\"
"
,
src
,
bdev
->
dest
);
if
(
ret
==
0
&&
(
mntflags
&
MS_RDONLY
))
{
mflags
=
add_required_remount_flags
(
src
,
bdev
->
dest
,
MS_BIND
|
MS_REC
|
mnt
flags
|
p
flags
|
MS_REMOUNT
);
if
(
ret
==
0
&&
(
mnt
_opts
->
mnt_
flags
&
MS_RDONLY
))
{
mflags
=
add_required_remount_flags
(
src
,
bdev
->
dest
,
MS_BIND
|
MS_REC
|
mnt
_opts
->
mnt_flags
|
mnt_opts
->
mnt_
flags
|
MS_REMOUNT
);
ret
=
mount
(
src
,
bdev
->
dest
,
"bind"
,
mflags
,
mntdata
);
if
(
ret
<
0
)
return
log_error_errno
(
-
errno
,
errno
,
"Failed to remount
\"
%s
\"
on
\"
%s
\"
read-only with options
\"
%s
\"
, mount flags
\"
%lu
\"
, and propagation flags
\"
%lu
\"
"
,
src
?
src
:
"(none)"
,
bdev
->
dest
?
bdev
->
dest
:
"(none)"
,
mntdata
,
mflags
,
p
flags
);
src
?
src
:
"(none)"
,
bdev
->
dest
?
bdev
->
dest
:
"(none)"
,
mntdata
,
mflags
,
mnt_opts
->
mnt_
flags
);
else
DEBUG
(
"Remounted
\"
%s
\"
on
\"
%s
\"
read-only with options
\"
%s
\"
, mount flags
\"
%lu
\"
, and propagation flags
\"
%lu
\"
"
,
src
?
src
:
"(none)"
,
bdev
->
dest
?
bdev
->
dest
:
"(none)"
,
mntdata
,
mflags
,
p
flags
);
src
?
src
:
"(none)"
,
bdev
->
dest
?
bdev
->
dest
:
"(none)"
,
mntdata
,
mflags
,
mnt_opts
->
mnt_
flags
);
}
TRACE
(
"Mounted
\"
%s
\"
on
\"
%s
\"
with options
\"
%s
\"
, mount flags
\"
%lu
\"
, and propagation flags
\"
%lu
\"
"
,
src
?
src
:
"(none)"
,
bdev
->
dest
?
bdev
->
dest
:
"(none)"
,
mntdata
,
mflags
,
p
flags
);
src
?
src
:
"(none)"
,
bdev
->
dest
?
bdev
->
dest
:
"(none)"
,
mntdata
,
mflags
,
mnt_opts
->
mnt_
flags
);
}
TRACE
(
"Mounted
\"
%s
\"
onto
\"
%s
\"
"
,
src
,
bdev
->
dest
);
...
...
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