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
e2f9a4ef
Unverified
Commit
e2f9a4ef
authored
Oct 23, 2018
by
2xsec
Committed by
Christian Brauner
Nov 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage_utils: add error handling
Signed-off-by:
2xsec
<
dh48.jeong@samsung.com
>
parent
b76767e1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
9 deletions
+24
-9
storage_utils.c
src/lxc/storage/storage_utils.c
+24
-9
No files found.
src/lxc/storage/storage_utils.c
View file @
e2f9a4ef
...
...
@@ -153,12 +153,18 @@ int blk_getsize(struct lxc_storage *bdev, uint64_t *size)
const
char
*
src
;
src
=
lxc_storage_get_path
(
bdev
->
src
,
bdev
->
type
);
fd
=
open
(
src
,
O_RDONLY
);
if
(
fd
<
0
)
fd
=
open
(
src
,
O_RDONLY
|
O_CLOEXEC
);
if
(
fd
<
0
)
{
SYSERROR
(
"Failed to open
\"
%s
\"
"
,
src
);
return
-
1
;
}
/* size of device in bytes */
ret
=
ioctl
(
fd
,
BLKGETSIZE64
,
size
);
if
(
ret
<
0
)
SYSERROR
(
"Failed to get block size of dev-src"
);
close
(
fd
);
return
ret
;
}
...
...
@@ -195,11 +201,16 @@ int detect_fs(struct lxc_storage *bdev, char *type, int len)
srcdev
=
lxc_storage_get_path
(
bdev
->
src
,
bdev
->
type
);
ret
=
pipe
(
p
);
if
(
ret
<
0
)
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to create pipe"
);
return
-
1
;
}
if
((
pid
=
fork
())
<
0
)
pid
=
fork
();
if
(
pid
<
0
)
{
SYSERROR
(
"Failed to fork process"
);
return
-
1
;
}
if
(
pid
>
0
)
{
int
status
;
...
...
@@ -409,8 +420,10 @@ const char *linkderef(const char *path, char *dest)
ssize_t
ret
;
ret
=
stat
(
path
,
&
sbuf
);
if
(
ret
<
0
)
if
(
ret
<
0
)
{
SYSERROR
(
"Failed to get status of file -
\"
%s
\"
"
,
path
);
return
NULL
;
}
if
(
!
S_ISLNK
(
sbuf
.
st_mode
))
return
path
;
...
...
@@ -517,20 +530,22 @@ int storage_destroy_wrapper(void *data)
struct
lxc_conf
*
conf
=
data
;
if
(
setgid
(
0
)
<
0
)
{
ERROR
(
"Failed to setgid to 0"
);
SYS
ERROR
(
"Failed to setgid to 0"
);
return
-
1
;
}
if
(
setgroups
(
0
,
NULL
)
<
0
)
WARN
(
"Failed to clear groups"
);
SYS
WARN
(
"Failed to clear groups"
);
if
(
setuid
(
0
)
<
0
)
{
ERROR
(
"Failed to setuid to 0"
);
SYS
ERROR
(
"Failed to setuid to 0"
);
return
-
1
;
}
if
(
!
storage_destroy
(
conf
))
if
(
!
storage_destroy
(
conf
))
{
ERROR
(
"Failed to destroy storage"
);
return
-
1
;
}
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