Commit 65a91a53 authored by Harald Sitter's avatar Harald Sitter 🏳️‍🌈
Browse files

make O_PATH optional-ish

on ancient linuxes we don't have access to it. more importantly freebsd
has nothing like it at all. use readonly in these cases
parent 3c299d99
......@@ -32,7 +32,13 @@ static QString nameToPath(const QString &name)
const QString path = QStringLiteral("/dev/%1").arg(name);
int blockFD = open(QFile::encodeName(path), O_PATH | O_NOFOLLOW);
int flags = O_NOFOLLOW; // POSIX.1-2008 should always be available
#ifdef O_PATH // Not available on FreeBSD and Linux < 2.6.39
flags |= O_PATH;
flags |= O_RDONLY;
int blockFD = open(QFile::encodeName(path), flags);
auto blockFDClose = qScopeGuard([blockFD] { close(blockFD); });
if (blockFD == -1) {
const int err = errno;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment