From 1ba3b6a2f60da97c86acd3a6725fcafd2ecfe812 Mon Sep 17 00:00:00 2001 From: Uwe Seimet <48174652+uweseimet@users.noreply.github.com> Date: Sat, 7 Aug 2021 02:50:20 +0200 Subject: [PATCH] PbDevice returns information on whether a device is removable (#167) * PbDevice returns information on whether a device is removable * Fixed log message --- src/raspberrypi/devices/disk.cpp | 2 +- src/raspberrypi/devices/disk.h | 14 +++++++------- src/raspberrypi/rascsi.cpp | 4 +++- src/raspberrypi/rascsi_interface.proto | 3 ++- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/raspberrypi/devices/disk.cpp b/src/raspberrypi/devices/disk.cpp index e2d50689..b1a8ed6c 100644 --- a/src/raspberrypi/devices/disk.cpp +++ b/src/raspberrypi/devices/disk.cpp @@ -950,7 +950,7 @@ void Disk::GetPath(Filepath& path) const // Flush // //--------------------------------------------------------------------------- -BOOL Disk::Flush() +bool Disk::Flush() { // Do nothing if there's nothing cached if (!disk.dcache) { diff --git a/src/raspberrypi/devices/disk.h b/src/raspberrypi/devices/disk.h index 76a31192..155405fe 100644 --- a/src/raspberrypi/devices/disk.h +++ b/src/raspberrypi/devices/disk.h @@ -201,14 +201,14 @@ public: virtual BOOL Open(const Filepath& path, BOOL attn = TRUE); // Open void GetPath(Filepath& path) const; // Get the path void Eject(BOOL force); // Eject - BOOL IsReady() const { return disk.ready; } // Ready check + bool IsReady() const { return disk.ready; } // Ready check void WriteP(BOOL flag); // Set Write Protect flag - BOOL IsWriteP() const { return disk.writep; } // Get write protect flag - BOOL IsReadOnly() const { return disk.readonly; } // Get read only flag - BOOL IsRemovable() const { return disk.removable; } // Get is removable flag - BOOL IsLocked() const { return disk.lock; } // Get locked status - BOOL IsAttn() const { return disk.attn; } // Get attention flag - BOOL Flush(); // Flush the cache + bool IsWriteP() const { return disk.writep; } // Get write protect flag + bool IsReadOnly() const { return disk.readonly; } // Get read only flag + bool IsRemovable() const { return disk.removable; } // Get is removable flag + bool IsLocked() const { return disk.lock; } // Get locked status + bool IsAttn() const { return disk.attn; } // Get attention flag + bool Flush(); // Flush the cache // Properties void SetLUN(DWORD lun) { disk.lun = lun; } // LUN set diff --git a/src/raspberrypi/rascsi.cpp b/src/raspberrypi/rascsi.cpp index da121ddd..ded0d1de 100644 --- a/src/raspberrypi/rascsi.cpp +++ b/src/raspberrypi/rascsi.cpp @@ -291,6 +291,8 @@ PbDevices GetDevices() { device->set_file(pUnit->IsRemovable() && !pUnit->IsReady() ? "NO MEDIA" : filepath.GetPath()); } + device->set_removable(pUnit->IsRemovable()); + // Write protection status if (pUnit->IsRemovable() && pUnit->IsReady() && pUnit->IsWriteP()) { device->set_read_only(true); @@ -686,7 +688,7 @@ bool ProcessCmd(int fd, const PbCommand &command) break; case EJECT: - LOGINFO("rasctl commands eject %s ID: %d UN: %d", type_str, id, un); + LOGINFO("rasctl commanded eject for %s ID: %d UN: %d", pUnit->GetID().c_str(), id, un); pUnit->Eject(TRUE); break; diff --git a/src/raspberrypi/rascsi_interface.proto b/src/raspberrypi/rascsi_interface.proto index 58e2efeb..a7eba989 100644 --- a/src/raspberrypi/rascsi_interface.proto +++ b/src/raspberrypi/rascsi_interface.proto @@ -48,7 +48,8 @@ message PbDevice { int32 un = 2; string type = 3; string file = 4; - bool read_only = 5; + bool removable = 5; + bool read_only = 6; } message PbDevices {