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
32a2ca49
Commit
32a2ca49
authored
Sep 06, 2016
by
Christian Brauner
Committed by
Stéphane Graber
Oct 26, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: make detect_ramfs_rootfs() return bool
Signed-off-by:
Christian Brauner
<
christian.brauner@canonical.com
>
parent
357e023b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
13 deletions
+17
-13
utils.c
src/lxc/utils.c
+16
-12
utils.h
src/lxc/utils.h
+1
-1
No files found.
src/lxc/utils.c
View file @
32a2ca49
...
...
@@ -1158,36 +1158,40 @@ bool switch_to_ns(pid_t pid, const char *ns) {
* IIUC, so long as we've chrooted so that rootfs is not our root,
* the rootfs entry should always be skipped in mountinfo contents.
*/
int
detect_ramfs_rootfs
(
void
)
bool
detect_ramfs_rootfs
(
void
)
{
char
buf
[
LINELEN
],
*
p
;
FILE
*
f
;
char
*
p
,
*
p2
;
char
*
line
=
NULL
;
size_t
len
=
0
;
int
i
;
char
*
p2
;
f
=
fopen
(
"/proc/self/mountinfo"
,
"r"
);
if
(
!
f
)
return
0
;
while
(
fgets
(
buf
,
LINELEN
,
f
))
{
for
(
p
=
buf
,
i
=
0
;
p
&&
i
<
4
;
i
++
)
p
=
strchr
(
p
+
1
,
' '
);
return
false
;
while
(
getline
(
&
line
,
&
len
,
f
)
!=
-
1
)
{
for
(
p
=
line
,
i
=
0
;
p
&&
i
<
4
;
i
++
)
p
=
strchr
(
p
+
1
,
' '
);
if
(
!
p
)
continue
;
p2
=
strchr
(
p
+
1
,
' '
);
p2
=
strchr
(
p
+
1
,
' '
);
if
(
!
p2
)
continue
;
*
p2
=
'\0'
;
if
(
strcmp
(
p
+
1
,
"/"
)
==
0
)
{
if
(
strcmp
(
p
+
1
,
"/"
)
==
0
)
{
// this is '/'. is it the ramfs?
p
=
strchr
(
p2
+
1
,
'-'
);
p
=
strchr
(
p2
+
1
,
'-'
);
if
(
p
&&
strncmp
(
p
,
"- rootfs rootfs "
,
16
)
==
0
)
{
free
(
line
);
fclose
(
f
);
return
1
;
return
true
;
}
}
}
free
(
line
);
fclose
(
f
);
return
0
;
return
false
;
}
char
*
on_path
(
char
*
cmd
,
const
char
*
rootfs
)
{
...
...
src/lxc/utils.h
View file @
32a2ca49
...
...
@@ -293,7 +293,7 @@ extern bool dir_exists(const char *path);
uint64_t
fnv_64a_buf
(
void
*
buf
,
size_t
len
,
uint64_t
hval
);
int
detect_shared_rootfs
(
void
);
int
detect_ramfs_rootfs
(
void
);
bool
detect_ramfs_rootfs
(
void
);
char
*
on_path
(
char
*
cmd
,
const
char
*
rootfs
);
bool
file_exists
(
const
char
*
f
);
bool
cgns_supported
(
void
);
...
...
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