feat: implement readlink(2) readlinkat(2)
[lunaix-os.git] / lunaix-os / kernel / lxconsole.c
index 0a2d449a1ad291df6a22fbeda1528a316ec1fa27..894a1b8e9837d636bbca6bf1a65355000b5316c4 100644 (file)
@@ -1,4 +1,5 @@
 #include <klibc/string.h>
+#include <lunaix/device.h>
 #include <lunaix/lxconsole.h>
 #include <lunaix/mm/pmm.h>
 #include <lunaix/mm/vmm.h>
@@ -7,6 +8,12 @@
 
 static struct console lx_console;
 
+int
+__tty_write(struct device* dev,
+            void* buf,
+            unsigned int offset,
+            unsigned int len);
+
 void
 lxconsole_init()
 {
@@ -28,6 +35,19 @@ lxconsole_init()
     memset(lx_console.buffer.data, 0, lx_console.buffer.size);
 
     lx_console.flush_timer = NULL;
+
+    struct device* tty_dev = device_add(NULL, &lx_console, "tty");
+    tty_dev->write = __tty_write;
+}
+
+int
+__tty_write(struct device* dev,
+            void* buf,
+            unsigned int offset,
+            unsigned int len)
+{
+    struct console* console = (struct console*)dev->underlay;
+    console_write(console, buf, len);
 }
 
 void
@@ -80,7 +100,7 @@ console_view_down()
 }
 
 void
-console_flush(void* arg)
+console_flush()
 {
     if (mutex_on_hold(&lx_console.buffer.lock)) {
         return;