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
75fca1ac
Unverified
Commit
75fca1ac
authored
Mar 09, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: cleanup automounting
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
95258e34
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
16 deletions
+11
-16
conf.c
src/lxc/conf.c
+11
-16
No files found.
src/lxc/conf.c
View file @
75fca1ac
...
@@ -647,7 +647,6 @@ static int lxc_mount_auto_mounts(struct lxc_handler *handler, int flags)
...
@@ -647,7 +647,6 @@ static int lxc_mount_auto_mounts(struct lxc_handler *handler, int flags)
has_cap_net_admin
=
lxc_wants_cap
(
CAP_NET_ADMIN
,
conf
);
has_cap_net_admin
=
lxc_wants_cap
(
CAP_NET_ADMIN
,
conf
);
for
(
i
=
0
;
default_mounts
[
i
].
match_mask
;
i
++
)
{
for
(
i
=
0
;
default_mounts
[
i
].
match_mask
;
i
++
)
{
__do_free
char
*
destination
=
NULL
,
*
source
=
NULL
;
__do_free
char
*
destination
=
NULL
,
*
source
=
NULL
;
int
saved_errno
;
unsigned
long
mflags
;
unsigned
long
mflags
;
if
((
flags
&
default_mounts
[
i
].
match_mask
)
!=
default_mounts
[
i
].
match_flag
)
if
((
flags
&
default_mounts
[
i
].
match_mask
)
!=
default_mounts
[
i
].
match_flag
)
continue
;
continue
;
...
@@ -656,11 +655,11 @@ static int lxc_mount_auto_mounts(struct lxc_handler *handler, int flags)
...
@@ -656,11 +655,11 @@ static int lxc_mount_auto_mounts(struct lxc_handler *handler, int flags)
/* will act like strdup if %r is not present */
/* will act like strdup if %r is not present */
source
=
lxc_string_replace
(
"%r"
,
rootfs
->
path
?
rootfs
->
mount
:
""
,
default_mounts
[
i
].
source
);
source
=
lxc_string_replace
(
"%r"
,
rootfs
->
path
?
rootfs
->
mount
:
""
,
default_mounts
[
i
].
source
);
if
(
!
source
)
if
(
!
source
)
return
-
1
;
return
syserror_set
(
-
ENOMEM
,
"Failed to create source path"
)
;
}
}
if
(
!
default_mounts
[
i
].
destination
)
if
(
!
default_mounts
[
i
].
destination
)
return
log_error
(
-
1
,
"BUG: auto mounts destination %d was NULL"
,
i
);
return
syserror_set
(
-
EINVAL
,
"BUG: auto mounts destination %d was NULL"
,
i
);
if
(
!
has_cap_net_admin
&&
default_mounts
[
i
].
requires_cap_net_admin
)
{
if
(
!
has_cap_net_admin
&&
default_mounts
[
i
].
requires_cap_net_admin
)
{
TRACE
(
"Container does not have CAP_NET_ADMIN. Skipping
\"
%s
\"
mount"
,
default_mounts
[
i
].
source
?:
"(null)"
);
TRACE
(
"Container does not have CAP_NET_ADMIN. Skipping
\"
%s
\"
mount"
,
default_mounts
[
i
].
source
?:
"(null)"
);
...
@@ -670,25 +669,21 @@ static int lxc_mount_auto_mounts(struct lxc_handler *handler, int flags)
...
@@ -670,25 +669,21 @@ static int lxc_mount_auto_mounts(struct lxc_handler *handler, int flags)
/* will act like strdup if %r is not present */
/* will act like strdup if %r is not present */
destination
=
lxc_string_replace
(
"%r"
,
rootfs
->
path
?
rootfs
->
mount
:
""
,
default_mounts
[
i
].
destination
);
destination
=
lxc_string_replace
(
"%r"
,
rootfs
->
path
?
rootfs
->
mount
:
""
,
default_mounts
[
i
].
destination
);
if
(
!
destination
)
if
(
!
destination
)
return
-
1
;
return
syserror_set
(
-
ENOMEM
,
"Failed to create target path"
)
;
mflags
=
add_required_remount_flags
(
source
,
destination
,
mflags
=
add_required_remount_flags
(
source
,
destination
,
default_mounts
[
i
].
flags
);
default_mounts
[
i
].
flags
);
ret
=
safe_mount
(
source
,
destination
,
default_mounts
[
i
].
fstype
,
ret
=
safe_mount
(
source
,
destination
,
default_mounts
[
i
].
fstype
,
mflags
,
default_mounts
[
i
].
options
,
mflags
,
default_mounts
[
i
].
options
,
rootfs
->
path
?
rootfs
->
mount
:
NULL
);
rootfs
->
path
?
rootfs
->
mount
:
NULL
);
saved_errno
=
errno
;
if
(
ret
<
0
&&
errno
==
ENOENT
)
{
INFO
(
"Mount source or target for
\"
%s
\"
on
\"
%s
\"
does not exist. Skipping"
,
source
,
destination
);
ret
=
0
;
}
else
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to mount
\"
%s
\"
on
\"
%s
\"
with flags %lu"
,
source
,
destination
,
mflags
);
}
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
errno
=
saved_errno
;
if
(
errno
!=
ENOENT
)
return
-
1
;
return
syserror
(
"Failed to mount
\"
%s
\"
on
\"
%s
\"
with flags %lu"
,
source
,
destination
,
mflags
);
INFO
(
"Mount source or target for
\"
%s
\"
on
\"
%s
\"
does not exist. Skipping"
,
source
,
destination
);
continue
;
}
}
TRACE
(
"Mounted automount
\"
%s
\"
on
\"
%s
\"
with flags %lu"
,
source
,
destination
,
mflags
);
}
}
if
(
flags
&
LXC_AUTO_CGROUP_MASK
)
{
if
(
flags
&
LXC_AUTO_CGROUP_MASK
)
{
...
...
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