PbDevice returns information on whether a device is removable (#167)

* PbDevice returns information on whether a device is removable

* Fixed log message
This commit is contained in:
Uwe Seimet 2021-08-07 02:50:20 +02:00 committed by GitHub
parent eeef537bc0
commit 1ba3b6a2f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 10 deletions

View File

@ -950,7 +950,7 @@ void Disk::GetPath(Filepath& path) const
// Flush // Flush
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
BOOL Disk::Flush() bool Disk::Flush()
{ {
// Do nothing if there's nothing cached // Do nothing if there's nothing cached
if (!disk.dcache) { if (!disk.dcache) {

View File

@ -201,14 +201,14 @@ public:
virtual BOOL Open(const Filepath& path, BOOL attn = TRUE); // Open virtual BOOL Open(const Filepath& path, BOOL attn = TRUE); // Open
void GetPath(Filepath& path) const; // Get the path void GetPath(Filepath& path) const; // Get the path
void Eject(BOOL force); // Eject 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 void WriteP(BOOL flag); // Set Write Protect flag
BOOL IsWriteP() const { return disk.writep; } // Get write protect flag bool IsWriteP() const { return disk.writep; } // Get write protect flag
BOOL IsReadOnly() const { return disk.readonly; } // Get read only flag bool IsReadOnly() const { return disk.readonly; } // Get read only flag
BOOL IsRemovable() const { return disk.removable; } // Get is removable flag bool IsRemovable() const { return disk.removable; } // Get is removable flag
BOOL IsLocked() const { return disk.lock; } // Get locked status bool IsLocked() const { return disk.lock; } // Get locked status
BOOL IsAttn() const { return disk.attn; } // Get attention flag bool IsAttn() const { return disk.attn; } // Get attention flag
BOOL Flush(); // Flush the cache bool Flush(); // Flush the cache
// Properties // Properties
void SetLUN(DWORD lun) { disk.lun = lun; } // LUN set void SetLUN(DWORD lun) { disk.lun = lun; } // LUN set

View File

@ -291,6 +291,8 @@ PbDevices GetDevices() {
device->set_file(pUnit->IsRemovable() && !pUnit->IsReady() ? "NO MEDIA" : filepath.GetPath()); device->set_file(pUnit->IsRemovable() && !pUnit->IsReady() ? "NO MEDIA" : filepath.GetPath());
} }
device->set_removable(pUnit->IsRemovable());
// Write protection status // Write protection status
if (pUnit->IsRemovable() && pUnit->IsReady() && pUnit->IsWriteP()) { if (pUnit->IsRemovable() && pUnit->IsReady() && pUnit->IsWriteP()) {
device->set_read_only(true); device->set_read_only(true);
@ -686,7 +688,7 @@ bool ProcessCmd(int fd, const PbCommand &command)
break; break;
case EJECT: 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); pUnit->Eject(TRUE);
break; break;

View File

@ -48,7 +48,8 @@ message PbDevice {
int32 un = 2; int32 un = 2;
string type = 3; string type = 3;
string file = 4; string file = 4;
bool read_only = 5; bool removable = 5;
bool read_only = 6;
} }
message PbDevices { message PbDevices {