Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow read-only mode on Linux for ATA drives #437

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions linux/DtaDevLinuxSata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,15 @@ bool DtaDevLinuxSata::init(const char * devref)
}

if ((fd = open(devref, O_RDWR)) < 0) {
isOpen = FALSE;
// This is a D1 because diskscan looks for open fail to end scan
LOG(D1) << "Error opening device " << devref << " " << (int32_t) fd;
LOG(D1) << "Error opening device in write mode; dev ref: " << devref << " FD: " << (int32_t) fd << " errno: " << errno;
if ((fd = open(devref, O_RDONLY)) < 0) {
LOG(D1) << "Error opening device in read mode; dev ref: " << devref << " FD: " << (int32_t) fd << " errno: " << errno;
} else {
isOpen = TRUE;
LOG(E) << "You do not have permission to access the raw disk in write mode, but you can access it in read mode";
LOG(E) << "Be extra careful trying to operate this device";
}
// if (-EPERM == fd) {
// LOG(E) << "You do not have permission to access the raw disk in write mode";
// LOG(E) << "Perhaps you might try sudo to run as root";
Expand Down