Add exclusive mode ioctls

This commit is contained in:
Kim Woelders
2018-07-17 15:41:04 +02:00
parent 2c3441dda5
commit a68edc5e57
+27 -1
View File
@@ -46,7 +46,7 @@ static struct ttynvt_param {
int foreground;
} ttynvt_param;
typedef struct ttynvt {
typedef struct {
int nonblock;
pthread_mutex_t tty_lock;
pthread_mutex_t poll_lock;
@@ -60,6 +60,7 @@ typedef struct ttynvt {
struct termios tio;
unsigned char mcr;
char excl;
char buf[RX_BUF_SIZE];
size_t blen;
@@ -556,6 +557,10 @@ static const char *_ioctl_name(int cmd)
CASE(TIOCMSET);
CASE(TCSBRK);
CASE(TIOCGWINSZ);
/* Exclusive mode */
CASE(TIOCEXCL);
CASE(TIOCGEXCL);
CASE(TIOCNXCL);
}
}
@@ -758,6 +763,27 @@ ttynvt_ioctl(fuse_req_t req, int cmd, void *arg,
}
break;
case TIOCEXCL:
if (tty->excl)
{
fuse_reply_err(req, EBUSY);
}
else
{
tty->excl = 1;
fuse_reply_ioctl(req, 0, 0, 0);
}
break;
case TIOCGEXCL:
CHECK_BUF_OUT(sizeof(int));
val = tty->excl;
fuse_reply_ioctl(req, 0, &val, sizeof(int));
break;
case TIOCNXCL:
tty->excl = 0;
fuse_reply_ioctl(req, 0, 0, 0);
break;
default:
fuse_reply_err(req, ENOSYS);
break;