Skip to content

Commit

Permalink
Log SG device
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Jan 31, 2025
1 parent 2713338 commit d2765a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cpp/shared/sg_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// SCSI2Pi, SCSI device emulator and SCSI tools for the Raspberry Pi
//
// Copyright (C) 2024 Uwe Seimet
// Copyright (C) 2024-2025 Uwe Seimet
//
//---------------------------------------------------------------------------

Expand All @@ -18,17 +18,19 @@
using namespace memory_util;
using namespace sg_util;

string SgAdapter::Init(const string &device)
string SgAdapter::Init(const string &d)
{
try {
fd = OpenDevice(device);
fd = OpenDevice(d);
}
catch (const IoException &e) {
return e.what();
}

GetBlockSize();

device = d;

return "";
}

Expand Down Expand Up @@ -107,7 +109,7 @@ SgAdapter::SgResult SgAdapter::SendCommandInternal(span<uint8_t> cdb, span<uint8
io_hdr.timeout = timeout * 1000;

if (enable_log && sg_logger.level() <= level::debug) {
sg_logger.debug(command_meta_data.LogCdb(cdb, "SG driver"));
sg_logger.debug(command_meta_data.LogCdb(cdb, fmt::format("SG driver ({})", device)));
}

const int status = ioctl(fd, SG_IO, &io_hdr) < 0 ? -1 : io_hdr.status;
Expand Down
2 changes: 2 additions & 0 deletions cpp/shared/sg_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class SgAdapter

void GetBlockSize();

string device;

logger &sg_logger;

CommandMetaData &command_meta_data = CommandMetaData::GetInstance();
Expand Down

0 comments on commit d2765a0

Please sign in to comment.