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
c69bd12f
Commit
c69bd12f
authored
Oct 09, 2009
by
Daniel Lezcano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use the configuration structure for setting up the rootfs
use the configuration structure for setting up the rootfs Signed-off-by:
Daniel Lezcano
<
dlezcano@fr.ibm.com
>
parent
ecb0e51b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
14 deletions
+30
-14
conf.c
src/lxc/conf.c
+30
-14
No files found.
src/lxc/conf.c
View file @
c69bd12f
...
...
@@ -842,25 +842,46 @@ static int setup_tty(const char *name, const struct lxc_tty_info *tty_info)
return
0
;
}
static
int
setup_rootfs
(
const
char
*
name
)
static
int
setup_rootfs
(
const
char
*
rootfs
)
{
char
path
[
MAXPATHLEN
];
char
*
tmpname
;
int
ret
=
-
1
;
snprintf
(
path
,
MAXPATHLEN
,
LXCPATH
"/%s/rootfs"
,
name
);
if
(
!
rootfs
)
return
0
;
if
(
chroot
(
path
))
{
SYSERROR
(
"failed to set chroot %s"
,
path
);
tmpname
=
tempnam
(
"/tmp"
,
"lxc-rootfs"
);
if
(
!
tmpname
)
{
SYSERROR
(
"failed to generate temporary name"
);
return
-
1
;
}
if
(
mkdir
(
tmpname
,
0700
))
{
SYSERROR
(
"failed to create temporary directory '%s'"
,
tmpname
);
return
-
1
;
}
if
(
mount
(
rootfs
,
tmpname
,
"none"
,
MS_BIND
|
MS_REC
,
NULL
))
{
SYSERROR
(
"failed to mount '%s'->'%s'"
,
rootfs
,
tmpname
);
goto
out
;
}
if
(
chroot
(
tmpname
))
{
SYSERROR
(
"failed to set chroot %s"
,
tmpname
);
goto
out
;
}
if
(
chdir
(
getenv
(
"HOME"
))
&&
chdir
(
"/"
))
{
SYSERROR
(
"failed to change to home directory"
);
return
-
1
;
goto
out
;
}
INFO
(
"chrooted to '%s'"
,
path
);
INFO
(
"chrooted to '%s'"
,
rootfs
);
return
0
;
ret
=
0
;
out:
rmdir
(
tmpname
);
return
ret
;
}
static
int
setup_pts
(
const
char
*
name
)
...
...
@@ -1434,11 +1455,6 @@ int lxc_configure(const char *name, struct lxc_conf *conf)
return
-
1
;
}
if
(
conf
->
rootfs
&&
configure_rootfs
(
name
,
conf
->
rootfs
))
{
ERROR
(
"failed to configure the rootfs"
);
return
-
1
;
}
if
(
conf
->
pts
&&
configure_pts
(
name
,
conf
->
pts
))
{
ERROR
(
"failed to configure a new pts instance"
);
return
-
1
;
...
...
@@ -1860,7 +1876,7 @@ int lxc_setup(const char *name, const char *cons,
return
-
1
;
}
if
(
lxc_conf
.
rootfs
&&
setup_rootfs
(
name
))
{
if
(
setup_rootfs
(
lxc_conf
.
rootfs
))
{
ERROR
(
"failed to set rootfs for '%s'"
,
name
);
return
-
1
;
}
...
...
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