chiark / gitweb /
shutdown: make use of wait_for_terminate_and_warn()
[elogind.git] / src / umount.c
index bd4f01ff64ae553d5cbdef1c77ff0cbf411e3ad6..44bed611ea7482e53ddeed993a5001c32853277e 100644 (file)
@@ -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) {
@@ -302,7 +293,7 @@ static int mount_points_list_umount(MountPoint **mount_point_list_head) {
                 if (umount2(mp->path, MNT_FORCE) == 0)
                         mount_point_remove_and_free(mp, mount_point_list_head);
                 else {
-                        log_debug("Could not unmount %s: %m", mp->path);
+                        log_warning("Could not unmount %s: %m", mp->path);
                         failed++;
                 }
         }
@@ -319,7 +310,7 @@ static int mount_points_list_remount_read_only(MountPoint **mount_point_list_hea
                 if (mount(NULL, mp->path, NULL, MS_MGC_VAL|MS_REMOUNT|MS_RDONLY, NULL) == 0)
                         mount_point_remove_and_free(mp, mount_point_list_head);
                 else {
-                        log_debug("Could not remount as read-only %s: %m", mp->path);
+                        log_warning("Could not remount as read-only %s: %m", mp->path);
                         failed++;
                 }
         }
@@ -335,7 +326,7 @@ static int swap_points_list_off(MountPoint **swap_list_head) {
                 if (swapoff(swap->path) == 0)
                         mount_point_remove_and_free(swap, swap_list_head);
                 else {
-                        log_debug("Could not swapoff %s: %m", swap->path);
+                        log_warning("Could not deactivate swap %s: %m", swap->path);
                         failed++;
                 }
         }
@@ -351,7 +342,7 @@ static int loopback_points_list_detach(MountPoint **loopback_list_head) {
                 if (delete_loopback(loopback->path) == 0)
                         mount_point_remove_and_free(loopback, loopback_list_head);
                 else {
-                        log_debug("Could not delete loopback %s: %m", loopback->path);
+                        log_warning("Could not delete loopback %s: %m", loopback->path);
                         failed++;
                 }
         }