Skip to content

Instantly share code, notes, and snippets.

@rightson
Created December 13, 2017 10:56
Show Gist options
  • Save rightson/96cdbbed4149c90d4be78c70b08997e3 to your computer and use it in GitHub Desktop.
Save rightson/96cdbbed4149c90d4be78c70b08997e3 to your computer and use it in GitHub Desktop.
TTY line discipline example structure
struct tty_ldisc {
int magic;
char *name;
int num;
int flags; /* * The following routines are called from above. */
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
*); /* * The following routines are called from below. */
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 *);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment