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
22ed6f7c
Commit
22ed6f7c
authored
Aug 06, 2015
by
Nicolas Cornu
Committed by
Stéphane Graber
Aug 27, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factorize handle of create=dir and create=file
Signed-off-by:
Nicolas Cornu
<
ncornu@aldebaran.com
>
parent
44793db2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
59 deletions
+24
-59
conf.c
src/lxc/conf.c
+24
-59
No files found.
src/lxc/conf.c
View file @
22ed6f7c
...
@@ -1804,36 +1804,46 @@ static void cull_mntent_opt(struct mntent *mntent)
...
@@ -1804,36 +1804,46 @@ static void cull_mntent_opt(struct mntent *mntent)
}
}
}
}
static
inline
int
mount_entry_on_systemfs
(
struct
mntent
*
mntent
)
static
int
mount_entry_create_dir_file
(
const
struct
mntent
*
mntent
,
const
char
*
path
)
{
{
unsigned
long
mntflags
;
char
*
pathdirname
=
NULL
;
char
*
mntdata
;
int
ret
;
int
ret
;
FILE
*
pathfile
=
NULL
;
FILE
*
pathfile
=
NULL
;
char
*
pathdirname
=
NULL
;
bool
optional
=
hasmntopt
(
mntent
,
"optional"
)
!=
NULL
;
if
(
hasmntopt
(
mntent
,
"create=dir"
))
{
if
(
hasmntopt
(
mntent
,
"create=dir"
))
{
if
(
mkdir_p
(
mntent
->
mnt_dir
,
0755
)
<
0
)
{
if
(
mkdir_p
(
path
,
0755
)
<
0
)
{
WARN
(
"Failed to create mount target '%s'"
,
mntent
->
mnt_dir
);
WARN
(
"Failed to create mount target '%s'"
,
path
);
ret
=
-
1
;
ret
=
-
1
;
}
}
}
}
if
(
hasmntopt
(
mntent
,
"create=file"
)
&&
access
(
mntent
->
mnt_dir
,
F_OK
))
{
if
(
hasmntopt
(
mntent
,
"create=file"
)
&&
access
(
path
,
F_OK
))
{
pathdirname
=
strdup
(
mntent
->
mnt_dir
);
pathdirname
=
strdup
(
path
);
pathdirname
=
dirname
(
pathdirname
);
pathdirname
=
dirname
(
pathdirname
);
if
(
mkdir_p
(
pathdirname
,
0755
)
<
0
)
{
if
(
mkdir_p
(
pathdirname
,
0755
)
<
0
)
{
WARN
(
"Failed to create target directory"
);
WARN
(
"Failed to create target directory"
);
}
}
pathfile
=
fopen
(
mntent
->
mnt_dir
,
"wb"
);
pathfile
=
fopen
(
path
,
"wb"
);
if
(
!
pathfile
)
{
if
(
!
pathfile
)
{
WARN
(
"Failed to create mount target '%s'"
,
mntent
->
mnt_dir
);
WARN
(
"Failed to create mount target '%s'"
,
path
);
ret
=
-
1
;
ret
=
-
1
;
}
}
else
else
fclose
(
pathfile
);
fclose
(
pathfile
);
}
}
free
(
pathdirname
);
return
ret
;
}
static
inline
int
mount_entry_on_systemfs
(
struct
mntent
*
mntent
)
{
unsigned
long
mntflags
;
char
*
mntdata
;
int
ret
;
bool
optional
=
hasmntopt
(
mntent
,
"optional"
)
!=
NULL
;
ret
=
mount_entry_create_dir_file
(
mntent
,
mntent
->
mnt_dir
);
cull_mntent_opt
(
mntent
);
cull_mntent_opt
(
mntent
);
...
@@ -1845,7 +1855,6 @@ static inline int mount_entry_on_systemfs(struct mntent *mntent)
...
@@ -1845,7 +1855,6 @@ static inline int mount_entry_on_systemfs(struct mntent *mntent)
ret
=
mount_entry
(
mntent
->
mnt_fsname
,
mntent
->
mnt_dir
,
ret
=
mount_entry
(
mntent
->
mnt_fsname
,
mntent
->
mnt_dir
,
mntent
->
mnt_type
,
mntflags
,
mntdata
,
optional
);
mntent
->
mnt_type
,
mntflags
,
mntdata
,
optional
);
free
(
pathdirname
);
free
(
mntdata
);
free
(
mntdata
);
return
ret
;
return
ret
;
...
@@ -1861,8 +1870,6 @@ static int mount_entry_on_absolute_rootfs(struct mntent *mntent,
...
@@ -1861,8 +1870,6 @@ static int mount_entry_on_absolute_rootfs(struct mntent *mntent,
char
*
mntdata
;
char
*
mntdata
;
int
r
,
ret
=
0
,
offset
;
int
r
,
ret
=
0
,
offset
;
const
char
*
lxcpath
;
const
char
*
lxcpath
;
FILE
*
pathfile
=
NULL
;
char
*
pathdirname
=
NULL
;
bool
optional
=
hasmntopt
(
mntent
,
"optional"
)
!=
NULL
;
bool
optional
=
hasmntopt
(
mntent
,
"optional"
)
!=
NULL
;
lxcpath
=
lxc_global_config_value
(
"lxc.lxcpath"
);
lxcpath
=
lxc_global_config_value
(
"lxc.lxcpath"
);
...
@@ -1901,27 +1908,8 @@ skipabs:
...
@@ -1901,27 +1908,8 @@ skipabs:
goto
out
;
goto
out
;
}
}
if
(
hasmntopt
(
mntent
,
"create=dir"
))
{
ret
=
mount_entry_create_dir_file
(
mntent
,
path
);
if
(
mkdir_p
(
path
,
0755
)
<
0
)
{
WARN
(
"Failed to create mount target '%s'"
,
path
);
ret
=
-
1
;
}
}
if
(
hasmntopt
(
mntent
,
"create=file"
)
&&
access
(
path
,
F_OK
))
{
pathdirname
=
strdup
(
path
);
pathdirname
=
dirname
(
pathdirname
);
if
(
mkdir_p
(
pathdirname
,
0755
)
<
0
)
{
WARN
(
"Failed to create target directory"
);
}
pathfile
=
fopen
(
path
,
"wb"
);
if
(
!
pathfile
)
{
WARN
(
"Failed to create mount target '%s'"
,
path
);
ret
=
-
1
;
}
else
fclose
(
pathfile
);
}
cull_mntent_opt
(
mntent
);
cull_mntent_opt
(
mntent
);
if
(
parse_mntopts
(
mntent
->
mnt_opts
,
&
mntflags
,
&
mntdata
)
<
0
)
{
if
(
parse_mntopts
(
mntent
->
mnt_opts
,
&
mntflags
,
&
mntdata
)
<
0
)
{
...
@@ -1935,7 +1923,6 @@ skipabs:
...
@@ -1935,7 +1923,6 @@ skipabs:
free
(
mntdata
);
free
(
mntdata
);
out:
out:
free
(
pathdirname
);
return
ret
;
return
ret
;
}
}
...
@@ -1946,8 +1933,6 @@ static int mount_entry_on_relative_rootfs(struct mntent *mntent,
...
@@ -1946,8 +1933,6 @@ static int mount_entry_on_relative_rootfs(struct mntent *mntent,
unsigned
long
mntflags
;
unsigned
long
mntflags
;
char
*
mntdata
;
char
*
mntdata
;
int
ret
;
int
ret
;
FILE
*
pathfile
=
NULL
;
char
*
pathdirname
=
NULL
;
bool
optional
=
hasmntopt
(
mntent
,
"optional"
)
!=
NULL
;
bool
optional
=
hasmntopt
(
mntent
,
"optional"
)
!=
NULL
;
/* relative to root mount point */
/* relative to root mount point */
...
@@ -1957,27 +1942,8 @@ static int mount_entry_on_relative_rootfs(struct mntent *mntent,
...
@@ -1957,27 +1942,8 @@ static int mount_entry_on_relative_rootfs(struct mntent *mntent,
return
-
1
;
return
-
1
;
}
}
if
(
hasmntopt
(
mntent
,
"create=dir"
))
{
ret
=
mount_entry_create_dir_file
(
mntent
,
path
);
if
(
mkdir_p
(
path
,
0755
)
<
0
)
{
WARN
(
"Failed to create mount target '%s'"
,
path
);
ret
=
-
1
;
}
}
if
(
hasmntopt
(
mntent
,
"create=file"
)
&&
access
(
path
,
F_OK
))
{
pathdirname
=
strdup
(
path
);
pathdirname
=
dirname
(
pathdirname
);
if
(
mkdir_p
(
pathdirname
,
0755
)
<
0
)
{
WARN
(
"Failed to create target directory"
);
}
pathfile
=
fopen
(
path
,
"wb"
);
if
(
!
pathfile
)
{
WARN
(
"Failed to create mount target '%s'"
,
path
);
ret
=
-
1
;
}
else
fclose
(
pathfile
);
}
cull_mntent_opt
(
mntent
);
cull_mntent_opt
(
mntent
);
if
(
parse_mntopts
(
mntent
->
mnt_opts
,
&
mntflags
,
&
mntdata
)
<
0
)
{
if
(
parse_mntopts
(
mntent
->
mnt_opts
,
&
mntflags
,
&
mntdata
)
<
0
)
{
...
@@ -1988,7 +1954,6 @@ static int mount_entry_on_relative_rootfs(struct mntent *mntent,
...
@@ -1988,7 +1954,6 @@ static int mount_entry_on_relative_rootfs(struct mntent *mntent,
ret
=
mount_entry
(
mntent
->
mnt_fsname
,
path
,
mntent
->
mnt_type
,
ret
=
mount_entry
(
mntent
->
mnt_fsname
,
path
,
mntent
->
mnt_type
,
mntflags
,
mntdata
,
optional
);
mntflags
,
mntdata
,
optional
);
free
(
pathdirname
);
free
(
mntdata
);
free
(
mntdata
);
return
ret
;
return
ret
;
...
@@ -4560,7 +4525,7 @@ struct lxc_list *sort_cgroup_settings(struct lxc_list* cgroup_settings)
...
@@ -4560,7 +4525,7 @@ struct lxc_list *sort_cgroup_settings(struct lxc_list* cgroup_settings)
/* Store the memsw_limit location */
/* Store the memsw_limit location */
memsw_limit
=
item
;
memsw_limit
=
item
;
}
else
if
(
strcmp
(
cg
->
subsystem
,
"memory.limit_in_bytes"
)
==
0
&&
memsw_limit
!=
NULL
)
{
}
else
if
(
strcmp
(
cg
->
subsystem
,
"memory.limit_in_bytes"
)
==
0
&&
memsw_limit
!=
NULL
)
{
/* lxc.cgroup.memory.memsw.limit_in_bytes is found before
/* lxc.cgroup.memory.memsw.limit_in_bytes is found before
* lxc.cgroup.memory.limit_in_bytes, swap these two items */
* lxc.cgroup.memory.limit_in_bytes, swap these two items */
item
->
elem
=
memsw_limit
->
elem
;
item
->
elem
=
memsw_limit
->
elem
;
memsw_limit
->
elem
=
it
->
elem
;
memsw_limit
->
elem
=
it
->
elem
;
...
...
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