2
0
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:
Pavel Emelyanov 2012-10-30 21:06:43 +03:00
parent 5cfec27131
commit 12ebda3184

View File

@ -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)
# 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;