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
d9cda2c1
Unverified
Commit
d9cda2c1
authored
Aug 01, 2017
by
Christian Brauner
Committed by
Stéphane Graber
Aug 15, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: mount_entry_create_dir_file()
bugfixes Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
355bf77a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
26 deletions
+34
-26
conf.c
src/lxc/conf.c
+34
-26
No files found.
src/lxc/conf.c
View file @
d9cda2c1
...
@@ -1788,44 +1788,52 @@ static void cull_mntent_opt(struct mntent *mntent)
...
@@ -1788,44 +1788,52 @@ static void cull_mntent_opt(struct mntent *mntent)
}
}
static
int
mount_entry_create_dir_file
(
const
struct
mntent
*
mntent
,
static
int
mount_entry_create_dir_file
(
const
struct
mntent
*
mntent
,
const
char
*
path
,
const
struct
lxc_rootfs
*
rootfs
,
const
char
*
path
,
const
char
*
lxc_name
,
const
char
*
lxc_path
)
const
struct
lxc_rootfs
*
rootfs
,
const
char
*
lxc_name
,
const
char
*
lxc_path
)
{
{
char
*
pathdirname
=
NULL
;
int
ret
=
0
;
int
ret
=
0
;
FILE
*
pathfile
=
NULL
;
if
(
strncmp
(
mntent
->
mnt_type
,
"overlay"
,
7
)
==
0
)
{
if
(
!
strncmp
(
mntent
->
mnt_type
,
"overlay"
,
7
))
if
(
ovl_mkdir
(
mntent
,
rootfs
,
lxc_name
,
lxc_path
)
<
0
)
ret
=
ovl_mkdir
(
mntent
,
rootfs
,
lxc_name
,
lxc_path
);
return
-
1
;
else
if
(
!
strncmp
(
mntent
->
mnt_type
,
"aufs"
,
4
))
}
else
if
(
strncmp
(
mntent
->
mnt_type
,
"aufs"
,
4
)
==
0
)
{
ret
=
aufs_mkdir
(
mntent
,
rootfs
,
lxc_name
,
lxc_path
);
if
(
aufs_mkdir
(
mntent
,
rootfs
,
lxc_name
,
lxc_path
)
<
0
)
if
(
ret
<
0
)
return
-
1
;
return
-
1
;
}
if
(
hasmntopt
(
mntent
,
"create=dir"
))
{
if
(
hasmntopt
(
mntent
,
"create=dir"
))
{
if
(
mkdir_p
(
path
,
0755
)
<
0
)
{
ret
=
mkdir_p
(
path
,
0755
);
WARN
(
"Failed to create mount target '%s'"
,
path
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
ret
=
-
1
;
SYSERROR
(
"Failed to create directory
\"
%s
\"
"
,
path
);
return
-
1
;
}
}
}
}
if
(
hasmntopt
(
mntent
,
"create=file"
)
&&
access
(
path
,
F_OK
))
{
if
(
hasmntopt
(
mntent
,
"create=file"
)
&&
access
(
path
,
F_OK
))
{
pathdirname
=
strdup
(
path
);
int
fd
;
pathdirname
=
dirname
(
pathdirname
);
char
*
p1
,
*
p2
;
if
(
mkdir_p
(
pathdirname
,
0755
)
<
0
)
{
WARN
(
"Failed to create target directory"
);
p1
=
strdup
(
path
);
}
if
(
!
p1
)
pathfile
=
fopen
(
path
,
"wb"
);
return
-
1
;
if
(
!
pathfile
)
{
WARN
(
"Failed to create mount target '%s'"
,
path
);
p2
=
dirname
(
p1
);
ret
=
-
1
;
}
else
{
ret
=
mkdir_p
(
p2
,
0755
);
fclose
(
pathfile
);
free
(
p1
);
if
(
ret
<
0
&&
errno
!=
EEXIST
)
{
SYSERROR
(
"Failed to create directory
\"
%s
\"
"
,
path
);
return
-
1
;
}
}
fd
=
open
(
path
,
O_CREAT
,
0644
);
if
(
fd
<
0
)
return
-
1
;
close
(
fd
);
}
}
free
(
pathdirname
);
return
ret
;
return
0
;
}
}
/* rootfs, lxc_name, and lxc_path can be NULL when the container is created
/* rootfs, lxc_name, and lxc_path can be NULL when the container is created
...
...
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