Skip to content

Commit 3aca0ef

Browse files
committed
Add TIOCGICOUNT ioctl.
1 parent 04fc08f commit 3aca0ef

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

src/kernel_abi.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,22 @@ struct BaseArch : public wordsize,
782782
};
783783
RR_VERIFY_TYPE(serial_struct);
784784

785+
struct serial_icounter_struct {
786+
int cts;
787+
int dsr;
788+
int rng;
789+
int dcd;
790+
int rx;
791+
int tx;
792+
int frame;
793+
int overrun;
794+
int parity;
795+
int brk;
796+
int buf_overrun;
797+
int reserved[9];
798+
};
799+
RR_VERIFY_TYPE(serial_icounter_struct);
800+
785801
struct winsize {
786802
unsigned_short ws_row;
787803
unsigned_short ws_col;

src/record_syscall.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,6 +1853,10 @@ static Switchable prepare_ioctl(RecordTask* t,
18531853
case TIOCSSERIAL:
18541854
return PREVENT_SWITCH;
18551855

1856+
case TIOCGICOUNT:
1857+
syscall_state.reg_parameter<typename Arch::serial_icounter_struct>(3);
1858+
return PREVENT_SWITCH;
1859+
18561860
case SNDRV_CTL_IOCTL_PVERSION:
18571861
syscall_state.reg_parameter<int>(3);
18581862
return PREVENT_SWITCH;

src/test/ioctl_ttyS.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
/* -*- Mode: C; tab-width: 8; c-basic-offset: 2; indent-tabs-mode: nil; -*- */
22

33
#include "util.h"
4+
#include <linux/serial.h>
45

56
int main(void) {
67
int fd;
78
int* mbits;
9+
struct serial_icounter_struct* sicnt;
810

911
fd = open("/dev/ttyS0", O_RDWR);
1012
if (fd < 0) {
@@ -20,6 +22,13 @@ int main(void) {
2022
test_assert(0 == ioctl(fd, TIOCMSET, mbits));
2123
atomic_printf("TIOCMSET mbits=0x%x afterwards\n", *mbits);
2224

25+
ALLOCATE_GUARD(sicnt, 'b');
26+
test_assert(0 == ioctl(fd, TIOCGICOUNT, sicnt));
27+
VERIFY_GUARD(sicnt);
28+
atomic_printf("TIOCGICOUNT returned %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
29+
sicnt->cts, sicnt->dsr, sicnt->rng, sicnt->dcd, sicnt->rx, sicnt->tx,
30+
sicnt->frame, sicnt->overrun, sicnt->parity, sicnt->brk, sicnt->buf_overrun);
31+
2332
atomic_puts("EXIT-SUCCESS");
2433
return 0;
2534
}

0 commit comments

Comments
 (0)