Signed-off-by: 2xsec <dh48.jeong@samsung.com>
const char *src;
src = lxc_storage_get_path(bdev->src, bdev->type);
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);
/* size of device in bytes */
ret = ioctl(fd, BLKGETSIZE64, size);
/* size of device in bytes */
ret = ioctl(fd, BLKGETSIZE64, size);
+ if (ret < 0)
+ SYSERROR("Failed to get block size of dev-src");
+
srcdev = lxc_storage_get_path(bdev->src, bdev->type);
ret = pipe(p);
srcdev = lxc_storage_get_path(bdev->src, bdev->type);
ret = pipe(p);
+ if (ret < 0) {
+ SYSERROR("Failed to create pipe");
- if ((pid = fork()) < 0)
+ pid = fork();
+ if (pid < 0) {
+ SYSERROR("Failed to fork process");
if (pid > 0) {
int status;
if (pid > 0) {
int status;
ssize_t ret;
ret = stat(path, &sbuf);
ssize_t ret;
ret = stat(path, &sbuf);
+ if (ret < 0) {
+ SYSERROR("Failed to get status of file - \"%s\"", path);
if (!S_ISLNK(sbuf.st_mode))
return path;
if (!S_ISLNK(sbuf.st_mode))
return path;
struct lxc_conf *conf = data;
if (setgid(0) < 0) {
struct lxc_conf *conf = data;
if (setgid(0) < 0) {
- ERROR("Failed to setgid to 0");
+ SYSERROR("Failed to setgid to 0");
return -1;
}
if (setgroups(0, NULL) < 0)
return -1;
}
if (setgroups(0, NULL) < 0)
- WARN("Failed to clear groups");
+ SYSWARN("Failed to clear groups");
- ERROR("Failed to setuid to 0");
+ SYSERROR("Failed to setuid to 0");
- if (!storage_destroy(conf))
+ if (!storage_destroy(conf)) {
+ ERROR("Failed to destroy storage");