Skip to content
Closed
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ if (DBUS)
list(APPEND QT_FPDEPS DBus)
endif()

if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
include_directories(SYSTEM /usr/local/include)
link_directories(/usr/local/lib)
endif()

find_package(Qt6 REQUIRED COMPONENTS ${QT_FPDEPS})

# In Qt 6.10, private dependencies are required to be explicit,
Expand Down
47 changes: 33 additions & 14 deletions src/core/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@
#include <qtmetamacros.h>
#include <qtypes.h>
#include <sys/mman.h>

#ifdef __FreeBSD__
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/uio.h>
#else
#include <sys/sendfile.h>
#endif

#include "instanceinfo.hpp"
#include "logcat.hpp"
Expand Down Expand Up @@ -392,13 +399,12 @@ void ThreadLogging::initFs() {
delete detailedFile;
detailedFile = nullptr;
} else {
auto lock = flock {
.l_type = F_WRLCK,
.l_whence = SEEK_SET,
.l_start = 0,
.l_len = 0,
.l_pid = 0,
};
struct flock lock = {};
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
lock.l_pid = 0;

if (fcntl(detailedFile->handle(), F_SETLK, &lock) != 0) { // NOLINT
qCWarning(logLogging) << "Unable to set lock marker on detailed log file. --follow from "
Expand All @@ -414,7 +420,14 @@ void ThreadLogging::initFs() {
auto* oldFile = this->file;
if (oldFile) {
oldFile->seek(0);
// clang-format off
#ifdef __FreeBSD__
off_t sent = 0;
sendfile(oldFile->handle(), file->handle(), 0, oldFile->size(), nullptr, &sent, 0);
#else
sendfile(file->handle(), oldFile->handle(), nullptr, oldFile->size());
#endif
// clang-format on
}

this->file = file;
Expand All @@ -426,7 +439,14 @@ void ThreadLogging::initFs() {
auto* oldFile = this->detailedFile;
if (oldFile) {
oldFile->seek(0);
// clang-format off
#ifdef __FreeBSD__
off_t sent = 0;
sendfile(oldFile->handle(), detailedFile->handle(), 0, oldFile->size(), nullptr, &sent, 0);
#else
sendfile(detailedFile->handle(), oldFile->handle(), nullptr, oldFile->size());
#endif
// clang-format on
}

crash::CrashInfo::INSTANCE.logFd = detailedFile->handle();
Expand Down Expand Up @@ -889,13 +909,12 @@ bool LogReader::continueReading() {
}

void LogFollower::FcntlWaitThread::run() {
auto lock = flock {
.l_type = F_RDLCK, // won't block other read locks when we take it
.l_whence = SEEK_SET,
.l_start = 0,
.l_len = 0,
.l_pid = 0,
};
struct flock lock = {};
lock.l_type = F_RDLCK; // won't block other read locks when we take it
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
lock.l_pid = 0;

auto r = fcntl(this->follower->reader->file->handle(), F_SETLKW, &lock); // NOLINT

Expand Down
26 changes: 12 additions & 14 deletions src/core/paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,12 @@ void QsPaths::createLock() {
return;
}

auto lock = flock {
.l_type = F_WRLCK,
.l_whence = SEEK_SET,
.l_start = 0,
.l_len = 0,
.l_pid = 0,
};
struct flock lock = {};
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
lock.l_pid = 0;

if (fcntl(file->handle(), F_SETLK, &lock) != 0) { // NOLINT
qCCritical(logPaths).nospace() << "Could not lock instance lock at " << path
Expand All @@ -389,13 +388,12 @@ bool QsPaths::checkLock(const QString& path, InstanceLockInfo* info, bool allowD
auto file = QFile(QDir(path).filePath("instance.lock"));
if (!file.open(QFile::ReadOnly)) return false;

auto lock = flock {
.l_type = F_WRLCK,
.l_whence = SEEK_SET,
.l_start = 0,
.l_len = 0,
.l_pid = 0,
};
struct flock lock = {};
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
lock.l_pid = 0;

fcntl(file.handle(), F_GETLK, &lock); // NOLINT
auto isLocked = lock.l_type != F_UNLCK;
Expand Down
13 changes: 6 additions & 7 deletions src/core/toolsupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,12 @@ bool QmlToolingSupport::lockTooling() {
return false;
}

auto lock = flock {
.l_type = F_WRLCK,
.l_whence = SEEK_SET, // NOLINT (fcntl.h??)
.l_start = 0,
.l_len = 0,
.l_pid = 0,
};
struct flock lock = {};
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET; // NOLINT (fcntl.h??)
lock.l_start = 0;
lock.l_len = 0;
lock.l_pid = 0;

if (fcntl(file->handle(), F_SETLK, &lock) == 0) {
qCInfo(logTooling) << "Acquired tooling support lock";
Expand Down