summaryrefslogtreecommitdiff
path: root/src/helper/ioctl.cpp
diff options
context:
space:
mode:
authorPancakeTAS <pancake@mgnet.work>2026-06-25 11:19:54 +0200
committerPancakeTAS <pancake@mgnet.work>2026-06-25 11:19:54 +0200
commitab752cafbde3755e7a09b3ecae021a6727cb7112 (patch)
treef7718df132f7683976c64974113d3148b43c46c5 /src/helper/ioctl.cpp
parentBug fixes all across the project (diff)
Project hierarchy overhaul
Diffstat (limited to 'src/helper/ioctl.cpp')
-rw-r--r--src/helper/ioctl.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/helper/ioctl.cpp b/src/helper/ioctl.cpp
new file mode 100644
index 0000000..21a1ccb
--- /dev/null
+++ b/src/helper/ioctl.cpp
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: MIT */
+
+#include "drm++/helper/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:
+ this->m_code = Error::BadFileDescriptor;
+ this->m_what = std::format(
+ "ioctl({}, 0x{:x}) failed: Invalid file descriptor",
+ this->m_fd, this->m_op
+ );
+ break;
+ case EINVAL:
+ case ENOTTY:
+ this->m_code = Error::InvalidArgument;
+ this->m_what = std::format(
+ "ioctl({}, 0x{:x}) failed: Invalid argument (errno {})",
+ this->m_fd, this->m_op, this->m_syserrno
+ );
+ break;
+ case ENOTSUP:
+ this->m_code = Error::NotSupported;
+ this->m_what = std::format(
+ "ioctl({}, 0x{:x}) failed: Operation not supported",
+ this->m_fd, this->m_op
+ );
+ break;
+ default:
+ this->m_code = Error::Other;
+ this->m_what = std::format(
+ "ioctl({}, 0x{:x}) failed: Unknown error (errno {})",
+ this->m_fd, this->m_op, this->m_syserrno
+ );
+ }
+}
+
+
+Exception::~Exception() = default;