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
4a185bf6
Unverified
Commit
4a185bf6
authored
Feb 17, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgfsng: convert_devpath()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
b03b7237
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
cgfsng.c
src/lxc/cgroups/cgfsng.c
+12
-10
No files found.
src/lxc/cgroups/cgfsng.c
View file @
4a185bf6
...
@@ -2582,41 +2582,43 @@ static int cgfsng_set(const char *filename, const char *value, const char *name,
...
@@ -2582,41 +2582,43 @@ static int cgfsng_set(const char *filename, const char *value, const char *name,
return
ret
;
return
ret
;
}
}
/*
/* take devices cgroup line
* take devices cgroup line
* /dev/foo rwx
* /dev/foo rwx
* and convert it to a valid
* and convert it to a valid
* type major:minor mode
* type major:minor mode
* line.
Return <0 on error. Dest is a preallocated buffer
* line.
Return <0 on error. Dest is a preallocated buffer long enough to hold
*
long enough to hold
the output.
* the output.
*/
*/
static
int
convert_devpath
(
const
char
*
invalue
,
char
*
dest
)
static
int
convert_devpath
(
const
char
*
invalue
,
char
*
dest
)
{
{
int
n_parts
;
int
n_parts
;
char
*
p
,
*
path
,
type
;
char
*
p
,
*
path
,
type
;
struct
stat
sb
;
unsigned
long
minor
,
major
;
unsigned
long
minor
,
major
;
struct
stat
sb
;
int
ret
=
-
EINVAL
;
int
ret
=
-
EINVAL
;
char
*
mode
=
NULL
;
char
*
mode
=
NULL
;
path
=
must_copy_string
(
invalue
);
path
=
must_copy_string
(
invalue
);
/*
/* Read path followed by mode. Ignore any trailing text.
* read path followed by mode; ignore any trailing text.
* A ' # comment' would be legal. Technically other text is not
* A ' # comment' would be legal. Technically other text
* legal, we could check for that if we cared to.
* is not legal, we could check for that if we cared to
*/
*/
for
(
n_parts
=
1
,
p
=
path
;
*
p
&&
n_parts
<
3
;
p
++
)
{
for
(
n_parts
=
1
,
p
=
path
;
*
p
&&
n_parts
<
3
;
p
++
)
{
if
(
*
p
!=
' '
)
if
(
*
p
!=
' '
)
continue
;
continue
;
*
p
=
'\0'
;
*
p
=
'\0'
;
if
(
n_parts
!=
1
)
if
(
n_parts
!=
1
)
break
;
break
;
p
++
;
p
++
;
n_parts
++
;
n_parts
++
;
while
(
*
p
==
' '
)
while
(
*
p
==
' '
)
p
++
;
p
++
;
mode
=
p
;
mode
=
p
;
if
(
*
p
==
'\0'
)
if
(
*
p
==
'\0'
)
goto
out
;
goto
out
;
}
}
...
@@ -2637,7 +2639,7 @@ static int convert_devpath(const char *invalue, char *dest)
...
@@ -2637,7 +2639,7 @@ static int convert_devpath(const char *invalue, char *dest)
type
=
'c'
;
type
=
'c'
;
break
;
break
;
default:
default:
ERROR
(
"Unsupported device type %i for
%s
"
,
m
,
path
);
ERROR
(
"Unsupported device type %i for
\"
%s
\"
"
,
m
,
path
);
ret
=
-
EINVAL
;
ret
=
-
EINVAL
;
goto
out
;
goto
out
;
}
}
...
...
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