diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-10-14 00:43:13 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-10-14 00:43:13 +0200 |
commit | ce726252a9a9487a694cbd68f4d13542ba965258 (patch) | |
tree | ec6aa103373e7b948b4cd1e2772c603a5c2103e8 /src | |
parent | b854a7e7289e0b136c6a4fa03ad76640c59bcfa0 (diff) |
umount: simplify code for deactivating loop devices
Diffstat (limited to 'src')
-rw-r--r-- | src/umount.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/umount.c b/src/umount.c index bd4f01ff64..ff1296fc0f 100644 --- a/src/umount.c +++ b/src/umount.c @@ -271,23 +271,14 @@ finish: static int delete_loopback(const char *device) { int fd, r; - 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; - } + if ((fd = open(device, O_RDONLY|O_CLOEXEC)) < 0) return -errno; - } - ioctl(fd, LOOP_CLR_FD, 0); - r = errno; + r = ioctl(fd, LOOP_CLR_FD, 0); close_nointr_nofail(fd); - if (r == ENXIO) /* not bound, so no error */ - r = 0; - errno = r; - return -errno; + /* ENXIO: not bound, so no error */ + return (r >= 0 || errno == ENXIO) ? 0 : -errno; } static int mount_points_list_umount(MountPoint **mount_point_list_head) { |