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
0b7a8353
Commit
0b7a8353
authored
May 10, 2010
by
Daniel LEzcano
Committed by
Daniel Lezcano
May 10, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
factor out pivot_root code
Clean up and factor a bit the pivot_root code. Signed-off-by:
Daniel Lezcano
<
dlezcano@fr.ibm.com
>
parent
1b09f2c0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
27 deletions
+11
-27
conf.c
src/lxc/conf.c
+11
-27
No files found.
src/lxc/conf.c
View file @
0b7a8353
...
@@ -457,14 +457,12 @@ static int setup_rootfs_pivot_root_cb(char *buffer, void *data)
...
@@ -457,14 +457,12 @@ static int setup_rootfs_pivot_root_cb(char *buffer, void *data)
return
0
;
return
0
;
}
}
static
int
setup_rootfs_pivot_root
(
const
char
*
rootfs
,
const
char
*
pivotdir
)
static
int
setup_rootfs_pivot_root
(
const
char
*
rootfs
,
const
char
*
pivotdir
)
{
{
char
path
[
MAXPATHLEN
];
char
path
[
MAXPATHLEN
];
void
*
cbparm
[
2
];
void
*
cbparm
[
2
];
struct
lxc_list
mountlist
,
*
iterator
;
struct
lxc_list
mountlist
,
*
iterator
;
int
ok
,
still_mounted
,
last_still_mounted
;
int
ok
,
still_mounted
,
last_still_mounted
;
int
pivotdir_is_temp
=
0
;
/* change into new root fs */
/* change into new root fs */
if
(
chdir
(
rootfs
))
{
if
(
chdir
(
rootfs
))
{
...
@@ -472,34 +470,20 @@ static int setup_rootfs_pivot_root(const char *rootfs, const char *pivotdir)
...
@@ -472,34 +470,20 @@ static int setup_rootfs_pivot_root(const char *rootfs, const char *pivotdir)
return
-
1
;
return
-
1
;
}
}
/* create temporary mountpoint if none specified */
if
(
!
pivotdir
)
if
(
!
pivotdir
)
{
pivotdir
=
"oldrootfs"
;
snprintf
(
path
,
sizeof
(
path
),
"./lxc-oldrootfs-XXXXXX"
);
/* create a default mountpoint if none specified */
if
(
!
mkdtemp
(
path
))
{
snprintf
(
path
,
sizeof
(
path
),
"%s/%s"
,
rootfs
,
pivotdir
);
SYSERROR
(
"can't make temporary mountpoint"
);
return
-
1
;
}
pivotdir
=
strdup
(
&
path
[
1
]);
/* get rid of leading dot */
if
(
access
(
path
,
F_OK
))
{
if
(
!
pivotdir
)
{
SYSERROR
(
"strdup failed"
);
if
(
mkdir_p
(
path
,
0755
))
{
SYSERROR
(
"failed to create pivotdir '%s'"
,
path
);
return
-
1
;
return
-
1
;
}
}
pivotdir_is_temp
=
1
;
DEBUG
(
"created '%s' directory"
,
path
);
}
else
{
snprintf
(
path
,
sizeof
(
path
),
"%s/%s"
,
rootfs
,
pivotdir
);
if
(
access
(
path
,
F_OK
))
{
if
(
mkdir_p
(
path
,
0755
))
{
SYSERROR
(
"failed to create pivotdir '%s'"
,
path
);
return
-
1
;
}
DEBUG
(
"created '%s' directory"
,
path
);
}
}
}
DEBUG
(
"mountpoint for old rootfs is '%s'"
,
path
);
DEBUG
(
"mountpoint for old rootfs is '%s'"
,
path
);
...
@@ -588,8 +572,8 @@ static int setup_rootfs_pivot_root(const char *rootfs, const char *pivotdir)
...
@@ -588,8 +572,8 @@ static int setup_rootfs_pivot_root(const char *rootfs, const char *pivotdir)
/* remove temporary mount point, we don't consider the removing
/* remove temporary mount point, we don't consider the removing
* as fatal */
* as fatal */
if
(
pivotdir_is_temp
&&
rmdir
(
pivotdir
))
if
(
rmdir
(
pivotdir
))
WARN
(
"can't remove
temporary
mountpoint: %m"
);
WARN
(
"can't remove mountpoint: %m"
);
INFO
(
"pivoted to '%s'"
,
rootfs
);
INFO
(
"pivoted to '%s'"
,
rootfs
);
return
0
;
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