mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 14:14:45 +03:00
Kernel: Remove KDSETMODE and KDGETMODE ioctl options from the TTY class
These options are not relevant and are actually meaningless on pure TTY devices, as they are meant to be effective only for the VirtualConsole devices. This also removes the virtual marking from two methods because they're no longer declared in the TTY class as well.
This commit is contained in:
parent
258af88b29
commit
4177e6be8b
Notes:
sideshowbarker
2024-07-17 07:06:47 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/4177e6be8b Pull-request: https://github.com/SerenityOS/serenity/pull/20768 Reviewed-by: https://github.com/BertalanD Reviewed-by: https://github.com/petelliott ✅ Reviewed-by: https://github.com/timschumi ✅
@ -562,19 +562,6 @@ ErrorOr<void> TTY::ioctl(OpenFileDescription&, unsigned request, Userspace<void*
|
||||
case TIOCNOTTY:
|
||||
current_process.set_tty(nullptr);
|
||||
return {};
|
||||
case KDSETMODE: {
|
||||
auto mode = static_cast<unsigned int>(arg.ptr());
|
||||
if (mode != KD_TEXT && mode != KD_GRAPHICS)
|
||||
return EINVAL;
|
||||
|
||||
set_graphical(mode == KD_GRAPHICS);
|
||||
return {};
|
||||
}
|
||||
case KDGETMODE: {
|
||||
auto mode_ptr = static_ptr_cast<int*>(arg);
|
||||
int mode = (is_graphical()) ? KD_GRAPHICS : KD_TEXT;
|
||||
return copy_to_user(mode_ptr, &mode);
|
||||
}
|
||||
}
|
||||
return EINVAL;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override;
|
||||
virtual bool can_read(OpenFileDescription const&, u64) const override;
|
||||
virtual bool can_write(OpenFileDescription const&, u64) const override;
|
||||
virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg) override final;
|
||||
virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg) override;
|
||||
|
||||
unsigned short rows() const { return m_rows; }
|
||||
unsigned short columns() const { return m_columns; }
|
||||
@ -48,9 +48,6 @@ public:
|
||||
|
||||
virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_name() const = 0;
|
||||
|
||||
virtual bool is_graphical() const { return false; }
|
||||
virtual void set_graphical(bool) { }
|
||||
|
||||
protected:
|
||||
virtual ErrorOr<size_t> on_tty_write(UserOrKernelBuffer const&, size_t) = 0;
|
||||
void set_size(unsigned short columns, unsigned short rows);
|
||||
|
@ -194,6 +194,27 @@ UNMAP_AFTER_INIT VirtualConsole::~VirtualConsole()
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
ErrorOr<void> VirtualConsole::ioctl(OpenFileDescription& description, unsigned request, Userspace<void*> arg)
|
||||
{
|
||||
TRY(Process::current().require_promise(Pledge::tty));
|
||||
switch (request) {
|
||||
case KDSETMODE: {
|
||||
auto mode = static_cast<unsigned int>(arg.ptr());
|
||||
if (mode != KD_TEXT && mode != KD_GRAPHICS)
|
||||
return EINVAL;
|
||||
|
||||
set_graphical(mode == KD_GRAPHICS);
|
||||
return {};
|
||||
}
|
||||
case KDGETMODE: {
|
||||
auto mode_ptr = static_ptr_cast<int*>(arg);
|
||||
int mode = (is_graphical()) ? KD_GRAPHICS : KD_TEXT;
|
||||
return copy_to_user(mode_ptr, &mode);
|
||||
}
|
||||
}
|
||||
return TTY::ioctl(description, request, arg);
|
||||
}
|
||||
|
||||
static inline Graphics::Console::Color ansi_color_to_standard_vga_color(VT::Color::ANSIColor color)
|
||||
{
|
||||
switch (color) {
|
||||
|
@ -77,9 +77,8 @@ public:
|
||||
|
||||
void refresh_after_resolution_change();
|
||||
|
||||
// ^TTY
|
||||
virtual bool is_graphical() const override { return m_graphical; }
|
||||
virtual void set_graphical(bool graphical) override;
|
||||
bool is_graphical() const { return m_graphical; }
|
||||
void set_graphical(bool graphical);
|
||||
|
||||
void emit_char(char);
|
||||
|
||||
@ -91,6 +90,7 @@ private:
|
||||
// ^TTY
|
||||
virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_name() const override;
|
||||
virtual ErrorOr<size_t> on_tty_write(UserOrKernelBuffer const&, size_t) override;
|
||||
virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg) override;
|
||||
virtual void echo(u8) override;
|
||||
|
||||
// ^TerminalClient
|
||||
|
Loading…
Reference in New Issue
Block a user