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
af25ca30
Unverified
Commit
af25ca30
authored
Apr 28, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage/dir: use "source" and "target" as terms
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
36902d07
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
15 deletions
+16
-15
dir.c
src/lxc/storage/dir.c
+16
-15
No files found.
src/lxc/storage/dir.c
View file @
af25ca30
...
...
@@ -131,7 +131,7 @@ int dir_mount(struct lxc_storage *bdev)
struct
lxc_mount_options
*
mnt_opts
=
&
rootfs
->
mnt_opts
;
unsigned
long
mflags
=
0
;
int
ret
;
const
char
*
s
rc
;
const
char
*
s
ource
,
*
target
;
if
(
!
strequal
(
bdev
->
type
,
"dir"
))
return
syserror_set
(
-
EINVAL
,
"Invalid storage driver"
);
...
...
@@ -145,23 +145,24 @@ int dir_mount(struct lxc_storage *bdev)
if
(
rootfs
->
dfd_idmapped
>=
0
&&
!
can_use_bind_mounts
())
return
syserror_set
(
-
EOPNOTSUPP
,
"Idmapped mount requested but kernel doesn't support new mount API"
);
src
=
lxc_storage_get_path
(
bdev
->
src
,
bdev
->
type
);
source
=
lxc_storage_get_path
(
bdev
->
src
,
bdev
->
type
);
target
=
bdev
->
dest
;
if
(
can_use_bind_mounts
())
{
__do_close
int
fd_source
=
-
EBADF
,
fd_target
=
-
EBADF
;
fd_target
=
open_at
(
-
EBADF
,
bdev
->
des
t
,
PROTECT_OPATH_DIRECTORY
,
0
,
0
);
fd_target
=
open_at
(
-
EBADF
,
targe
t
,
PROTECT_OPATH_DIRECTORY
,
0
,
0
);
if
(
fd_target
<
0
)
return
syserror
(
"Failed to open
\"
%s
\"
"
,
bdev
->
des
t
);
return
syserror
(
"Failed to open
\"
%s
\"
"
,
targe
t
);
if
(
rootfs
->
dfd_idmapped
>=
0
)
{
ret
=
move_detached_mount
(
rootfs
->
dfd_idmapped
,
fd_target
,
""
,
PROTECT_OPATH_DIRECTORY
,
PROTECT_LOOKUP_BENEATH
);
}
else
{
fd_source
=
open_at
(
-
EBADF
,
s
rc
,
PROTECT_OPATH_DIRECTORY
,
0
,
0
);
fd_source
=
open_at
(
-
EBADF
,
s
ource
,
PROTECT_OPATH_DIRECTORY
,
0
,
0
);
if
(
fd_source
<
0
)
return
syserror
(
"Failed to open
\"
%s
\"
"
,
s
rc
);
return
syserror
(
"Failed to open
\"
%s
\"
"
,
s
ource
);
ret
=
fd_bind_mount
(
fd_source
,
""
,
PROTECT_OPATH_DIRECTORY
,
...
...
@@ -170,29 +171,29 @@ int dir_mount(struct lxc_storage *bdev)
PROTECT_LOOKUP_BENEATH
,
0
,
true
);
}
if
(
ret
<
0
)
return
syserror
(
"Failed to mount
\"
%s
\"
onto
\"
%s
\"
"
,
s
rc
,
bdev
->
des
t
);
return
syserror
(
"Failed to mount
\"
%s
\"
onto
\"
%s
\"
"
,
s
ource
,
targe
t
);
}
else
{
ret
=
mount
(
s
rc
,
bdev
->
des
t
,
"bind"
,
MS_BIND
|
MS_REC
|
mnt_opts
->
mnt_flags
|
mnt_opts
->
prop_flags
,
mnt_opts
->
data
);
ret
=
mount
(
s
ource
,
targe
t
,
"bind"
,
MS_BIND
|
MS_REC
|
mnt_opts
->
mnt_flags
|
mnt_opts
->
prop_flags
,
mnt_opts
->
data
);
if
(
ret
<
0
)
return
log_error_errno
(
-
errno
,
errno
,
"Failed to mount
\"
%s
\"
on
\"
%s
\"
"
,
s
rc
,
bdev
->
des
t
);
return
log_error_errno
(
-
errno
,
errno
,
"Failed to mount
\"
%s
\"
on
\"
%s
\"
"
,
s
ource
,
targe
t
);
if
(
ret
==
0
&&
(
mnt_opts
->
mnt_flags
&
MS_RDONLY
))
{
mflags
=
add_required_remount_flags
(
s
rc
,
bdev
->
des
t
,
MS_BIND
|
MS_REC
|
mnt_opts
->
mnt_flags
|
mnt_opts
->
mnt_flags
|
MS_REMOUNT
);
mflags
=
add_required_remount_flags
(
s
ource
,
targe
t
,
MS_BIND
|
MS_REC
|
mnt_opts
->
mnt_flags
|
mnt_opts
->
mnt_flags
|
MS_REMOUNT
);
ret
=
mount
(
s
rc
,
bdev
->
des
t
,
"bind"
,
mflags
,
mnt_opts
->
data
);
ret
=
mount
(
s
ource
,
targe
t
,
"bind"
,
mflags
,
mnt_opts
->
data
);
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
\"
"
,
s
rc
?
src
:
"(none)"
,
bdev
->
des
t
,
mnt_opts
->
data
,
mflags
,
mnt_opts
->
mnt_flags
);
s
ource
?
source
:
"(none)"
,
targe
t
,
mnt_opts
->
data
,
mflags
,
mnt_opts
->
mnt_flags
);
else
DEBUG
(
"Remounted
\"
%s
\"
on
\"
%s
\"
read-only with options
\"
%s
\"
, mount flags
\"
%lu
\"
, and propagation flags
\"
%lu
\"
"
,
s
rc
?
src
:
"(none)"
,
bdev
->
des
t
,
mnt_opts
->
data
,
mflags
,
mnt_opts
->
mnt_flags
);
s
ource
?
source
:
"(none)"
,
targe
t
,
mnt_opts
->
data
,
mflags
,
mnt_opts
->
mnt_flags
);
}
TRACE
(
"Mounted
\"
%s
\"
on
\"
%s
\"
with options
\"
%s
\"
, mount flags
\"
%lu
\"
, and propagation flags
\"
%lu
\"
"
,
s
rc
?
src
:
"(none)"
,
bdev
->
des
t
,
mnt_opts
->
data
,
mflags
,
mnt_opts
->
mnt_flags
);
s
ource
?
source
:
"(none)"
,
targe
t
,
mnt_opts
->
data
,
mflags
,
mnt_opts
->
mnt_flags
);
}
TRACE
(
"Mounted
\"
%s
\"
onto
\"
%s
\"
"
,
s
rc
,
bdev
->
des
t
);
TRACE
(
"Mounted
\"
%s
\"
onto
\"
%s
\"
"
,
s
ource
,
targe
t
);
return
0
;
}
...
...
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