The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
pty.c File Reference

Macros

#define RING_SIZE   4096
 pseudo-terminals (see pty.h).
#define LINE_MAX   1024
#define MAX_LINES   64
#define CHUNK   256
#define CTRL(key)
#define PTMX_NUMBER   DEVICE_NUMBER(5, 2)
#define PTS_MAJOR   136

Typedefs

typedef struct pty pty_t

Functions

void pty_init (void)
 register /dev/ptmx.
device_t * pty_slave_device (uint32_t index)
 the device of /dev/pts/N (devfs uses it to open the slave side).
bool pty_next (uint32_t *index)
 the lowest pair number at or above *index that exists (devfs lists them).

Macro Definition Documentation

◆ RING_SIZE

#define RING_SIZE   4096

pseudo-terminals (see pty.h).

each pair has two rings: input (master to slave, after the line discipline) and output (slave to master, after output processing; echo goes there too). in canonical mode, typed bytes collect in an edit buffer; a newline or VEOF moves the line into the input ring and adds its length to a queue of lines, and a read takes at most one line. a line of length 0 in the queue is an end of file.

lifetime: the master's file and every open of the slave hold the pair. when the master closes, the slave reads the end of file, its writes get EIO, and the session gets SIGHUP. the pair is freed when both sides are closed. the devices of /dev/pts/N are a static table, so devfs can hold one while the pair goes away.

locking: one spinlock for all pairs. user memory is copied in and out through a buffer on the stack, outside the lock.

◆ LINE_MAX

#define LINE_MAX   1024

◆ MAX_LINES

#define MAX_LINES   64

◆ CHUNK

#define CHUNK   256

◆ CTRL

#define CTRL ( key)
Value:
((key) & 0x1f)

◆ PTMX_NUMBER

#define PTMX_NUMBER   DEVICE_NUMBER(5, 2)

◆ PTS_MAJOR

#define PTS_MAJOR   136

Typedef Documentation

◆ pty_t

typedef struct pty pty_t

Function Documentation

◆ pty_init()

void pty_init ( void )

register /dev/ptmx.

call once at boot, after the device registry.

◆ pty_slave_device()

device_t * pty_slave_device ( uint32_t index)

the device of /dev/pts/N (devfs uses it to open the slave side).

Returns
the device, or NULL if pair N does not exist.

◆ pty_next()

bool pty_next ( uint32_t * index)

the lowest pair number at or above *index that exists (devfs lists them).

Parameters
indexin: where to start; out: the pair found.
Returns
false if there is none.