From 6beeb2ccca925a8ae00731405bd78b86b75b2595 Mon Sep 17 00:00:00 2001 From: Evgeny Sinelnikov Date: Sat, 27 Mar 2021 02:59:28 +0400 Subject: [PATCH] cdrom.c: Try to mount multiple devices in automatic mode --- cdrom.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cdrom.c b/cdrom.c index 565e7b6..5e118ea 100644 --- a/cdrom.c +++ b/cdrom.c @@ -228,6 +228,7 @@ enum return_type cdrom_prepare(void) if (IS_AUTOMATIC) { unsigned int j; + enum return_type automatic_result = RETURN_OK; for (j = 0; j < 15; ++j) { udev_settle(); @@ -254,14 +255,23 @@ enum return_type cdrom_prepare(void) get_medias(CDROM, &medias, &medias_models); remove_wait_message(); } - if ((i = try_automatic(medias, medias_models)) != -1) { - if (j) { + while ((i = try_automatic(medias, medias_models)) != -1) { + if (j && automatic_result == RETURN_OK) { log_message("found /dev/%s %s after %d seconds of waiting", medias[i], medias_models[i], j); remove_wait_message(); } - return do_with_device(medias[i], medias_models[i]); + if (automatic_result != RETURN_OK) { + log_message("try next found device /dev/%s %s", + medias[i], medias_models[i]); + } + automatic_result = do_with_device(medias[i], medias_models[i]); + if (automatic_result == RETURN_OK) + return RETURN_OK; + log_message("mount device /dev/%s %s failed", medias[i], medias_models[i]); } + if (automatic_result != RETURN_OK) + return automatic_result; } ptr = medias;