Excerpt from Frank's June 28, 2011 on subject
struc termios
alignb 4
.c_iflag: resd 1 ; input mode flags
.c_oflag: resd 1 ; output mode flags
.c_cflag: resd 1 ; control mode flags
.c_lflag: resd 1 ; local mode flags
.c_line: resb 1 ; line discipline
.c_cc: resb 19 ; control characters
endstruc
Which is 36 bytes in length. From same thread
mov eax, SYS_IOCTL ; get current mode
mov ebx, STDIN
mov ecx, TCGETS
lea edx, [ebp - termios_size]
int 80h
and my 64 bit version
xor rax, rax
mov rdi, rax
mov rdi, SYS_READ
mov rsi, rax
mov esi, TCGETS
mov rdx, rsp
mov al, SYS_IOCTL
syscall
and I have in fact verified that even in 64 bit mode versus int80, 36 bytes of stack where populated with data.
This little tidbit though, extracted from /usr/include/x86_64/bits/termios.h tells a very different story in so much as this structure is 60 bytes.
#include <iostream>
using namespace std;
typedef unsigned char cc_t;
typedef unsigned int speed_t;
typedef unsigned int tcflag_t;
#define NCCS 32
struct termios
{
tcflag_t c_iflag; /* input mode flags */
tcflag_t c_oflag; /* output mode flags */
tcflag_t c_cflag; /* control mode flags */
tcflag_t c_lflag; /* local mode flags */
cc_t c_line; /* line discipline */
cc_t c_cc[NCCS]; /* control characters */
speed_t c_ispeed; /* input speed */
speed_t c_ospeed; /* output speed */
};
int main () {
cout << sizeof (termios) << endl;
return 0;
}
My question is, am I going to be ok doing it with syscall and logically assuming for backward compatibility the structure is 36 bytes