+ if (waitpid(pid, &status, 0) == -1) {
+ pb_log("%s: waitpid failed: %s\n", __func__,
+ strerror(errno));
+ goto out_rmdir;
+ }
+
+ if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
+ goto out_rmdir;
+
+ setup_device_links(ctx);
+ return 0;
+
+out_rmdir:
+ rmdir_recursive(mount_base(), ctx->mount_path);
+ return -1;
+}
+
+static int umount_device(struct discover_context *ctx)
+{
+ int status;
+ pid_t pid;
+
+ remove_device_links(ctx);
+
+ pid = fork();
+ if (pid == -1) {
+ pb_log("%s: fork failed: %s\n", __func__, strerror(errno));
+ return -1;
+ }
+
+ if (pid == 0) {
+ execl(UMOUNT_BIN, UMOUNT_BIN, ctx->mount_path, NULL);
+ exit(EXIT_FAILURE);
+ }
+