Commit 12ebda31 authored by Pavel Emelyanov's avatar Pavel Emelyanov

tty: Factor out tty ioctls ENOTTY checking

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 5cfec271
...@@ -452,6 +452,19 @@ out_send_fd: ...@@ -452,6 +452,19 @@ out_send_fd:
return ret; return ret;
} }
static inline int tty_ioctl(int fd, int cmd, int *arg)
{
int ret;
ret = sys_ioctl(fd, cmd, (unsigned long)arg);
if (ret < 0) {
if (ret != -ENOTTY)
return -1;
*arg = 0;
}
return 0;
}
static int parasite_dump_tty(struct parasite_tty_args *args) static int parasite_dump_tty(struct parasite_tty_args *args)
{ {
int ret; int ret;
...@@ -468,40 +481,25 @@ static int parasite_dump_tty(struct parasite_tty_args *args) ...@@ -468,40 +481,25 @@ static int parasite_dump_tty(struct parasite_tty_args *args)
# define TIOCGEXCL _IOR('T', 0x40, int) # define TIOCGEXCL _IOR('T', 0x40, int)
#endif #endif
ret = sys_ioctl(args->fd, TIOCGSID, (unsigned long)&args->sid); ret = tty_ioctl(args->fd, TIOCGSID, &args->sid);
if (ret < 0) { if (ret < 0)
if (ret != -ENOTTY) goto err;
goto err;
args->sid = 0;
}
ret = sys_ioctl(args->fd, TIOCGPGRP, (unsigned long)&args->pgrp); ret = tty_ioctl(args->fd, TIOCGPGRP, &args->pgrp);
if (ret < 0) { if (ret < 0)
if (ret != -ENOTTY) goto err;
goto err;
args->pgrp = 0;
}
ret = sys_ioctl(args->fd, TIOCGPKT, (unsigned long)&args->st_pckt); ret = tty_ioctl(args->fd, TIOCGPKT, &args->st_pckt);
if (ret < 0) { if (ret < 0)
if (ret != -ENOTTY) goto err;
goto err;
args->st_pckt = 0;
}
ret = sys_ioctl(args->fd, TIOCGPTLCK, (unsigned long)&args->st_lock); ret = tty_ioctl(args->fd, TIOCGPTLCK, &args->st_lock);
if (ret < 0) { if (ret < 0)
if (ret != -ENOTTY) goto err;
goto err;
args->st_lock = 0;
}
ret = sys_ioctl(args->fd, TIOCGEXCL, (unsigned long)&args->st_excl); ret = tty_ioctl(args->fd, TIOCGEXCL, &args->st_excl);
if (ret < 0) { if (ret < 0)
if (ret != -ENOTTY) goto err;
goto err;
args->st_excl = 0;
}
args->hangup = false; args->hangup = false;
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment