umount: simplify code for deactivating loop devices
This commit is contained in:
parent
b854a7e728
commit
ce726252a9
17
src/umount.c
17
src/umount.c
|
@ -271,23 +271,14 @@ finish:
|
||||||
static int delete_loopback(const char *device) {
|
static int delete_loopback(const char *device) {
|
||||||
int fd, r;
|
int fd, r;
|
||||||
|
|
||||||
if ((fd = open(device, O_RDONLY|O_CLOEXEC)) < 0) {
|
if ((fd = open(device, O_RDONLY|O_CLOEXEC)) < 0)
|
||||||
if (errno == ENOENT) {
|
|
||||||
log_debug("Loop device %s does not exist.", device);
|
|
||||||
errno = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
|
||||||
|
|
||||||
ioctl(fd, LOOP_CLR_FD, 0);
|
r = ioctl(fd, LOOP_CLR_FD, 0);
|
||||||
r = errno;
|
|
||||||
close_nointr_nofail(fd);
|
close_nointr_nofail(fd);
|
||||||
|
|
||||||
if (r == ENXIO) /* not bound, so no error */
|
/* ENXIO: not bound, so no error */
|
||||||
r = 0;
|
return (r >= 0 || errno == ENXIO) ? 0 : -errno;
|
||||||
errno = r;
|
|
||||||
return -errno;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mount_points_list_umount(MountPoint **mount_point_list_head) {
|
static int mount_points_list_umount(MountPoint **mount_point_list_head) {
|
||||||
|
|
Loading…
Reference in New Issue