summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-03-06 17:33:39 +0100
committerDavid Herrmann <dh.herrmann@gmail.com>2013-03-06 17:33:39 +0100
commit5c7184f79790f47dcb4dd4d665949a40bcec4ee6 (patch)
treeb27a342f474b2c39b1eb60e6a48b49fd48b7a679 /src
parent724afe8c1af296d93d9640d50284125056d1fce1 (diff)
uvtd: vt: implement ioctl dummies
Add dummies for the ioctl VT callbacks. Also implement the KD-MODE and KB-MODE state tracking as it is fairly trivial. Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/uvtd_vt.c131
1 files changed, 131 insertions, 0 deletions
diff --git a/src/uvtd_vt.c b/src/uvtd_vt.c
index 78ba70e..18e4503 100644
--- a/src/uvtd_vt.c
+++ b/src/uvtd_vt.c
@@ -31,8 +31,13 @@
#include <errno.h>
#include <inttypes.h>
+#include <linux/kd.h>
+#include <linux/vt.h>
#include <stdlib.h>
#include <string.h>
+#include <termio.h>
+#include <termios.h>
+#include <unistd.h>
#include "shl_hook.h"
#include "shl_log.h"
#include "uvt.h"
@@ -47,6 +52,9 @@ struct uvtd_vt {
struct shl_hook *hook;
struct uvtd_session *session;
bool is_legacy;
+
+ unsigned int mode;
+ unsigned int kbmode;
};
static void vt_hup(struct uvtd_vt *vt)
@@ -97,6 +105,8 @@ int uvtd_vt_new(struct uvtd_vt **out, struct uvt_ctx *uctx, unsigned int id,
vt->ref = 1;
vt->uctx = uctx;
vt->is_legacy = is_legacy;
+ vt->mode = KD_TEXT;
+ vt->kbmode = K_UNICODE;
ret = shl_hook_new(&vt->hook);
if (ret)
@@ -168,6 +178,113 @@ unsigned int uvtd_vt_poll(struct uvtd_vt *vt)
return UVT_TTY_WRITE;
}
+static int vt_ioctl_TCFLSH(void *data, unsigned long arg)
+{
+ switch (arg) {
+ case TCIFLUSH:
+ case TCOFLUSH:
+ case TCIOFLUSH:
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int vt_ioctl_VT_ACTIVATE(void *data, unsigned long arg)
+{
+ return -EINVAL;
+}
+
+static int vt_ioctl_VT_WAITACTIVE(void *data, unsigned long arg)
+{
+ return -EINVAL;
+}
+
+static int vt_ioctl_VT_GETSTATE(void *data, struct vt_stat *arg)
+{
+ return -EINVAL;
+}
+
+static int vt_ioctl_VT_OPENQRY(void *data, unsigned int *arg)
+{
+ return -EINVAL;
+}
+
+static int vt_ioctl_VT_GETMODE(void *data, struct vt_mode *arg)
+{
+ return -EINVAL;
+}
+
+static int vt_ioctl_VT_SETMODE(void *data, const struct vt_mode *arg)
+{
+ return -EINVAL;
+}
+
+static int vt_ioctl_VT_RELDISP(void *data, unsigned long arg)
+{
+ return -EINVAL;
+}
+
+static int vt_ioctl_KDGETMODE(void *data, unsigned int *arg)
+{
+ struct uvtd_vt *vt = data;
+
+ *arg = vt->mode;
+ return 0;
+}
+
+static int vt_ioctl_KDSETMODE(void *data, unsigned int arg)
+{
+ struct uvtd_vt *vt = data;
+
+ switch (arg) {
+ case KD_TEXT0:
+ case KD_TEXT1:
+ arg = KD_TEXT;
+ /* fallthrough */
+ case KD_TEXT:
+ case KD_GRAPHICS:
+ vt->mode = arg;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int vt_ioctl_KDGKBMODE(void *data, unsigned int *arg)
+{
+ struct uvtd_vt *vt = data;
+
+ *arg = vt->kbmode;
+ return 0;
+}
+
+static int vt_ioctl_KDSKBMODE(void *data, unsigned int arg)
+{
+ struct uvtd_vt *vt = data;
+
+ switch (arg) {
+ case K_RAW:
+ /* TODO: what does K_RAW do? */
+ case K_UNICODE:
+ case K_OFF:
+ vt->kbmode = arg;
+ break;
+ case K_XLATE:
+ case K_MEDIUMRAW:
+ /* TODO: do we need these? */
+ return -EOPNOTSUPP;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
/* compatibility to UVT-VT ops */
static void vt_ref(void *vt)
@@ -213,4 +330,18 @@ struct uvt_vt_ops uvtd_vt_ops = {
.read = vt_read,
.write = vt_write,
.poll = vt_poll,
+
+ .ioctl_TCFLSH = vt_ioctl_TCFLSH,
+
+ .ioctl_VT_ACTIVATE = vt_ioctl_VT_ACTIVATE,
+ .ioctl_VT_WAITACTIVE = vt_ioctl_VT_WAITACTIVE,
+ .ioctl_VT_GETSTATE = vt_ioctl_VT_GETSTATE,
+ .ioctl_VT_OPENQRY = vt_ioctl_VT_OPENQRY,
+ .ioctl_VT_GETMODE = vt_ioctl_VT_GETMODE,
+ .ioctl_VT_SETMODE = vt_ioctl_VT_SETMODE,
+ .ioctl_VT_RELDISP = vt_ioctl_VT_RELDISP,
+ .ioctl_KDGETMODE = vt_ioctl_KDGETMODE,
+ .ioctl_KDSETMODE = vt_ioctl_KDSETMODE,
+ .ioctl_KDGKBMODE = vt_ioctl_KDGKBMODE,
+ .ioctl_KDSKBMODE = vt_ioctl_KDSKBMODE,
};