diff options
| author | PancakeTAS <pancake@mgnet.work> | 2026-05-18 15:51:33 +0200 |
|---|---|---|
| committer | PancakeTAS <pancake@mgnet.work> | 2026-05-18 15:51:33 +0200 |
| commit | 9d2e04c95285825a196205163eebd945a362fb5e (patch) | |
| tree | 59fdd2cfad0d3d548e54b54740806d7604218b89 /src/ioctl.cpp | |
| parent | Extend sync objects with timeline support (diff) | |
Split public/private API into respective locations
Diffstat (limited to '')
| -rw-r--r-- | src/ioctl.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/ioctl.cpp b/src/ioctl.cpp new file mode 100644 index 0000000..982e1e9 --- /dev/null +++ b/src/ioctl.cpp @@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: MIT */ + +#include "drm++/ioctl.hpp" + +#include <format> +#include <string> + +#include <errno.h> + +using namespace drm::ioctl; + +Exception::Exception(int fd, unsigned long op) + : m_fd(fd), m_op(op), m_syserrno(errno) { + switch (errno) { + case EBADF: + m_code = Error::BadFileDescriptor; + break; + case EINVAL: + case ENOTTY: + m_code = Error::InvalidArgument; + break; + case ENOTSUP: + m_code = Error::NotSupported; + break; + default: + m_code = Error::Other; + } +} + +std::string Exception::readable() { + switch (this->m_code) { + case Error::BadFileDescriptor: + return std::format( + "ioctl({}, {}) failed: Invalid file descriptor", + this->m_fd, this->m_op + ); + case Error::InvalidArgument: + return std::format( + "ioctl({}, {}) failed: Invalid argument (errno {})", + this->m_fd, this->m_op, this->m_syserrno + ); + case Error::NotSupported: + return std::format( + "ioctl({}, {}) failed: Operation not supported", + this->m_fd, this->m_op + ); + case Error::Other: + return std::format( + "ioctl({}, {}) failed: Unknown error (errno {})", + this->m_fd, this->m_op, this->m_syserrno + ); + } +} + +Exception::~Exception() = default; |
