mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 13:28:27 +00:00
tty: Factor out tty ioctls ENOTTY checking
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
5cfec27131
commit
12ebda3184
58
parasite.c
58
parasite.c
@ -452,6 +452,19 @@ out_send_fd:
|
||||
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)
|
||||
{
|
||||
int ret;
|
||||
@ -468,40 +481,25 @@ static int parasite_dump_tty(struct parasite_tty_args *args)
|
||||
# define TIOCGEXCL _IOR('T', 0x40, int)
|
||||
#endif
|
||||
|
||||
ret = sys_ioctl(args->fd, TIOCGSID, (unsigned long)&args->sid);
|
||||
if (ret < 0) {
|
||||
if (ret != -ENOTTY)
|
||||
goto err;
|
||||
args->sid = 0;
|
||||
}
|
||||
ret = tty_ioctl(args->fd, TIOCGSID, &args->sid);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
ret = sys_ioctl(args->fd, TIOCGPGRP, (unsigned long)&args->pgrp);
|
||||
if (ret < 0) {
|
||||
if (ret != -ENOTTY)
|
||||
goto err;
|
||||
args->pgrp = 0;
|
||||
}
|
||||
ret = tty_ioctl(args->fd, TIOCGPGRP, &args->pgrp);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
ret = sys_ioctl(args->fd, TIOCGPKT, (unsigned long)&args->st_pckt);
|
||||
if (ret < 0) {
|
||||
if (ret != -ENOTTY)
|
||||
goto err;
|
||||
args->st_pckt = 0;
|
||||
}
|
||||
ret = tty_ioctl(args->fd, TIOCGPKT, &args->st_pckt);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
ret = sys_ioctl(args->fd, TIOCGPTLCK, (unsigned long)&args->st_lock);
|
||||
if (ret < 0) {
|
||||
if (ret != -ENOTTY)
|
||||
goto err;
|
||||
args->st_lock = 0;
|
||||
}
|
||||
ret = tty_ioctl(args->fd, TIOCGPTLCK, &args->st_lock);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
ret = sys_ioctl(args->fd, TIOCGEXCL, (unsigned long)&args->st_excl);
|
||||
if (ret < 0) {
|
||||
if (ret != -ENOTTY)
|
||||
goto err;
|
||||
args->st_excl = 0;
|
||||
}
|
||||
ret = tty_ioctl(args->fd, TIOCGEXCL, &args->st_excl);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
args->hangup = false;
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user