mirror of
git://github.com/lxc/lxc
synced 2025-08-30 11:31:59 +00:00
utils: add errno logs for exception case
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
This commit is contained in:
parent
7be6bcd523
commit
2f32e37ef4
@ -1418,8 +1418,10 @@ static int lxc_get_unused_loop_dev_legacy(char *loop_name)
|
||||
int dfd = -1, fd = -1, ret = -1;
|
||||
|
||||
dir = opendir("/dev");
|
||||
if (!dir)
|
||||
if (!dir) {
|
||||
SYSERROR("Failed to open \"/dev\"");
|
||||
return -1;
|
||||
}
|
||||
|
||||
while ((dp = readdir(dir))) {
|
||||
if (strncmp(dp->d_name, "loop", 4) != 0)
|
||||
@ -1467,12 +1469,16 @@ static int lxc_get_unused_loop_dev(char *name_loop)
|
||||
int fd_ctl = -1, fd_tmp = -1;
|
||||
|
||||
fd_ctl = open("/dev/loop-control", O_RDWR | O_CLOEXEC);
|
||||
if (fd_ctl < 0)
|
||||
if (fd_ctl < 0) {
|
||||
SYSERROR("Failed to open loop control");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
loop_nr = ioctl(fd_ctl, LOOP_CTL_GET_FREE);
|
||||
if (loop_nr < 0)
|
||||
if (loop_nr < 0) {
|
||||
SYSERROR("Failed to get loop control");
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
ret = snprintf(name_loop, LO_NAME_SIZE, "/dev/loop%d", loop_nr);
|
||||
if (ret < 0 || ret >= LO_NAME_SIZE)
|
||||
@ -1480,7 +1486,7 @@ static int lxc_get_unused_loop_dev(char *name_loop)
|
||||
|
||||
fd_tmp = open(name_loop, O_RDWR | O_CLOEXEC);
|
||||
if (fd_tmp < 0)
|
||||
goto on_error;
|
||||
SYSERROR("Failed to open loop \"%s\"", name_loop);
|
||||
|
||||
on_error:
|
||||
close(fd_ctl);
|
||||
@ -1495,26 +1501,34 @@ int lxc_prepare_loop_dev(const char *source, char *loop_dev, int flags)
|
||||
|
||||
fd_loop = lxc_get_unused_loop_dev(loop_dev);
|
||||
if (fd_loop < 0) {
|
||||
if (fd_loop == -ENODEV)
|
||||
fd_loop = lxc_get_unused_loop_dev_legacy(loop_dev);
|
||||
else
|
||||
if (fd_loop != -ENODEV)
|
||||
goto on_error;
|
||||
|
||||
fd_loop = lxc_get_unused_loop_dev_legacy(loop_dev);
|
||||
if (fd_loop < 0)
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
fd_img = open(source, O_RDWR | O_CLOEXEC);
|
||||
if (fd_img < 0)
|
||||
if (fd_img < 0) {
|
||||
SYSERROR("Failed to open source \"%s\"", source);
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
ret = ioctl(fd_loop, LOOP_SET_FD, fd_img);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
SYSERROR("Failed to set loop fd");
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
memset(&lo64, 0, sizeof(lo64));
|
||||
lo64.lo_flags = flags;
|
||||
|
||||
ret = ioctl(fd_loop, LOOP_SET_STATUS64, &lo64);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
SYSERROR("Failed to set loop status64");
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
fret = 0;
|
||||
|
||||
@ -1681,10 +1695,8 @@ int lxc_set_death_signal(int signal, pid_t parent)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
SYSERROR("Failed to set PR_SET_PDEATHSIG to %d", signal);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user