_cleanup_close_ int fd = -1;
int r;
+ assert(device);
+
fd = open(device, O_RDONLY|O_CLOEXEC);
if (fd < 0)
return errno == ENOENT ? 0 : -errno;
|| path_startswith(path, "/run/initramfs");
}
-static int remount_with_timeout(MountPoint *m, char *options, int *n_failed) {
+static int remount_with_timeout(MountPoint *m, char *options) {
pid_t pid;
int r;
BLOCK_SIGNALS(SIGCHLD);
+ assert(m);
+ assert(options);
+
/* Due to the possiblity of a remount operation hanging, we
* fork a child process and set a timeout. If the timeout
* lapses, the assumption is that that particular remount
return r;
}
-static int umount_with_timeout(MountPoint *m, bool *changed) {
+static int umount_with_timeout(MountPoint *m) {
pid_t pid;
int r;
BLOCK_SIGNALS(SIGCHLD);
+ assert(m);
+
/* Due to the possiblity of a umount operation hanging, we
* fork a child process and set a timeout. If the timeout
* lapses, the assumption is that that particular umount
int n_failed = 0;
assert(head);
+ assert(changed);
LIST_FOREACH(mount_point, m, *head) {
bool mount_is_readonly;
* Since the remount can hang in the instance of
* remote filesystems, we remount asynchronously
* and skip the subsequent umount if it fails */
- if (remount_with_timeout(m, options, &n_failed) < 0) {
+ if (remount_with_timeout(m, options) < 0) {
if (nonunmountable_path(m->path))
n_failed++;
continue;
continue;
/* Trying to umount */
- if (umount_with_timeout(m, changed) < 0)
+ if (umount_with_timeout(m) < 0)
n_failed++;
- else {
- if (changed)
- *changed = true;
- }
+ else
+ *changed = true;
}
return n_failed;
int n_failed = 0;
assert(head);
+ assert(changed);
LIST_FOREACH_SAFE(mount_point, m, n, *head) {
log_info("Deactivating swap %s.", m->path);
if (swapoff(m->path) == 0) {
- if (changed)
- *changed = true;
-
+ *changed = true;
mount_point_free(head, m);
} else {
log_warning_errno(errno, "Could not deactivate swap %s: %m", m->path);
struct stat root_st;
assert(head);
+ assert(changed);
k = lstat("/", &root_st);
log_info("Detaching loopback %s.", m->path);
r = delete_loopback(m->path);
if (r >= 0) {
- if (r > 0 && changed)
+ if (r > 0)
*changed = true;
mount_point_free(head, m);
dev_t rootdev;
assert(head);
+ assert(changed);
r = get_block_device("/", &rootdev);
if (r <= 0)
LIST_FOREACH_SAFE(mount_point, m, n, *head) {
- if (major(rootdev) != 0)
- if (rootdev == m->devnum) {
- n_failed ++;
- continue;
- }
+ if (major(rootdev) != 0 && rootdev == m->devnum) {
+ n_failed ++;
+ continue;
+ }
log_info("Detaching DM %u:%u.", major(m->devnum), minor(m->devnum));
r = delete_dm(m->devnum);
if (r >= 0) {
- if (changed)
- *changed = true;
-
+ *changed = true;
mount_point_free(head, m);
} else {
log_warning_errno(errno, "Could not detach DM %s: %m", m->path);
int r;
LIST_HEAD(MountPoint, mp_list_head);
+ assert(changed);
+
LIST_HEAD_INIT(mp_list_head);
r = mount_points_list_get(&mp_list_head);
if (r < 0)
bool umount_changed;
int r;
+ assert(changed);
+
/* Retry umount, until nothing can be umounted anymore. Mounts are
* processed in order, newest first. The retries are needed when
* an old mount has been moved, to a path inside a newer mount. */
int r;
LIST_HEAD(MountPoint, swap_list_head);
+ assert(changed);
+
LIST_HEAD_INIT(swap_list_head);
r = swap_list_get(&swap_list_head);
int r;
LIST_HEAD(MountPoint, loopback_list_head);
+ assert(changed);
+
LIST_HEAD_INIT(loopback_list_head);
r = loopback_list_get(&loopback_list_head);
int r;
LIST_HEAD(MountPoint, dm_list_head);
+ assert(changed);
+
LIST_HEAD_INIT(dm_list_head);
r = dm_list_get(&dm_list_head);