From f84a13b3e20d623bb34949faa80312e0384cc360 Mon Sep 17 00:00:00 2001 From: Uwe Seimet <48174652+uweseimet@users.noreply.github.com> Date: Sat, 29 Oct 2022 18:15:30 +0200 Subject: [PATCH] Prevent copying of files in use (#951) --- cpp/rascsi/rascsi_image.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cpp/rascsi/rascsi_image.cpp b/cpp/rascsi/rascsi_image.cpp index 4e0804a6..746056e8 100644 --- a/cpp/rascsi/rascsi_image.cpp +++ b/cpp/rascsi/rascsi_image.cpp @@ -249,6 +249,12 @@ bool RascsiImage::CopyImage(const CommandContext& context, const PbCommand& comm return context.ReturnStatus(false, "Can't read source image file '" + from + "'"); } + const auto [id, lun] = StorageDevice::GetIdsForReservedFile(from); + if (id != -1 || lun != -1) { + return context.ReturnStatus(false, "Can't copy image file '" + from + + "', it is currently being used by device ID " + to_string(id) + ", LUN " + to_string(lun)); + } + if (!CreateImageFolder(context, to)) { return false; }