Kernel: Make ioctl take unsigned long instead of int

this is what linux does :D

also fix one or two `return ioctl` instead of `return ioctl_impl`
This commit is contained in:
2026-07-07 03:11:16 +03:00
parent ea4e016b1e
commit eee0b7c3ff
24 changed files with 33 additions and 33 deletions

View File

@@ -38,7 +38,7 @@ namespace Kernel
BAN::ErrorOr<size_t> write_impl(off_t, BAN::ConstByteSpan) override;
BAN::ErrorOr<long> ioctl_impl(int cmd, void* arg) override;
BAN::ErrorOr<long> ioctl_impl(unsigned long request, void* arg) override;
protected:
ThreadBlocker m_sample_data_blocker;

View File

@@ -36,7 +36,7 @@ namespace Kernel
virtual BAN::ErrorOr<size_t> read_impl(off_t, BAN::ByteSpan) override;
virtual BAN::ErrorOr<size_t> write_impl(off_t, BAN::ConstByteSpan) override;
BAN::ErrorOr<long> ioctl_impl(int cmd, void* arg) override;
BAN::ErrorOr<long> ioctl_impl(unsigned long request, void* arg) override;
virtual bool can_read_impl() const override { return true; }
virtual bool can_write_impl() const override { return true; }

View File

@@ -150,7 +150,7 @@ namespace Kernel
bool has_error() const { return has_error_impl(); }
bool has_hungup() const { return has_hungup_impl(); }
BAN::ErrorOr<long> ioctl(int request, void* arg);
BAN::ErrorOr<long> ioctl(unsigned long request, void* arg);
BAN::ErrorOr<void> add_epoll(class Epoll*);
void del_epoll(class Epoll*);
@@ -199,7 +199,7 @@ namespace Kernel
virtual bool has_error_impl() const = 0;
virtual bool has_hungup_impl() const = 0;
virtual BAN::ErrorOr<long> ioctl_impl(int, void*) { return BAN::Error::from_errno(ENOTSUP); }
virtual BAN::ErrorOr<long> ioctl_impl(unsigned long, void*) { return BAN::Error::from_errno(ENOTSUP); }
protected:
// TODO: this is supposed to be const I guess?

View File

@@ -92,7 +92,7 @@ namespace Kernel
virtual BAN::ErrorOr<void> send_raw_bytes(BAN::Span<const BAN::ConstByteSpan> buffers) = 0;
private:
BAN::ErrorOr<long> ioctl_impl(int, void*) override;
BAN::ErrorOr<long> ioctl_impl(unsigned long, void*) override;
private:
const Type m_type;

View File

@@ -54,7 +54,7 @@ namespace Kernel
protected:
NetworkSocket(NetworkLayer&, const Socket::Info&);
virtual BAN::ErrorOr<long> ioctl_impl(int request, void* arg) override;
virtual BAN::ErrorOr<long> ioctl_impl(unsigned long request, void* arg) override;
virtual BAN::ErrorOr<void> getsockname_impl(sockaddr*, socklen_t*) override;
virtual BAN::ErrorOr<void> getpeername_impl(sockaddr*, socklen_t*) override = 0;

View File

@@ -66,7 +66,7 @@ namespace Kernel
BAN::ErrorOr<void> getsockopt_impl(int, int, void*, socklen_t*) override;
BAN::ErrorOr<void> setsockopt_impl(int, int, const void*, socklen_t) override;
BAN::ErrorOr<long> ioctl_impl(int, void*) override;
BAN::ErrorOr<long> ioctl_impl(unsigned long, void*) override;
void receive_packet(BAN::ConstByteSpan, const sockaddr* sender, socklen_t sender_len, uint32_t validated_cksums) override;

View File

@@ -41,7 +41,7 @@ namespace Kernel
BAN::ErrorOr<void> getsockopt_impl(int, int, void*, socklen_t*) override;
BAN::ErrorOr<void> setsockopt_impl(int, int, const void*, socklen_t) override;
BAN::ErrorOr<long> ioctl_impl(int, void*) override;
BAN::ErrorOr<long> ioctl_impl(unsigned long, void*) override;
bool can_read_impl() const override { return !m_packets.empty(); }
bool can_write_impl() const override { return true; }

View File

@@ -136,7 +136,7 @@ namespace Kernel
BAN::ErrorOr<long> sys_recvmsg(int socket, msghdr* message, int flags);
BAN::ErrorOr<long> sys_sendmsg(int socket, const msghdr* message, int flags);
BAN::ErrorOr<long> sys_ioctl(int fildes, int request, void* arg);
BAN::ErrorOr<long> sys_ioctl(int fildes, unsigned long request, void* arg);
BAN::ErrorOr<long> sys_pselect(sys_pselect_t* arguments);
BAN::ErrorOr<long> sys_ppoll(pollfd* fds, nfds_t nfds, const timespec* tmp_p, const sigset_t* sigmask);

View File

@@ -32,7 +32,7 @@ namespace Kernel
void on_close(int) override;
BAN::ErrorOr<long> ioctl_impl(int, void*) override;
BAN::ErrorOr<long> ioctl_impl(unsigned long, void*) override;
private:
PseudoTerminalMaster(BAN::UniqPtr<VirtualRange>, mode_t, uid_t, gid_t);

View File

@@ -68,7 +68,7 @@ namespace Kernel
virtual bool has_error_impl() const override { return false; }
virtual bool has_hungup_impl() const override { return false; }
virtual BAN::ErrorOr<long> ioctl_impl(int, void*) override;
virtual BAN::ErrorOr<long> ioctl_impl(unsigned long, void*) override;
private:
bool putchar(uint8_t ch);

View File

@@ -34,7 +34,7 @@ namespace Kernel
BAN::ErrorOr<size_t> read_impl(off_t, BAN::ByteSpan) override;
bool can_read_impl() const override { return true; }
BAN::ErrorOr<long> ioctl_impl(int request, void* arg) override;
BAN::ErrorOr<long> ioctl_impl(unsigned long request, void* arg) override;
private:
USBJoystick(USBHIDDriver&);

View File

@@ -77,9 +77,9 @@ namespace Kernel
return to_copy;
}
BAN::ErrorOr<long> AudioController::ioctl_impl(int cmd, void* arg)
BAN::ErrorOr<long> AudioController::ioctl_impl(unsigned long request, void* arg)
{
switch (cmd)
switch (request)
{
case SND_GET_CHANNELS:
*static_cast<uint32_t*>(arg) = get_channels();
@@ -92,7 +92,7 @@ namespace Kernel
{
SpinLockGuard _(m_spinlock);
*static_cast<uint32_t*>(arg) = m_sample_data->size();
if (cmd == SND_RESET_BUFFER)
if (request == SND_RESET_BUFFER)
m_sample_data->pop(m_sample_data->size());
return 0;
}
@@ -113,7 +113,7 @@ namespace Kernel
return 0;
}
return CharacterDevice::ioctl_impl(cmd, arg);
return CharacterDevice::ioctl_impl(request, arg);
}
}

View File

@@ -135,9 +135,9 @@ namespace Kernel
return bytes_to_copy;
}
BAN::ErrorOr<long> FramebufferDevice::ioctl_impl(int cmd, void* arg)
BAN::ErrorOr<long> FramebufferDevice::ioctl_impl(unsigned long request, void* arg)
{
switch (cmd)
switch (request)
{
case FB_MSYNC_RECTANGLE:
{
@@ -152,7 +152,7 @@ namespace Kernel
}
}
return CharacterDevice::ioctl(cmd, arg);
return CharacterDevice::ioctl_impl(request, arg);
}
uint32_t FramebufferDevice::get_pixel(uint32_t x, uint32_t y) const

View File

@@ -316,7 +316,7 @@ namespace Kernel
return {};
}
BAN::ErrorOr<long> Inode::ioctl(int request, void* arg)
BAN::ErrorOr<long> Inode::ioctl(unsigned long request, void* arg)
{
auto ret = ioctl_impl(request, arg);
if (!ret.is_error() || ret.error().get_error_code() != ENOTSUP)

View File

@@ -45,7 +45,7 @@ namespace Kernel
}
}
BAN::ErrorOr<long> NetworkInterface::ioctl_impl(int request, void* arg)
BAN::ErrorOr<long> NetworkInterface::ioctl_impl(unsigned long request, void* arg)
{
if (arg == nullptr)
{

View File

@@ -108,7 +108,7 @@ namespace Kernel
m_address_len = addr_len;
}
BAN::ErrorOr<long> NetworkSocket::ioctl_impl(int request, void* arg)
BAN::ErrorOr<long> NetworkSocket::ioctl_impl(unsigned long request, void* arg)
{
switch (request)
{

View File

@@ -402,7 +402,7 @@ namespace Kernel
return {};
}
BAN::ErrorOr<long> TCPSocket::ioctl_impl(int request, void* argument)
BAN::ErrorOr<long> TCPSocket::ioctl_impl(unsigned long request, void* argument)
{
switch (request)
{

View File

@@ -336,7 +336,7 @@ namespace Kernel
return {};
}
BAN::ErrorOr<long> UDPSocket::ioctl_impl(int request, void* argument)
BAN::ErrorOr<long> UDPSocket::ioctl_impl(unsigned long request, void* argument)
{
switch (request)
{

View File

@@ -2043,7 +2043,7 @@ namespace Kernel
return TRY(m_open_file_descriptors.sendmsg(socket, message, flags));
}
BAN::ErrorOr<long> Process::sys_ioctl(int fildes, int request, void* arg)
BAN::ErrorOr<long> Process::sys_ioctl(int fildes, unsigned long request, void* arg)
{
auto inode = TRY(m_open_file_descriptors.inode_of(fildes));
return TRY(inode->ioctl(request, arg));

View File

@@ -157,7 +157,7 @@ namespace Kernel
slave->m_write_blocker.unblock();
}
BAN::ErrorOr<long> PseudoTerminalMaster::ioctl_impl(int request, void* argument)
BAN::ErrorOr<long> PseudoTerminalMaster::ioctl_impl(unsigned long request, void* argument)
{
switch (request)
{
@@ -174,7 +174,7 @@ namespace Kernel
return BAN::Error::from_errno(ENODEV);
}
return CharacterDevice::ioctl(request, argument);
return CharacterDevice::ioctl_impl(request, argument);
}
PseudoTerminalSlave::PseudoTerminalSlave(BAN::String&& name, uint32_t number, mode_t mode, uid_t uid, gid_t gid)

View File

@@ -133,7 +133,7 @@ namespace Kernel
(void)Process::kill(-m_foreground_pgrp, SIGWINCH);
}
BAN::ErrorOr<long> TTY::ioctl_impl(int request, void* argument)
BAN::ErrorOr<long> TTY::ioctl_impl(unsigned long request, void* argument)
{
switch (request)
{
@@ -204,7 +204,7 @@ namespace Kernel
}
}
return CharacterDevice::ioctl(request, argument);
return CharacterDevice::ioctl_impl(request, argument);
}
void TTY::on_key_event(LibInput::RawKeyEvent event)

View File

@@ -185,7 +185,7 @@ namespace Kernel
return to_copy;
}
BAN::ErrorOr<long> USBJoystick::ioctl_impl(int request, void* arg)
BAN::ErrorOr<long> USBJoystick::ioctl_impl(unsigned long request, void* arg)
{
switch (request)
{
@@ -217,7 +217,7 @@ namespace Kernel
ASSERT_NOT_REACHED();
}
return USBHIDDevice::ioctl(request, arg);
return USBHIDDevice::ioctl_impl(request, arg);
}
void USBJoystick::update()

View File

@@ -82,7 +82,7 @@ struct fb_msync_region
};
#define FB_MSYNC_RECTANGLE 90 /* msync a rectangular area in mmap'd framebuffer device */
int ioctl(int, int, ...);
int ioctl(int, unsigned long, ...);
__END_DECLS

View File

@@ -3,7 +3,7 @@
#include <sys/syscall.h>
#include <unistd.h>
int ioctl(int fildes, int request, ...)
int ioctl(int fildes, unsigned long request, ...)
{
va_list args;
va_start(args, request);