|                                                                                                        |
Copyright © h-peter recktenwald, berlin, 2000 - Free for non-commercial use.
Lynx (etc) text mode tables arranged to 132 chars/line -
where if properly adjusted the tables appear most "readable"...
=> lynx

[intro] [a:index] [s:index] [#:index]
[1..64] [65..128] [129..192] [193..256] [257..] [ref] [struc] [fcntl] [ioctl] [pguide] [man2]
[next] [back] [linux] [main] [bot] [top]
Syscalls pages archive (110K->1M), updated (2.3.0, ver. 1.66) man 2 pages (170K->1,2M)

content



 

// include/linux/eventpoll.h, epoll event data array
		struct epoll_event {
		        __u32 events;		// epoll events
		        __u64 data;		// user data variable
		};

		// opcodes to issue to sys_epoll_ctl()
		EPOLL_CTL_ADD	1		// add a file decriptor to the interface
		EPOLL_CTL_DEL	2		// remove a file decriptor from the interface
		EPOLL_CTL_MOD	3		// change file decriptor epoll_event structure

		// epoll events, from glibc-2.3.2 source, sysdeps/unix/sysv/linux/sys/epoll.h
		EPOLLIN		0x001
		EPOLLPRI	0x002
		EPOLLOUT	0x004
		EPOLLRDNORM	0x040
		EPOLLRDBAND	0x080
		EPOLLWRNORM	0x100
		EPOLLWRBAND	0x200
		EPOLLMSG	0x400
		EPOLLERR	0x008
		EPOLLHUP	0x010

		typedef union epoll_data
		{
		  void *ptr;
		  int fd;
		  uint32_t u32;
		  uint64_t u64;
		} epoll_data_t;

		struct epoll_event
		{
		  uint32_t events;		// Epoll events
		  epoll_data_t data;		// User data variable
		};

 

// include/asm-i386/mman.h, mmap and madvise syscalls groups flags
		PROT_READ       0x1             // page can be read
		PROT_WRITE      0x2             // page can be written
		PROT_EXEC       0x4             // page can be executed
		PROT_SEM        0x8             // page may be used for atomic ops
		PROT_NONE       0x0             // page can not be accessed
		PROT_GROWSDOWN  0x01000000      // mprotect flag: extend change to start of growsdown vma
		PROT_GROWSUP    0x02000000      // mprotect flag: extend change to end of growsup vma

		MAP_SHARED      0x01            // Share changes
		MAP_PRIVATE     0x02            // Changes are private
		MAP_TYPE        0x0f            // Mask for type of mapping
		MAP_FIXED       0x10            // Interpret addr exactly
		MAP_ANONYMOUS   0x20            // don't use a file

		MAP_GROWSDOWN   0x0100          // stack-like segment
		MAP_DENYWRITE   0x0800          // ETXTBSY
		MAP_EXECUTABLE  0x1000          // mark it as an executable
		MAP_LOCKED      0x2000          // pages are locked
		MAP_NORESERVE   0x4000          // don't check for reservations
		MAP_POPULATE    0x8000          // populate (prefault) pagetables
		MAP_NONBLOCK    0x10000         // do not block on IO

		MS_ASYNC        1               // sync memory asynchronously
		MS_INVALIDATE   2               // invalidate the caches
		MS_SYNC         4               // synchronous memory sync

		MCL_CURRENT     1               // lock all current mappings
		MCL_FUTURE      2               // lock all future mappings

		MADV_NORMAL     0x0             // default page-in behavior
		MADV_RANDOM     0x1             // page-in minimum required
		MADV_SEQUENTIAL 0x2             // read-ahead aggressively
		MADV_WILLNEED   0x3             // pre-fault pages
		MADV_DONTNEED   0x4             // discard these pages

						// compatibility flags
		MAP_ANON        MAP_ANONYMOUS
		MAP_FILE        0

 

// include/aio_abi.h
		typedef unsigned long   aio_context_t;

		// read() from /dev/aio returns these structures:
		
		struct io_event {
			__u64	data;		// the data field from the iocb
			__u64	obj;		// what iocb this event came from
			__s64	res;		// result code for this event
			__s64	res2;		// secondary result
		};

		// Kernel comment:
		//	"we always use a 64bit off_t when communicating with userland. 
		//	"its up to libraries to do the proper padding and aio_error abstraction


		struct iocb {
		    // internal to the kernel/libc.
			__u64	aio_data;	// data to be returned in data of the 'event'
			__u32	PADDED(aio_key, aio_reserved1);	// kernel sets aio_key to req #

		    // common fields
			__u16	aio_lio_opcode;	// re IOCB_CMD_xx
			__s16	aio_reqprio;
			__u32	aio_fildes;

			__u64	aio_buf;
			__u64	aio_nbytes;
			__s64	aio_offset;

		    // extra parameters
			__u64	aio_reserved2;
			__u64	aio_reserved3;
		};  // 64 bytes

		enum {
			IOCB_CMD_PREAD = 0,
			IOCB_CMD_PWRITE = 1,
			IOCB_CMD_FSYNC = 2,
			IOCB_CMD_FDSYNC = 3,
			IOCB_CMD_PREADX = 4,	// experimental
			IOCB_CMD_POLL = 5,	// experimental
			IOCB_CMD_NOOP = 6,
		};

 

// include/asm/ldt.h
		// Maximum number of LDT entries supported.
		#define LDT_ENTRIES     8192
		// The size of each LDT entry.
		#define LDT_ENTRY_SIZE  8

		struct user_desc {
		    unsigned int  entry_number;
		    unsigned long base_addr;
		    unsigned int  limit;
		    unsigned int  seg_32bit:1;
		    unsigned int  contents:2;
		    unsigned int  read_exec_only:1;
		    unsigned int  limit_in_pages:1;
		    unsigned int  seg_not_present:1;
		    unsigned int  useable:1;
		};
			
		#define MODIFY_LDT_CONTENTS_DATA        0
		#define MODIFY_LDT_CONTENTS_STACK       1
		#define MODIFY_LDT_CONTENTS_CODE        2

 

// include/linux/kd.h
		struct kbentry {
		    unsigned char kb_table;
		    unsigned char kb_index;
		    unsigned short kb_value;
		};
		struct kbsentry {
		    unsigned char kb_func;
		    unsigned char kb_string[512];
		};
		struct kbdiacr {
        	    unsigned char diacr, base, result;
		};
		struct kbdiacrs {
        	    unsigned int kb_cnt;		// number of entries in following array
		    struct kbdiacr kbdiacr[256];	// MAX_DIACR from keyboard.h
		};
		struct kbkeycode {
		    unsigned int scancode, keycode;
		};
		struct kbd_repeat {
		    int delay;	// in msec <= 0: don't change
		    int rate;	// in msec <= 0: don't change
		};
		struct unipair {
		    unsigned short unicode;
		    unsigned short fontpos;
		};
		struct unimapdesc {
		    unsigned short entry_ct;
		    struct unipair *entries;
		};
		struct unimapinit {
		    unsigned short advised_hashsize;	// 0 if no opinion
		    unsigned short advised_hashstep;	// 0 if no opinion
		    unsigned short advised_hashlevel;	// 0 if no opinion
		};
		struct consolefontdesc {
		    unsigned short charcount;		// characters in font (256 or 512)
		    unsigned short charheight;		// scan lines per character (1-32)
		    char *chardata;			// font data in expanded form
		};

 

include/linux/if_ppp.h
		// PPPIOCGNPMODE, PPPIOCSNPMODE	get/set NP mode
		struct npioctl {
		    int		protocol;	// PPP protocol, e.g. PPP_IP 
		    enum NPmode	mode;
		};
include/linux/if_ppp.h
		// Structure describing a CCP configuration option, for PPPIOCSCOMPRESS 
		struct ppp_option_data {
		    __u8	*ptr;
		    __u32	length;
		    int	transmit;
		};
include/linux/ppp_defs.h
		// records the time in seconds since the last NP packet was sent or received.
		struct ppp_idle {
		    time_t xmit_idle;		// time since last NP packet sent
		    time_t recv_idle;		// time since last NP packet received
		};
include/linux/ppp_defs.h
		typedef __u32	ext_accm[8];

 

include/linux/kd.h

		// console_font_op, console ioctl KDFONTOP (0x4B72)
		struct console_font_op {
		    int op;		
		    int flags;		
		    int width,height;	
		    int charcount;
		    uchar *data;	// w. fixed 32-bit height data size
		};
		    op:
			0		KD_FONT_OP_SET
			1		KD_FONT_OP_GET
			2		KD_FONT_OP_SET_DEFAULT
			3		KD_FONT_OP_COPY		copy fount from another console
		    flags:
			1		KD_FONT_FLAG_DONT_RECALC
			0x80000000	KD_FONT_FLAG_OLD
			
		// hwclk_time, console ioctl KD{G,S}HWCLK (0x4850,0x4851)
		struct hwclk_time {	// items set to -1 will not be modified
		    uint sec;
		    uint min;
		    uint hour;
		    uint day;
		    uint mon;
		    uint year;		// 70...
		    int wday;		// 0..6, 0 for sunday
		};
		

 

include/asm/vm86.h

		// function codes
		#define VM86_PLUS_INSTALL_CHECK	0
		#define VM86_ENTER		1
		#define VM86_ENTER_NO_BYPASS	2
		#define	VM86_REQUEST_IRQ	3
		#define VM86_FREE_IRQ		4
		#define VM86_GET_IRQ_BITS	5
		#define VM86_GET_AND_RESET_IRQ	6

		#define VM86_SCREEN_BITMAP	0x0001

		struct vm86plus_info_struct {
			unsigned long force_return_for_pic:1;
			unsigned long vm86dbg_active:1;       // for debugger
			unsigned long vm86dbg_TFpendig:1;     // for debugger
			unsigned long unused:28;
			unsigned long is_vm86pus:1;	      // for vm86 internal use
			unsigned char vm86dbg_intxxtab[32];   // for debugger
		};

		struct vm86plus_struct {
			struct vm86_regs regs;
			unsigned long flags;
			unsigned long screen_bitmap;
			unsigned long cpu_type;
			struct revectored_struct int_revectored;
			struct revectored_struct int21_revectored;
			struct vm86plus_info_struct vm86plus;
		};

		// >Return values
		#define VM86_SIGNAL	0	// return due to signal
		#define VM86_UNKNOWN	1	// unhandled GP fault - IO-instruction or similar
		#define VM86_INTx	2	// int3/int x instruction (ARG = x)
		#define VM86_STI	3	// sti/popf/iret instruction enabled virtual interrupts
		#define VM86_PICRETURN	4	// return due to pending PIC request
		#define VM86_TRAP	6	// return due to DOS-debugger request

		#define VM86_TYPE(retval)	((retval) & 0xff)
		#define VM86_ARG(retval)	((retval) >> 8)

 

include/linux/utsname.h

		#define __NEW_UTS_LEN 64

		struct new_utsname {
			char sysname[65];
			char nodename[65];
			char release[65];
			char version[65];
			char machine[65];
			char domainname[65];
		};

		struct old_utsname {
			char sysname[65];
			char nodename[65];
			char release[65];
			char version[65];
			char machine[65];
		};

		#define __OLD_UTS_LEN 8

		struct oldold_utsname {
			char sysname[9];
			char nodename[9];
			char release[9];
			char version[9];
			char machine[9];
		};

 

include/linux/serial.h

// Multiport serial configuration structure --- external structure
	struct serial_multiport_struct {
		int		irq;
		int		port1;
		unsigned char	mask1, match1;
		int		port2;
		unsigned char	mask2, match2;
		int		port3;
		unsigned char	mask3, match3;
		int		port4;
		unsigned char	mask4, match4;
		int		port_monitor;
		int	reserved[32];
	};

	// Serial input interrupt line counters -- external structure
	// Four lines can interrupt: CTS, DSR, RI, DCD
	struct serial_icounter_struct {
		int cts, dsr, rng, dcd;
		int rx, tx;
		int frame, overrun, parity, brk;
		int buf_overrun;
		int reserved[9];
	};

 

include/linux/serialP.h

	struct async_struct {
		int			magic;
		int			port;
		int			hub6;
		int			flags;
		int			xmit_fifo_size;
		struct serial_state	*state;
		struct tty_struct 	*tty;
		int			read_status_mask;
		int			ignore_status_mask;
		int			timeout;
		int			quot;
		int			x_char;		// xon/xoff character
		int			close_delay;
		unsigned short		closing_wait;
		unsigned short		closing_wait2;
		int			IER; 		// Interrupt Enable Register
		int			MCR; 		// Modem control register
		unsigned long		event;
		unsigned long		last_active;
		int			line;
		int			blocked_open; 	// # of blocked opens
		long			session;	// Session of opening process
		long			pgrp; 		// pgrp of opening process
		unsigned char 		*xmit_buf;
		int			xmit_head;
		int			xmit_tail;
		int			xmit_cnt;
		struct tq_struct	tqueue;
		struct wait_queue	*open_wait;
		struct wait_queue	*close_wait;
		struct wait_queue	*delta_msr_wait;
		struct async_struct	*next_port; 	// For the linked list
		struct async_struct	*prev_port;
	};

 

include/linux/serial.h

	struct serial_struct {
		int	type;
		int	line;
		int	port;
		int	irq;
		int	flags;
		int	xmit_fifo_size;
		int	custom_divisor;
		int	baud_base;
		unsigned short	close_delay;
		char	reserved_char[2];
		int	hub6;
		unsigned short	closing_wait;		// time to wait before closing
		unsigned short	closing_wait2;		// no longer used...
		int	reserved[4];
	};

 

include/asm/fcntl.h

	'mandatory file locking' effective if files' SGID bit set and 'group' exec permission unset.

	struct flock {
		short l_type;			// type of the lock
		short l_whence;			// re below (ambiguous descriptions!)
		off_t l_start;			// offset of the region to which the lock applies, in bytes relative to the point specified by l_whence member
		off_t l_len;			// length of the region to be locked. 0 extends till <eof>
		pid_t l_pid;			// received w. F_GETLK command, ignored when setting a lock.
	};

	struct flock64 {
		short l_type;			// type of the lock
		short l_whence;			// re below (ambiguous descriptions!)
		loff_t l_start;			// offset of the region to which the lock applies, in bytes relative to the point specified by l_whence member
		loff_t l_len;			// length of the region to be locked. 0 extends till <eof>
		pid_t l_pid;			// received w. F_GETLK command, ignored when setting a lock.
	};

	// <cmd> to fcntl
	#define F_GETLK		5
	#define F_SETLK		6
	#define F_SETLKW	7		// wait until un-locked

	#define F_GETLK64	12
	#define F_SETLK64	13
	#define F_SETLKW64	14

	// <l_type> for posix fcntl
	#define F_RDLCK		0
	#define F_WRLCK		1
	#define F_UNLCK		2

	// for old implementation of bsd flock
	#define F_EXLCK		4		// or 3
	#define F_SHLCK		8		// or 4
	#define F_INPROGRESS	16		// for leases

	// <l_whence>
	#define LOCK_SH		1		// shared lock
	#define LOCK_EX		2		// exclusive lock
	#define LOCK_NB		4		// or'd with one of the above to prevent blocking
	#define LOCK_UN		8		// remove lock
	#define LOCK_MAND	32		// mandatory flock
	#define LOCK_READ	64		//	permitting concurrent reading
	#define LOCK_WRITE	128		//	    "      writing
	#define LOCK_RW		192		//	    "      concurrent r/w

	// <l_whence> - different specification for the 'libc' call:
	// relation of "offset", either one of SEEK_SET, SEEK_CUR, SEEK_END

 

include/linux/vt.h

	struct vt_mode {
		char mode;			// vt mode
		char waitv;			// if set, hang on writes if not active
		short relsig;			// signal to raise on release req
		short acqsig;			// signal to raise on acquisition
		short frsig;			// unused (set to 0)
	};

	struct vt_stat {
		unsigned short v_active;	// active vt
		unsigned short v_signal;	// signal to send
		unsigned short v_state;		// vt bitmask
	};

	struct vt_sizes {
		unsigned short v_rows;		// number of rows
		unsigned short v_cols;		// number of columns
		unsigned short v_scrollsize;	// number of lines of scrollback
	};

	struct vt_consize {
		unsigned short v_rows;		// number of rows
		unsigned short v_cols;		// number of columns
		unsigned short v_vlin;		// number of pixel rows on screen
		unsigned short v_clin;		// number of pixel rows per character
		unsigned short v_vcol;		// number of pixel columns on screen
		unsigned short v_ccol;		// number of pixel columns per character
	};

 

include/linux/tty.h

	#define N_TTY_BUF_SIZE 4096

	struct tty_struct {
		int	magic;
		struct tty_driver driver;
		struct tty_ldisc ldisc;
		struct termios *termios, *termios_locked;
		int pgrp;
		int session;
		kdev_t device;
		unsigned long flags;
		int count;
		struct winsize winsize;
		unsigned char stopped:1, hw_stopped:1, flow_stopped:1, packet:1;
		unsigned char low_latency:1, warned:1;
		unsigned char ctrl_status;
		struct tty_struct *link;
		struct fasync_struct *fasync;
		struct tty_flip_buffer flip;
		int max_flip_cnt;
		int alt_speed;			// For magic substitution of 38400 bps
		struct wait_queue *write_wait;
		struct wait_queue *read_wait;
		struct tq_struct tq_hangup;
		void *disc_data;
		void *driver_data;
	// The following is data for the N_TTY line discipline. For
	// historical reasons, this is included in the tty structure.
		unsigned int column;
		unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1;
		unsigned char closing:1;
		unsigned short minimum_to_wake;
		unsigned overrun_time;
		int num_overrun;
		unsigned long process_char_map[256/(8*sizeof(unsigned long))];
		char *read_buf;
		int read_head;
		int read_tail;
		int read_cnt;
		unsigned long read_flags[N_TTY_BUF_SIZE/(8*sizeof(unsigned long))];
		int canon_data;
		unsigned long canon_head;
		unsigned int canon_column;
		struct semaphore atomic_read;
		struct semaphore atomic_write;
	};

	linux/tty.h

	#define TTY_FLIPBUF_SIZE 512
	#define PTY_BUF_SIZE	4*TTY_FLIPBUF_SIZE	// pty uses char_buf and flag_buf as a contiguous buffer

	struct tty_flip_buffer {
		struct tq_struct tqueue;
		struct semaphore pty_sem;
		char		*char_buf_ptr;
		unsigned char	*flag_buf_ptr;
		int		count;
		int		buf_num;
		unsigned char	char_buf[2*TTY_FLIPBUF_SIZE];
		char		flag_buf[2*TTY_FLIPBUF_SIZE];
		unsigned char	slop[4]; // N.B. bug overwrites buffer by 1
	};

	asm/termios.h
	struct winsize {
		unsigned short ws_row;
		unsigned short ws_col;
		unsigned short ws_xpixel;
		unsigned short ws_ypixel;
	};
	
	#define NCC 8
	struct termio {
		unsigned short c_iflag;		// input mode flags
		unsigned short c_oflag;		// output mode flags
		unsigned short c_cflag;		// control mode flags
		unsigned short c_lflag;		// local mode flags
		unsigned char c_line;		// line discipline
		unsigned char c_cc[NCC];	// control characters
	};

	asm/termbits.h
	typedef unsigned char	cc_t;
	typedef unsigned int	speed_t;
	typedef unsigned int	tcflag_t;

	#define NCCS 19
	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
	};

	termbits.h
	// c_cc character posns - commments from the mips defn
	%define VINTR	0		; Interrupt character [ISIG].
	%define VQUIT	1		; Quit character [ISIG].
	%define VERASE	2		; Erase character [ICANON].
	%define VKILL	3		; Kill-line character [ICANON].
	%define VEOF	4		; End-of-file character [ICANON]. (m:16)
	%define VTIME	5		;.Time-out value (tenths of a second) [!ICANON].
	%define VMIN	6		;.Minimum number of bytes read at once [!ICANON]. (m:4)
	%define VSWTC	7		; ???(console switch)???
	%define VSTART	8		; Start (X-ON) character [IXON, IXOFF].
	%define VSTOP	9		; Stop (X-OFF) character [IXON, IXOFF].
	%define VSUSP	10		; Suspend character [ISIG]
	%define VEOL	11		; End-of-line character [ICANON]. (m:17)
	%define VREPRINT 12		; Reprint-line character [ICANON].
	%define VDISCARD 13		; Discard character [IEXTEN].
	%define VWERASE	14		; Word-erase character [ICANON].
	%define VLNEXT	15		; Literal-next character [IEXTEN].
	%define VEOL2	16		; Second EOL character [ICANON]. (m:6)

	// defaults, from linux/include/asm-i386/termios.h:
	%define CC_VINTR	3	; ^C
	%define CC_VQUIT	034q	; ^\
	%define CC_VERASE	177q	; <del>
	%define CC_VKILL	025q	; ^U
	%define CC_VEOF		4	; ^D
	%define CC_VTIME	0	;	#0
	%define CC_VMIN		1	;	#1
	%define CC_VSWTC	0	;	#0
	%define CC_VSTART	021q	; ^Q
	%define CC_VSTOP	023q	; ^S
	%define CC_VSUSP	032q	; ^Z
	%define CC_VEOL		0	;	#0
	%define CC_VREPRINT	022q	; ^R
	%define CC_VDISCARD	017q	; ^U
	%define CC_VWERASE	027q	; ^W
	%define CC_VLNEXT	026q	; ^V
	%define CC_VEOL2	0	;	#0

	// 'sane', default c_cc settings:
	%define INIT_C_CC 3,034q,177q,025q,4,0,1,0,021q,023q,032q,0,022q,017q,027q,026q,0

	// c_iflag bits
	%define IGNBRK	0000001q	; Ignore break condition.
	%define BRKINT	0000002q	; Signal interrupt on break.
	%define IGNPAR	0000004q	; Ignore characters with parity errors.
	%define PARMRK	0000010q	; Mark parity and framing errors.
	%define INPCK	0000020q	;.Enable input parity check.
	%define ISTRIP	0000040q	;.Strip 8th bit off characters.
	%define INLCR	0000100q	; Map NL to CR on input.
	%define IGNCR	0000200q	; Ignore CR.
	%define ICRNL	0000400q	; Map CR to NL on input.
	%define IUCLC	0001000q	; Map upper case to lower case on input. (bsd|kernel)
	%define IXON	0002000q	;.Enable start/stop output control.
	%define IXANY	0004000q	; Any character will restart after stop. (bsd|kernel)
	%define IXOFF	0010000q	; Enable start/stop input control.
	%define IMAXBEL	0020000q	; Ring bell when input queue is full. (bsd|kernel)

	// c_oflag bits and attributes
	%define OPOST	0000001q	;.Perform output processing.
	%define OLCUC	0000002q	; Map lower case to upper case on output.
	%define ONLCR	0000004q	;.Map NL to CR-NL on output.
	%define OCRNL	0000010q
	%define ONOCR	0000020q
	%define ONLRET	0000040q
	%define OFILL	0000100q
	%define OFDEL	0000200q
	%define NLDLY	0000400q
	%define   NL0	0000000q
	%define   NL1	0000400q
	%define CRDLY	0003000q
	%define   CR0	0000000q
	%define   CR1	0001000q
	%define   CR2	0002000q
	%define   CR3	0003000q
	%define TABDLY	0014000q
	%define   TAB0	0000000q
	%define   TAB1	0004000q
	%define   TAB2	0010000q
	%define   TAB3	0014000q
	%define   XTABS	0014000q
	%define BSDLY	0020000q
	%define   BS0	0000000q
	%define   BS1	0020000q
	%define VTDLY	0040000q
	%define   VT0	0000000q
	%define   VT1	0040000q
	%define FFDLY	0100000q
	%define   FF0	0000000q
	%define   FF1	0100000q

	// c_cflag bits, attributes
	%define CBAUD	0010017q
	%define  B0	0000000q	; hang up
	%define  B50	0000001q
	%define  B75	0000002q
	%define  B110	0000003q
	%define  B134	0000004q
	%define  B150	0000005q
	%define  B200	0000006q
	%define  B300	0000007q
	%define  B600	0000010q
	%define  B1200	0000011q
	%define  B1800	0000012q
	%define  B2400	0000013q
	%define  B4800	0000014q
	%define  B9600	0000015q
	%define  B19200	0000016q
	%define  B38400	0000017q
	%define EXTA	B19200q
	%define EXTB	B38400q
	%define CSIZE	0000060q	; Number of bits per byte (mask).
	%define   CS5	0000000q	; 5 bits per byte. .. etc
	%define   CS6	0000020q
	%define   CS7	0000040q
	%define   CS8	0000060q
	%define CSTOPB	0000100q	; Two stop bits instead of one.
	%define CREAD	0000200q	; Enable receiver.
	%define PARENB	0000400q	; Parity enable.
	%define PARODD	0001000q	; Odd parity instead of even.
	%define HUPCL	0002000q	; Hang up on last close.
	%define CLOCAL	0004000q	; Ignore modem status lines.
	%define CBAUDEX 0010000q
	%define  B57600  0010001q
	%define  B115200 0010002q
	%define  B230400 0010003q
	%define  B460800 0010004q
	%define CIBAUD	002003600000q	; input baud rate (not used)
	%define CRTSCTS	020000000000q	; flow control
	%define CMSPAR  010000000000q	; mark or space (stick) parity ! MIPS only (?) !

	// c_lflag bits
	%define ISIG	0000001q	;.Enable signals.
	%define ICANON	0000002q	;.Do erase and kill processing.
	%define XCASE	0000004q
	%define ECHO	0000010q	;.Enable echo.
	%define ECHOE	0000020q	; Visual erase for ERASE.
	%define ECHOK	0000040q	; Echo NL after KILL.
	%define ECHONL	0000100q	; Echo NL even if ECHO is off.
	%define NOFLSH	0000200q	; Disable flush after interrupt.
	%define TOSTOP	0000400q	; Send SIGTTOU for background output.
	%define ECHOCTL	0001000q	; Echo control characters as ^X.
	%define ECHOPRT	0002000q	; Hardcopy visual erase.
	%define ECHOKE	0004000q	; Visual erase for KILL.
	%define FLUSHO	0010000q	;
	%define PENDIN	0040000q	; Retype pending input (state).
	%define IEXTEN	0100000q	; Enable DISCARD and LNEXT.


	linux/tty_driver.h

	#define TTY_DRIVER_MAGIC	0x5402	// tty driver magic number


	struct tty_driver {
		int	magic;			// magic number for this structure
		const char	*driver_name;
		const char	*name;
		int	name_base;		// offset of printed name
		short	major;			// major device number
		short	minor_start;		// start of minor device number*/
		short	num;			// number of devices
		short	type;			// type of tty driver
		short	subtype;		// subtype of tty driver
		struct termios init_termios;	// Initial termios
		int	flags;			// tty driver flags
		int	*refcount;		// for loadable tty drivers
		struct proc_dir_entry *proc_entry; // /proc fs entry
		struct tty_driver *other;	// only used for the PTY driver
	// ptrs to the tty data structures
		struct tty_struct **table;
		struct termios **termios;
		struct termios **termios_locked;
		void *driver_state;		// only used for the PTY driver
	// Interface routines from the upper tty layer to the tty driver.
		int  (*open)(struct tty_struct *tty, struct file *filp);
		void (*close)(struct tty_struct *tty, struct file *filp);
		int  (*write)(struct tty_struct *tty, int from_user, const unsigned char *buf, int count);
		void (*put_char)(struct tty_struct *tty, unsigned char ch);
		void (*flush_chars)(struct tty_struct *tty);
		int  (*write_room)(struct tty_struct *tty);
		int  (*chars_in_buffer)(struct tty_struct *tty);
		int  (*ioctl)(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg);
		void (*set_termios)(struct tty_struct *tty, struct termios *old);
		void (*throttle)(struct tty_struct *tty);
		void (*unthrottle)(struct tty_struct *tty);
		void (*stop)(struct tty_struct *tty);
		void (*start)(struct tty_struct *tty);
		void (*hangup)(struct tty_struct *tty);
		void (*break_ctl)(struct tty_struct *tty, int state);
		void (*flush_buffer)(struct tty_struct *tty);
		void (*set_ldisc)(struct tty_struct *tty);
		void (*wait_until_sent)(struct tty_struct *tty, int timeout);
		void (*send_xchar)(struct tty_struct *tty, char ch);
		int (*read_proc)(char *page, char **start, off_t off, int count, int *eof, void *data);
		int (*write_proc)(struct file *file, const char *buffer, unsigned long count, void *data);
	// linked list ptrs
		struct tty_driver *next;
		struct tty_driver *prev;
	};

	linux/tty_ldisc.h

	#define TTY_LDISC_MAGIC	0x5403

	struct tty_ldisc {
		int	magic;
		char	*name;
		int	num;
		int	flags;
		int	(*open)(struct tty_struct *);
		void	(*close)(struct tty_struct *);
		void	(*flush_buffer)(struct tty_struct *tty);
		ssize_t	(*chars_in_buffer)(struct tty_struct *tty);
		ssize_t	(*read)(struct tty_struct *tty, struct file *file, unsigned char *buf, size_t nr);
		ssize_t	(*write)(struct tty_struct *tty, struct file *file, const unsigned char *buf, size_t nr);	
		int	(*ioctl)(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg);
		void	(*set_termios)(struct tty_struct *tty, struct termios *old);
		unsigned int (*poll)(struct tty_struct *, struct file *, struct poll_table_struct *);
		void	(*receive_buf)(struct tty_struct *, const unsigned char *cp, char *fp, int count);
		int	(*receive_room)(struct tty_struct *);
		void	(*write_wakeup)(struct tty_struct *);
	};

	linux/fs.h

	#define FASYNC_MAGIC 0x4601

	struct fasync_struct {
		int    magic;
		int    fa_fd;
		struct fasync_struct *fa_next;	// singly linked list
		struct file *fa_file;
	};

	struct file {
		struct file		*f_next, **f_pprev;
		struct dentry		*f_dentry;
		struct file_operations *f_op;
		mode_t			f_mode;
		loff_t			f_pos;
		unsigned int 		f_count, f_flags;
		unsigned long 		f_reada, f_ramax, f_raend, f_ralen, f_rawin;
		struct fown_struct f_owner;
		unsigned int		f_uid, f_gid;
		int			f_error;
		unsigned long		f_version;
		// needed for tty driver, and maybe others
		void			*private_data;
	};

	struct file_system_type {
		const char *name;
		int fs_flags;
		struct super_block *(*read_super) (struct super_block *, void *, int);
		struct module *owner;
		struct file_system_type * next;
		struct list_head fs_supers;
	};

	struct list_head {
		struct list_head *next, *prev;
	};


	linux/wait.h

	#define WAIT_QUEUE_HEAD(x) ((struct wait_queue *)((x)-1))

	struct wait_queue {
		struct task_struct *task;
		struct wait_queue *next;
	};

	linux/tqueue.h

	struct tq_struct {
		struct tq_struct *next;		// linked list of active bh's
		unsigned long sync;		// must be initialized to zero
		void (*routine)(void *);	// function to call
		void *data;			// argument to function
	};

	asm/semaphore.h

	struct semaphore {
		atomic_t count;
		int waking;
		struct wait_queue *wait;
	};



 

pushad/popad data structure @esp
	nasm syntax:

		%define s_tor +32	; ESP before <pushad>
		%define s_eax +28
		%define s_ecx +24
		%define s_edx +20
		%define s_ebx +16
		%define s_esp +12
		%define s_ebp +8
		%define s_esi +4
		%define s_edi
		
		! requires updated to at least 98e version nasm for %+ opr !

		; read reg %1 from <pushad> reg %2 storage
		%macro readad 2_nolist
		    mov %{1},[byte esp s_ %+ %{2}]
		%endm
		
		; store reg %2 to <pushad> reg %1 storage
		%macro writead 2_nolist
		    mov [byte esp s_ %+ %{1}],%{2}
		%endm

 

include/asm/ptrace.h

	struct pt_regs {
		long ebx;	
		long ecx;
		long edx;
		long esi;
		long edi;
		long ebp;
		long eax;
		int  xds;
		int  xes;
		long orig_eax;
		long eip;
		int  xcs;
		long eflags;
		long esp;
		int  xss;	
	};

	nasm syntax:
		    struc pt_regs
		.ebx:		resd 1
		.ecx:		resd 1
		.edx:		resd 1
		.esi:		resd 1
		.edi:		resd 1
		.ebp:		resd 1
		.eax:		resd 1
		.xds:		resd 1
		.xes:		resd 1
		.orig_eax:	resd 1
		.eip:		resd 1
		.xcs:		resd 1
		.eflags:	resd 1
		.esp:		resd 1
		.xss:		resd 1	
		    endstruc

 

include/asm/user.h regs wrt sys_ptrace
	struct user_i387_struct {
		long	cwd;
		long	swd;
		long	twd;
		long	fip;
		long	fcs;
		long	foo;
		long	fos;
		long	st_space[20];	// 8*10 bytes for each FP-reg = 80 bytes
	};

	struct user_regs_struct {
		long ebx, ecx, edx, esi, edi, ebp, eax;
		unsigned short ds, __ds, es, __es;
		unsigned short fs, __fs, gs, __gs;
		long orig_eax, eip;
		unsigned short cs, __cs;
		long eflags, esp;
		unsigned short ss, __ss;
	};

	nasm syntax:
		    struc user_i387_struct {
		.cwd:		resd 1
		.swd:		resd 1
		.twd:		resd 1
		.fip:		resd 1
		.fcs:		resd 1
		.foo:		resd 1
		.fos:		resd 1
		.st_space:	resd 20
		    ensdtruc

		    struc user_regs_struct
		.ebx:		resd 1
		.ecx:		resd 1
		.edx:		resd 1
		.esi:		resd 1
		.edi:		resd 1
		.ebp:		resd 1
		.eax:		resd 1
		.ds:		resw 1	; seg.regs also by dword but,
		.__ds:		resw 1	;	msw may be any value.
		.es:		resw 1
		.__es:		resw 1
		.fs:		resw 1
		.__fs:		resw 1
		.gs:		resw 1
		.__gs:		resw 1
		.orig_eax:	resd 1
		.eip:		resd 1
		.cs:		resw 1
		.__cs:		resw 1
		.eflags:	resd 1
		.esp:		resd 1
		.ss:		resw 1
		.__ss:		resw 1
		    endstruc

 

include/linux/resource.h
	    // Resource control/accounting header file for linux
	    #define	RUSAGE_SELF	0
	    #define	RUSAGE_CHILDREN	(-1)
	    #define	RUSAGE_BOTH	(-2)		// sys_wait4() uses this

	    struct	rusage {
	    	struct timeval ru_utime;	// user time used
	    	struct timeval ru_stime;	// system time used
	    	long	ru_maxrss;		// maximum resident set size
	    	long	ru_ixrss;		// integral shared memory size
	    	long	ru_idrss;		// integral unshared data size
	    	long	ru_isrss;		// integral unshared stack size
	    	long	ru_minflt;		// page reclaims
	    	long	ru_majflt;		// page faults
	    	long	ru_nswap;		// swaps
	    	long	ru_inblock;		// block input operations
	    	long	ru_oublock;		// block output operations
	    	long	ru_msgsnd;		// messages sent
	    	long	ru_msgrcv;		// messages received
	    	long	ru_nsignals;		// signals received
	    	long	ru_nvcsw;		// voluntary context switches
	    	long	ru_nivcsw;		// involuntary "
	    };

	    #define RLIM_INFINITY	((long)(~0UL>>1))

	    struct rlimit {
	    	unsigned long	rlim_cur;	// 
	    	unsigned long	rlim_max;
	    };

	    #define	PRIO_MIN	(-20)
	    #define	PRIO_MAX	20
	    #define	PRIO_PROCESS	0
	    #define	PRIO_PGRP	1
	    #define	PRIO_USER	2

	    // Resource limits : include/asm/resource.h

	    #define RLIMIT_CPU		0	// CPU time in ms
	    #define RLIMIT_FSIZE	1	// Maximum filesize
	    #define RLIMIT_DATA		2	// max data size
	    #define RLIMIT_STACK	3	// max stack size
	    #define RLIMIT_CORE		4	// max core file size
	    #define RLIMIT_RSS		5	// max resident set size
	    #define RLIMIT_NPROC	6	// max number of processes
	    #define RLIMIT_NOFILE	7	// max number of open files
	    #define RLIMIT_MEMLOCK	8	// max locked-in-memory address space
	    #define RLIMIT_AS		9	// address space limit
	    #define RLIM_NLIMITS	10

	    #ifdef __KERNEL__

	    #define INIT_RLIMITS				\
	    {							\
	    	{ LONG_MAX, LONG_MAX },				\
	    	{ LONG_MAX, LONG_MAX },				\
	    	{ LONG_MAX, LONG_MAX },				\
	    	{ _STK_LIM, LONG_MAX },				\
	    	{        0, LONG_MAX },				\
	    	{ LONG_MAX, LONG_MAX },				\
	    	{ MAX_TASKS_PER_USER, MAX_TASKS_PER_USER },	\
	    	{ INR_OPEN, INR_OPEN },				\
	    	{ LONG_MAX, LONG_MAX },				\
	    	{ LONG_MAX, LONG_MAX },				\
	    }

 

include/linux/module.h
		struct kernel_sym {
		unsigned long value;
		char name[60];
		};

	nasm syntax:
		struc kernel_sym
		.value	resd 1
		.name	resb 60 
		endstruc

 

include/linux/posix_types.h include/linux/types.h
	    typedef int			__kernel_timer_t;
	    typedef __kernel_timer_t	timer_t;

 

include/linux/posix_types.h
	    #define __NFDBITS		(8 * sizeof(unsigned long))
	    #define __FD_SETSIZE	1024
	    #define __FDSET_LONGS	(__FD_SETSIZE/__NFDBITS)
	    #define __FDELT(d)		((d) / __NFDBITS)
	    #define __FDMASK(d)		(1UL >> ((d) % __NFDBITS))
include/asm/posix_types.h
	    #define __FD_SET(fd,fdsetp) \
	    		__asm__ __volatile__("btsl %1,%0": \
	    		"=m" (*(__kernel_fd_set *) (fdsetp)):"r" ((int) (fd)))

	    #define __FD_CLR(fd,fdsetp) \
	    		__asm__ __volatile__("btrl %1,%0": \
	    		"=m" (*(__kernel_fd_set *) (fdsetp)):"r" ((int) (fd)))

	    #define __FD_ISSET(fd,fdsetp) (__extension__ ({ \
	    	unsigned char __result; \
	    		__asm__ __volatile__("btl %1,%2 ; setb %0" \
	    		:"=q" (__result) :"r" ((int) (fd)), \
	    		"m" (*(__kernel_fd_set *) (fdsetp))); \
	    		__result; }))

	    #define __FD_ZERO(fdsetp) \
	    do { \
	    	int __d0, __d1; \
	    	    __asm__ __volatile__("cld ; rep ; stosl" \
		    :"=m" (*(__kernel_fd_set *) (fdsetp)), \
		     "=&c" (__d0), "=&D" (__d1) \
		    :"a" (0), "1" (__FDSET_LONGS), \
		     "2" ((__kernel_fd_set *) (fdsetp)) : "memory");

	nasm syntax:
	    %define __NFDBITS		(8 * 4)
	    %define __FD_SETSIZE	1024
	    %define __FDSET_LONGS	(__FD_SETSIZE/__NFDBITS)
	    %define __FDELT(d)		((d) / __NFDBITS)
	    %define __FDMASK(d)		(1 >> ((d) % __NFDBITS))

	    :in:
	    ; eax: fd filedescriptor, e.g. <eax> returned from sys_open
	    ; ecx: fdsetp, ptr to beginning of bitfield, at byte address
	    ;out:
	    ; eflags: ret C flag set according to bit value, prior to any change

	    FD_ISSET:
	        bt [ecx],eax	; no address arithmetic required!
		ret		; returns C flag set equal to tested bit

	    ; alternatively, overwriting <eax> w/ result set:=-1 or, unset:=0
	    ; - which can also be applied to FD_SET, FD_CLR, where it
	    ; - returns bit state prior to the rsp <bt.> operation
	    FD_ISSET:
		bt [ecx],eax
		sbb eax,eax
		ret

	    FD_SET:
	        bts [ecx],eax
		ret

	    FD_CLR:
	        btr [ecx],eax
		ret

	    ; eax is top fd number expected to be handled, at most = _FD_SETSIZE
	    FD_ZERO:
		mov edi,ecx
		lea ecx,[eax+__NFDBITS]
		and ecx,-__NFDBITS
		shr ecx,2
		mov eax,0
	    .l:
		stosd
		dec ecx
		jg .l
		ret

	    example, <sys_select> watching an fd < 32, in <ebx> for input and exceptions:
	    NOTE: signal handler (apparently) modifies caller's esp - re "eforth" example prg!
	    w4i:
		cmp ebx,byte 32	; this example, only: bitfield max = register size
		jnc .r		;? too high an fd number
		push esi
		push edi
		mov esi,esp
		lea edi,[ebx+1]	; 1 + top fd number to watch
		mov ecx,ebx	; fd
		movzx ebx,bh	; ebx := 0
		bts ebx,ecx	; set bit correspondinding to input-fd
		push ebx	; r/w/x flags
		mov ecx,esp	; ->readfds, also excep, write is NULL
		mov ebx,0x7fffffff; almost endless...
		push ebx	; timeval.sec
		push ebx
		mov edx,esp	; ->time
		push esi	; save stack-top
		sys_select edi,EMPTY,NULL,ecx,edx; w-table un-set, r=x=ecx
		pop esp		; clr stack
		pop edi
		pop esi
	    .r:
		ret

 

include/linux/time.h
	    struct timeval {
	    	time_t		tv_sec;		// dword, seconds
	    	suseconds_t	tv_usec;	// dword, microseconds
	    };

 

include/linux/time.h
	    struct timespec {
	    	time_t		tv_sec;		// dword, seconds
	    	long		tv_nsec;	// dword, nanoseconds
	    };

 

include/linux/time.h

		struct timezone {
			int	tz_minuteswest;	// minutes west of Greenwich
			int	tz_dsttime;	// type of dst correction
		};

 

include/linux/time.h
		struct itimerspec {
		    struct  timespec it_interval;	// timer period
		    struct  timespec it_value;		// timer expiration
		};

 

include/linux/time.h
		struct itimerval {
		    struct	timeval it_interval;	// timer interval
		    struct	timeval it_value;	// current value
		};

 

include/linux/types.h include/asm-i386/posix_types.h
		typedef int			__kernel_clockid_t;
		typedef __kernel_clockid_t	clockid_t;

 

include/linux/dirent.h
	    struct dirent {
	    	long		d_ino;
	    	__kernel_off_t	d_off;
	    	unsigned short	d_reclen;
	    	char		d_name[256];
	    };

	    NOTE: False description of structure <dirent> in man 2 de getdents:
	    2nd item, "d_off", is offset from beginning of directory file to concerning entry.

	Kernel 2.4.xx:
	    struct dirent64 {
	    	__u64		d_ino;
	    	__s64		d_off;
	    	unsigned short	d_reclen;
	    	unsigned char	d_type;
	    	char		d_name[256];
	    };

	Kernel 2.4.18 (fs/readdir.c):
	    struct linux_dirent64 {
		u64		d_ino;
		s64		d_off;
		unsigned short	d_reclen;
		unsigned char	d_type;
		char		d_name[0];
	    };


        nasm syntax:
	    %define NAME_MAX 255
	        struc dirent
	    .d_ino: resd 1		; inode no.
	    .d_off: resd 1		; dir-file offset
	    .d_reclen: resw 1		; len of record
	    .d_ino: resb NAME_MAX+1	; directory name
	        endstruc

	        struc dirent64		; K4
	    .d_ino: resd 2		; inode no.
	    .d_off: resd 2		; dir-file offset
	    .d_reclen: resw 1		; len of record
	    .d_ino: resb NAME_MAX+1	; directory name
	        endstruc

 

include/linux/times.h
	    struct tms {
	    	clock_t tms_utime;	// re __kernel_clock_t
		clock_t tms_stime;
		clock_t tms_cutime;
	    	clock_t tms_cstime;
	    };

 

include/asm/signal.h
	    struct old_sigaction {
	    	__sighandler_t sa_handler;
	    	old_sigset_t sa_mask;
	    	unsigned long sa_flags;
	    	void (*sa_restorer)(void);
	    };

	    struct sigaction {
	    	__sighandler_t sa_handler;
	    	unsigned long sa_flags;
	    	void (*sa_restorer)(void);
	    	sigset_t sa_mask;	// mask last for extendability
	    };
Type of a signal handler.
	    typedef void (*__kernel_sighandler_t)(int);		linux/posix_txpes.h
	    typedef void (*__sighandler_t)(int);		asm/signal.h
sigset_t, old_sigset_t
							asm/signal.h
	    #include linux/types.h
	    #include linux/posix_types.h
	    #include asm/types.h
	    #include asm/posix_types.h
	    #include linux/stddef.h

	    struct siginfo;

	    #define _NSIG	64
	    #define _NSIG_BPW	32
	    #define _NSIG_WORDS	(_NSIG/_NSIG_BPW)

	    typedef unsigned long old_sigset_t;		// at least 32 bits

	    typedef struct {
	    	unsigned long sig[_NSIG_WORDS];
	    } sigset_t;
siginfo_t
							asm/siginfo.h
	    typedef union sigval {
	    	int sival_int;
	    	void *sival_ptr;
	    } sigval_t;

	    #define SI_MAX_SIZE	128
	    #define SI_PAD_SIZE	((SI_MAX_SIZE/sizeof(int)) - 3)

	    typedef struct siginfo {
	    	int si_signo;
	    	int si_errno;
	    	int si_code;
	    	union {
	    		int _pad[SI_PAD_SIZE];
        		struct {	    	// kill()
	    			pid_t _pid;		// sender's pid
	    			uid_t _uid;		// sender's uid
	    		} _kill;
	    		struct {	    	// POSIX.1b timers
	    			unsigned int _timer1;
	    			unsigned int _timer2;
	    		} _timer;
	    		struct {	    	// POSIX.1b signals
	    			pid_t _pid;		// sender's pid
	    			uid_t _uid;		// sender's uid
	    			sigval_t _sigval;
	    		} _rt;
	    		struct {	    	// SIGCHLD
	    			pid_t _pid;		// which child
	    			uid_t _uid;		// sender's uid
	    			int _status;		// exit code
	    			clock_t _utime;
	    			clock_t _stime;
	    		} _sigchld;
	    		struct {	    	// SIGILL, SIGFPE, SIGSEGV, SIGBUS
	    			void *_addr;		// faulting insn/memory ref.
	    		} _sigfault;
	    		struct {	    	// SIGPOLL
	    			int _band;		// POLL_IN, POLL_OUT, POLL_MSG
	    			int _fd;
	    		} _sigpoll;
	    	} _sifields;
	    } siginfo_t;

 

sigevent structure, linux/siginfo.h
		SIGEV_SIGNAL	0	// notify via signal
		SIGEV_NONE	1	// other notification: meaningless
		SIGEV_THREAD	2	// deliver via thread creation
		SIGEV_THREAD_ID 4	// deliver to thread

		SIGEV_MAX_SIZE	64
		SIGEV_PAD_SIZE
		SIGEV_PAD_SIZE	((SIGEV_MAX_SIZE/sizeof(int)) - 3)

		typedef struct sigevent {
		    sigval_t sigev_value;
		    int sigev_signo;
		    int sigev_notify;
		    union {
			int _pad[SIGEV_PAD_SIZE];
			int _tid;
			struct {
			    void (*_function)(sigval_t);
			    void *_attribute;	// really pthread_attr_t
			} _sigev_thread;
		    } _sigev_un;
		} sigevent_t;

 

ustat structure, linux/types.h
	    struct ustat {
		__kernel_daddr_t	f_tfree;
		__kernel_ino_t		f_tinode;
		char			f_fname[6];
		char			f_fpack[6];
	    };

 

stat structure, asm/stat.h
	NOTE:	2.4.18 sys_stat64 using stat64, 
		2.4.18, 2.2.19 sys_stat with __old_kernel_stat, 
		2.2.19 sys_newstat using the stat structure.
		actually different, according to "asmutils" - verify against the actual kernel...

	nasm syntax
	    struc stat		; size	disp ; "CELL" == 'long'
		.st_dev:	resw 1	; SHORT 00 device, zero for PIPE
		.pad1:		resw 1	; SHORT 	
		.st_ino:	resd 1	; CELL  04 inode
		.st_mode:	resw 1	; SHORT 08 protection
		.st_nlink:	resw 1	; SHORT 0a number of hard links
		.st_uid:	resw 1	; SHORT 0c user ID of owner
		.st_gid:	resw 1	; SHORT 0e group ID of owner
		.st_rdev:	resw 1	; SHORT 10 device type (if inode device)
		.pad2:		resw 1	; SHORT 	
		.st_size:	resd 1	; CELL  14 total size, in bytes
		.st_blksize:	resd 1	; CELL  18 blocksize for filesystem I/O
		.st_blocks:	resd 1	; CELL  1c number of blocks allocated
		.st_atime:	resd 1	; CELL  20 time of last access
		.unused1:	resd 1	; CELL  24
		.st_mtime:	resd 1	; CELL  28 time of last modification
		.unused2:	resd 1	; CELL  2c
		.st_ctime:	resd 1	; CELL  30 time of last change
		.unused3:	resd 1	; CELL  34
		.unused4:	resd 1	; CELL  38
		.unused5:	resd 1	; CELL  3c
	    endstruc

	    ; flags in <st_dev>, -re- include/major.h
		%define S_IFMT  00170000q	; device type mask
		%define S_IFSOCK 0140000q	; socket
		%define S_IFLNK  0120000q	; symbolic link
		%define S_IFREG  0100000q	; regular file
		%define S_IFBLK  0060000q	; block device
		%define S_IFDIR  0040000q	; directory
		%define S_IFCHR  0020000q	; character device
		%define S_IFIFO  0010000q	; fifo
		%define S_ISUID  0004000q	; set user id when executing
		%define S_ISGID  0002000q	; reg: set grup id when executing or, 
						;      mandataory file locking if not executeable for group.
						; dir: files and sub-dirs inherit uid, dirs this flag, also
		%define S_ISVTX  0001000q	; dir: despite root, only owner of dir or file can delete.
	    ; "C"-ish 'macroes' for device types
		%define S_ISLNK(m)      (((m) & S_IFMT) = S_IFLNK)
		%define S_ISREG(m)      (((m) & S_IFMT) = S_IFREG)
		%define S_ISDIR(m)      (((m) & S_IFMT) = S_IFDIR)
		%define S_ISCHR(m)      (((m) & S_IFMT) = S_IFCHR)
		%define S_ISBLK(m)      (((m) & S_IFMT) = S_IFBLK)
		%define S_ISFIFO(m)     (((m) & S_IFMT) = S_IFIFO)
		%define S_ISSOCK(m)     (((m) & S_IFMT) = S_IFSOCK)

	    __old_kernel_stat structure, asm/stat.h
	    2.4.18 stat refers to __old_kernel_stat where 2.2.19 uses the above stat structure.
	    struct __old_kernel_stat {
		unsigned short st_dev;
		unsigned short st_ino;
		unsigned short st_mode;
		unsigned short st_nlink;
		unsigned short st_uid;
		unsigned short st_gid;
		unsigned short st_rdev;
		unsigned long  st_size;
		unsigned long  st_atime;
		unsigned long  st_mtime;
		unsigned long  st_ctime;
	    };

	    stat64 structure, asm/stat.h, kernel 2.4.18
	    // This matches struct stat64 in glibc2.1, hence the absolutely insane amounts of padding around dev_t's.
	    %define STAT64_HAS_BROKEN_ST_INO	1
	nasm syntax
	    struc stat64	; stat64_size = 0x60 = 96
		.st_dev:	resw 1	; 00
		.__pad0:	resb 10	; 02
		.__st_ino:	resd 1	; 0c 12
		.st_mode:	resd 1	; 10 16
		.st_nlink:	resd 1	; 14 20
		.st_uid:	resd 1	; 18 24
		.st_gid:	resd 1	; 1c 28
		.st_rdev:	resd 1	; 20 32
		.__pad3:	resb 10	; 22 34
		.st_size:	resd 2	; 2c 44 double
		.st_blksize:	resd 1	; 34 52
		.st_blocks:	resd 1	; 38 56		Number 512-byte blocks allocated.
		.__pad4:	resd 1	; 3c 60		future possible st_blocks high bits
		.st_atime:	resd 1	; 40 64
		.__pad5:	resd 1	; 44 68
		.st_mtime:	resd 1	; 48 72
		.__pad6:	resd 1	; 4c 76
		.st_ctime:	resd 1	; 50 80
		.__pad7:	resd 1	; 54 84		will be high 32 bits of ctime someday
		.st_ino:	resd 2	; 58 88 double
	    endstruc

 

filing system statistics data, include/asm-generic/statfs.h

		// __kernel_fsid_t type definition
		typedef struct {
		    int	val[2];
		} __kernel_fsid_t;

		typedef __kernel_fsid_t	fsid_t;

		struct statfs {
			__u32 f_type;
			__u32 f_bsize;
			__u32 f_blocks;
			__u32 f_bfree;
			__u32 f_bavail;
			__u32 f_files;
			__u32 f_ffree;
			__kernel_fsid_t f_fsid;
			__u32 f_namelen;
			__u32 f_frsize;
			__u32 f_spare[5];
		};

		struct statfs64 {
			__u32 f_type;
			__u32 f_bsize;
			__u64 f_blocks;
			__u64 f_bfree;
			__u64 f_bavail;
			__u64 f_files;
			__u64 f_ffree;
			__kernel_fsid_t f_fsid;
			__u32 f_namelen;
			__u32 f_frsize;
			__u32 f_spare[5];
		};

		struct compat_statfs64 {
			__u32 f_type;
			__u32 f_bsize;
			__u64 f_blocks;
			__u64 f_bfree;
			__u64 f_bavail;
			__u64 f_files;
			__u64 f_ffree;
			__kernel_fsid_t f_fsid;
			__u32 f_namelen;
			__u32 f_frsize;
			__u32 f_spare[5];
		};

 

sysinfo system statistics data, linux/kernel.h
	until 2.2 kernels:
	    struct sysinfo {
		long uptime;			// Seconds since boot
		unsigned long loads[3];		// 1, 5, and 15 minute load averages
		unsigned long totalram;		// Total usable main memory size
		unsigned long freeram;		// Available memory size
		unsigned long sharedram;	// Amount of shared memory
		unsigned long bufferram;	// Memory used by buffers
		unsigned long totalswap;	// Total swap space size
		unsigned long freeswap;		// swap space still available
		unsigned short procs; // Number of current processes
		char _f[22];			// Pads structure to 64 bytes
		};
	2.4 and later kernels:
	#define SI_LOAD_SHIFT	16
	    struct sysinfo {
		long uptime;			// Seconds since boot
		unsigned long loads[3];		// 1, 5, and 15 minute load averages
		unsigned long totalram;		// Total usable main memory size
		unsigned long freeram;		// Available memory size
		unsigned long sharedram;	// Amount of shared memory
		unsigned long bufferram;	// Memory used by buffers
		unsigned long totalswap;	// Total swap space size
		unsigned long freeswap;		// swap space still available
		unsigned short procs;		// Number of current processes
		unsigned short pad;		// explicit padding for m68k
		unsigned long totalhigh;	// Total high memory size
		unsigned long freehigh;		// Available high memory size
		unsigned int mem_unit;		// Memory unit size in bytes
		char _f[20-2*sizeof(long)-sizeof(int)];	// Padding: libc5 uses this..
};


 

sigaltstack, alternate stack for signal handlers asm/signal.h (libc: bits/sigstack.h)

		MINSIGSTKSZ	8192		// minimal stack size for a signal handler.
		SIGSTKSZ	(MINSIGSTKSZ + 32768)	// System default stack size.

		SS_ONSTACK	0x0001
		SS_DISABLE	0x0004

		typedef struct sigaltstack {	// stack_t
			void *ss_sp;		// int (dword)
			int ss_flags;		// int (dword), SS_ONSTACK or SS_DISABLE
			size_t ss_size;		// int (dword)
		} stack_t;

		// obsolete, use only for reference wrt old kernel code:
		struct sigstack	{		// Structure describing a signal stack
		    __ptr_t ss_sp;		// Signal stack pointer.
		    int ss_onstack;		// Nonzero if executing on this stack.
		  };

 

data types
	//		name			i386 asm
	// ----------------------------------------------------------------------

		byte			8 contiguous bits, one address unit
		word			two contiguous address units
		dword			four contiguous address units, 'cell'
		qword			eight contiguous address units

		char			8bit byte
		short			16bit word
		short int		16bit word
		int			32bit dword
		long			32bit dword
		long int		32bit dword
		long long		64bit qword
		long long int		64bit qword

	    'little endian' byte order, i.e. more significant bytes stored towards higher address values.

		*(data item)		dword address which points to the rsp. data item
		&(data item)		dword address at which the rsp. data item is stored

	    basic data items may be preceded by various, fancy attributes, 'unsigned' &c, which
	    are a matter of interpretation, related to a particular programming tool (e.g. "C"), 
	    not inherent to their physical representation.

	//		name			"C"
	// ----------------------------------------------------------------------

	// ----	bsd
	    unsigned char		u_char;
	    unsigned short		u_short;
	    unsigned int		u_int;
	    unsigned long		u_long

	// ---- sysv
	    unsigned char		unchar;
	    unsigned short		ushort;
	    unsigned int		uint;
	    unsigned long		ulong;

	    unsigned short		umode_t;

	// ---- Just Names...
	    ...useless but for obscure compilers' and obscure languages' obscure "data types".

	    __kernel_fd_set		fd_set
	    __kernel_dev_t		dev_t
	    __kernel_ino_t		ino_t
	    __kernel_mode_t		mode_t
	    __kernel_nlink_t		nlink_t
	    __kernel_off_t		off_t
	    __kernel_pid_t		pid_t
	    __kernel_uid_t		uid_t
	    __kernel_gid_t		gid_t
	    __kernel_daddr_t		daddr_t
	    __kernel_key_t		key_t
	    __kernel_suseconds_t	suseconds_t
	    __kernel_loff_t		loff_t;
	    __kernel_size_t		size_t;
	    __kernel_ssize_t		ssize_t;
	    __kernel_ptrdiff_t		ptrdiff_t;
	    __kernel_time_t		time_t
	    __kernel_clock_t		clock_t;
	    __kernel_caddr_t		caddr_t;

	// ---- !(__BIT_TYPES_DEFINED__)
	    __u8			u_int8_t;	// 8bit byte
	    __s8			int8_t;		// 8bit byte
	    __u16			u_int16_t;	// 16bit word
	    __s16			int16_t;	// 16bit word
	    __u32			u_int32_t;	// 32bit dword
	    __s32			int32_t;	// 32bit dword
	// ---- #endif !(__BIT_TYPES_DEFINED__)
	    __u8			uint8_t;	// 8bit byte
	    __u16			uint16_t;	// 16bit word
	    __u32			uint32_t;	// 32bit dword

	    __u64			uint64_t;	// 64bit quad word
	    __u64			u_int64_t;	// 64bit quad word
	    __s64			int64_t;	// 64bit quad word

	// ---- libc:

	    long int			__off_t; 	// Type of file sizes and offsets.
	    long long int		__off64_t;	// Type of file sizes and offsets.
	    long long int		loff_t;		// Type of file sizes and offsets.
	    int				__pid_t;      	// Type of process identifications.
	    int				__ssize_t;    	// Type of a byte count, or error.
	    int				size_t;
	    unsigned char		__u_char;
	    unsigned short		__u_short;
	    unsigned int		__u_int;
	    unsigned long		__u_long;

	    unsigned long long int	__u_quad_t;
	    long long int		__quad_t;

	    signed char			__int8_t;
	    unsigned char		__uint8_t;
	    signed short int		__int16_t;
	    unsigned short int		__uint16_t;
	    signed int			__int32_t;
	    unsigned int		__uint32_t;

	    signed long long int	__int64_t;
	    unsigned long long int	__uint64_t;

	    int				__pid_t;	// Type of process identifications.
	    int				__gid_t;	// Type of process group identifications.
	    int				__uid_t;	// Type of process user identifications.
	    int				__ssize_t;	// Type of a byte count, or error.
	    int				__daddr_t;		// The type of a disk address.
	    char			*__caddr_t;
	    long int			__time_t;
	    long int			__swblk_t;	// Type of a swap block (?)
	    long int			__clock_t;
	    unsigned long int		__fd_mask;	// One element in the file descriptor mask array.
	    int				__key_t;
	    unsigned short int		__ipc_pid_t;	// Used in `struct shmid_ds'.
	    long int			__t_scalar_t;	// Used in XTI. 
	    unsigned long int		__t_uscalar_t;
	    int				ptr_t;
	    int				__intptr_t;
	    long int			__blkcnt_t;	// Type to count number os disk blocks.
	    __u_long			__fsblkcnt_t;	// Type to count file system blocks.
	    __u_quad_t			__fsblkcnt64_t;
	    __u_long			__fsfilcnt_t;	// Type to count file system inodes.
	    __u_quad_t			__fsfilcnt64_t;
	    __u_long			__ino64_t;	// Type of file serial numbers.
	    __loff_t			__off64_t;	// Type of file sizes and offsets.
	    __quad_t			__blkcnt64_t;
	    __quad_t			*__qaddr_t;
	    __u_quad_t			__dev_t;	// Type of device numbers.
	    __u_int			__uid_t;	// Type of user identifications.
	    __u_int			__gid_t;	// Type of group identifications.
	    __u_long			__ino_t;	// Type of file serial numbers.
	    __u_int			__mode_t;	// Type of file attribute bitmasks.
	    __u_int			__nlink_t; 	// Type of file link counts.
	    __quad_t			__loff_t;	// Type of file sizes and offsets.
	    __u_long			__rlim_t;	// Type of resource counts.
	    __u_quad_t			__rlim64_t;	// Type of resource counts (LFS).
	    __u_int			__id_t;		// General type for ID.
	    struct
	      {
	        int __val[2];
	      } __fsid_t;				// Type of file system IDs.


	    // # include <bits/pthreadtypes.h>	// defines nothing wrt Sys-V/linux

 


 

[top]
[main] [back] [bot] [top]
[intro] [index] [1..64] [65..128] [129..192] [193..256] [257..] [reference] [struc] [ioctl] [pguide]

 

H.-Peter Recktenwald, Berlin, 28.Mai.2000 = .hpr.l0 = : 2232