From 5308a6e74d5bb57233eebc8511be0c855c7e8643 Mon Sep 17 00:00:00 2001 From: Uwe Seimet Date: Sun, 29 Aug 2021 14:13:34 +0200 Subject: [PATCH] Reject inserting a medium when there is already a medium present (eject first) --- src/raspberrypi/rascsi.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/raspberrypi/rascsi.cpp b/src/raspberrypi/rascsi.cpp index 472807ba..85fe1e5e 100644 --- a/src/raspberrypi/rascsi.cpp +++ b/src/raspberrypi/rascsi.cpp @@ -880,6 +880,10 @@ bool ProcessCmd(int fd, const PbDeviceDefinition& pbDevice, const PbOperation op switch (operation) { case INSERT: { + if (!device->IsRemoved()) { + return ReturnStatus(fd, false, "Existing medium must first be ejected"); + } + if (!pbDevice.vendor().empty() || !pbDevice.product().empty() || !pbDevice.revision().empty()) { return ReturnStatus(fd, false, "Device name cannot be changed"); }