summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-03-06 19:21:57 +0100
committerDavid Herrmann <dh.herrmann@gmail.com>2013-03-06 19:21:57 +0100
commite1344b5691e56167176e8c0c6d4d2081ddb765e2 (patch)
tree25b1458e525d1a15e1e214912d31a0eedae67037 /src
parentfb08eea3737907bbbc11c0a14427efe116fae92e (diff)
uvtd: vt: return -ENODEV if session died
We now keep a link to our parent seat and set it to NULL when our session is unregistered. In this case, any further request that depends on the session being registered and probably a valid seat pointer, we will stop with ENODEV. Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/uvtd_vt.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/uvtd_vt.c b/src/uvtd_vt.c
index cc121a0..50eac8e 100644
--- a/src/uvtd_vt.c
+++ b/src/uvtd_vt.c
@@ -52,6 +52,7 @@ struct uvtd_vt {
struct uvt_ctx *uctx;
struct shl_hook *hook;
struct uvtd_session *session;
+ struct uvtd_seat *seat;
bool is_legacy;
unsigned int mode;
@@ -78,6 +79,7 @@ static int vt_session_event(struct uvtd_session *session, unsigned int event,
switch (event) {
case UVTD_SESSION_UNREGISTER:
vt->session = NULL;
+ vt->seat = NULL;
vt_hup(vt);
break;
case UVTD_SESSION_ACTIVATE:
@@ -107,6 +109,7 @@ int uvtd_vt_new(struct uvtd_vt **out, struct uvt_ctx *uctx, unsigned int id,
memset(vt, 0, sizeof(*vt));
vt->ref = 1;
vt->uctx = uctx;
+ vt->seat = seat;
vt->is_legacy = is_legacy;
vt->mode = KD_TEXT;
vt->kbmode = K_UNICODE;
@@ -169,16 +172,25 @@ void uvtd_vt_unregister_cb(struct uvtd_vt *vt, uvt_vt_cb cb, void *data)
int uvtd_vt_read(struct uvtd_vt *vt, uint8_t *mem, size_t len)
{
+ if (!vt || !vt->seat)
+ return -ENODEV;
+
return -EAGAIN;
}
int uvtd_vt_write(struct uvtd_vt *vt, const uint8_t *mem, size_t len)
{
+ if (!vt || !vt->seat)
+ return -ENODEV;
+
return len;
}
unsigned int uvtd_vt_poll(struct uvtd_vt *vt)
{
+ if (!vt || !vt->seat)
+ return UVT_TTY_HUP | UVT_TTY_READ | UVT_TTY_WRITE;
+
return UVT_TTY_WRITE;
}
@@ -198,21 +210,41 @@ static int vt_ioctl_TCFLSH(void *data, unsigned long arg)
static int vt_ioctl_VT_ACTIVATE(void *data, unsigned long arg)
{
+ struct uvtd_vt *vt = data;
+
+ if (!vt->seat)
+ return -ENODEV;
+
return -EINVAL;
}
static int vt_ioctl_VT_WAITACTIVE(void *data, unsigned long arg)
{
+ struct uvtd_vt *vt = data;
+
+ if (!vt->seat)
+ return -ENODEV;
+
return -EINVAL;
}
static int vt_ioctl_VT_GETSTATE(void *data, struct vt_stat *arg)
{
+ struct uvtd_vt *vt = data;
+
+ if (!vt->seat)
+ return -ENODEV;
+
return -EINVAL;
}
static int vt_ioctl_VT_OPENQRY(void *data, unsigned int *arg)
{
+ struct uvtd_vt *vt = data;
+
+ if (!vt->seat)
+ return -ENODEV;
+
return -EINVAL;
}
@@ -259,6 +291,11 @@ static int vt_ioctl_VT_SETMODE(void *data, const struct vt_mode *arg,
static int vt_ioctl_VT_RELDISP(void *data, unsigned long arg)
{
+ struct uvtd_vt *vt = data;
+
+ if (!vt->seat)
+ return -ENODEV;
+
return -EINVAL;
}