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
0b932f9d
Unverified
Commit
0b932f9d
authored
Mar 17, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: rework lxc specific mount option parsing
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
12cf9f5a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
17 deletions
+52
-17
conf.c
src/lxc/conf.c
+33
-17
conf.h
src/lxc/conf.h
+19
-0
No files found.
src/lxc/conf.c
View file @
0b932f9d
...
...
@@ -2090,33 +2090,48 @@ skipremount:
return
0
;
}
const
char
*
lxc_mount_options_info
[
LXC_MOUNT_MAX
]
=
{
"create=dir"
,
"create=file"
,
"optional"
,
"relative"
,
};
/* Remove "optional", "create=dir", and "create=file" from mntopt */
static
void
cull_mntent_opt
(
struct
mntent
*
mntent
)
void
parse_lxc_mntopts
(
struct
lxc_mount_options
*
opts
,
char
*
mnt_opts
)
{
int
i
;
char
*
list
[]
=
{
"create=dir"
,
"create=file"
,
"optional"
,
"relative"
,
NULL
};
for
(
i
=
0
;
list
[
i
];
i
++
)
{
for
(
size_t
i
=
LXC_MOUNT_CREATE_DIR
;
i
<
LXC_MOUNT_MAX
;
i
++
)
{
const
char
*
opt_name
=
lxc_mount_options_info
[
i
];
char
*
p
,
*
p2
;
p
=
strstr
(
mnt
ent
->
mnt_opts
,
list
[
i
]
);
p
=
strstr
(
mnt
_opts
,
opt_name
);
if
(
!
p
)
continue
;
p2
=
strchr
(
p
,
','
);
if
(
!
p2
)
{
/* no more mntopts, so just chop it here */
*
p
=
'\0'
;
switch
(
i
)
{
case
LXC_MOUNT_CREATE_DIR
:
opts
->
create_dir
=
1
;
break
;
case
LXC_MOUNT_CREATE_FILE
:
opts
->
create_file
=
1
;
break
;
case
LXC_MOUNT_OPTIONAL
:
opts
->
optional
=
1
;
break
;
case
LXC_MOUNT_RELATIVE
:
opts
->
relative
=
1
;
break
;
default:
WARN
(
"Unknown LXC specific mount option"
);
continue
;
}
memmove
(
p
,
p2
+
1
,
strlen
(
p2
+
1
)
+
1
);
p2
=
strchr
(
p
,
','
);
if
(
!
p2
)
*
p
=
'\0'
;
/* no more mntopts, so just chop it here */
else
memmove
(
p
,
p2
+
1
,
strlen
(
p2
+
1
)
+
1
);
}
}
...
...
@@ -2178,6 +2193,7 @@ static inline int mount_entry_on_generic(struct mntent *mntent,
char
*
rootfs_path
=
NULL
;
int
ret
;
bool
dev
,
optional
,
relative
;
struct
lxc_mount_options
opts
=
{};
optional
=
hasmntopt
(
mntent
,
"optional"
)
!=
NULL
;
dev
=
hasmntopt
(
mntent
,
"dev"
)
!=
NULL
;
...
...
@@ -2194,7 +2210,7 @@ static inline int mount_entry_on_generic(struct mntent *mntent,
return
-
1
;
}
cull_mntent_opt
(
mntent
);
parse_lxc_mntopts
(
&
opts
,
mntent
->
mnt_opts
);
ret
=
parse_propagationopts
(
mntent
->
mnt_opts
,
&
pflags
);
if
(
ret
<
0
)
...
...
src/lxc/conf.h
View file @
0b932f9d
...
...
@@ -181,6 +181,23 @@ struct lxc_tty_info {
struct
lxc_terminal_info
*
tty
;
};
typedef
enum
lxc_mount_options_t
{
LXC_MOUNT_CREATE_DIR
=
0
,
LXC_MOUNT_CREATE_FILE
=
1
,
LXC_MOUNT_OPTIONAL
=
2
,
LXC_MOUNT_RELATIVE
=
3
,
LXC_MOUNT_MAX
=
4
,
}
lxc_mount_options_t
;
__hidden
extern
const
char
*
lxc_mount_options_info
[
LXC_MOUNT_MAX
];
struct
lxc_mount_options
{
int
create_dir
:
1
;
int
create_file
:
1
;
int
optional
:
1
;
int
relative
:
1
;
};
/* Defines a structure to store the rootfs location, the
* optionals pivot_root, rootfs mount paths
* @path : the rootfs source (directory or device)
...
...
@@ -211,6 +228,7 @@ struct lxc_rootfs {
unsigned
long
mountflags
;
char
*
data
;
bool
managed
;
struct
lxc_mount_options
mnt_opts
;
};
/*
...
...
@@ -509,6 +527,7 @@ __hidden extern int userns_exec_full(struct lxc_conf *conf, int (*fn)(void *), v
const
char
*
fn_name
);
__hidden
extern
int
parse_mntopts
(
const
char
*
mntopts
,
unsigned
long
*
mntflags
,
char
**
mntdata
);
__hidden
extern
int
parse_propagationopts
(
const
char
*
mntopts
,
unsigned
long
*
pflags
);
__hidden
extern
void
parse_lxc_mntopts
(
struct
lxc_mount_options
*
opts
,
char
*
mnt_opts
);
__hidden
extern
void
tmp_proc_unmount
(
struct
lxc_conf
*
lxc_conf
);
__hidden
extern
void
suggest_default_idmap
(
void
);
__hidden
extern
FILE
*
make_anonymous_mount_file
(
struct
lxc_list
*
mount
,
bool
include_nesting_helpers
);
...
...
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