PatchworkOS  28a9544
A non-POSIX operating system.
Loading...
Searching...
No Matches

Pipes. More...

Data Structures

struct  pipe_private_t
 

Functions

static uint64_t pipe_open (file_t *file)
 
static uint64_t pipe_open2 (file_t *files[2])
 
static void pipe_close (file_t *file)
 
static uint64_t pipe_read (file_t *file, void *buffer, uint64_t count, uint64_t *offset)
 
static uint64_t pipe_write (file_t *file, const void *buffer, uint64_t count, uint64_t *offset)
 
static wait_queue_tpipe_poll (file_t *file, poll_events_t *revents)
 
uint64_t pipe_init (void)
 
void pipe_deinit (void)
 

Variables

static dentry_tpipeDir = NULL
 
static dentry_tnewFile = NULL
 
static file_ops_t fileOps
 

Detailed Description

Pipes.

Pipes are exposed in the /dev/pipe directory. Pipes are unidirectional communication channels that can be used for inter-process communication (IPC).

Creating Pipes

Pipes are created using the /dev/pipe/new file. Opening this file using open() will return one file descriptor that can be used for both reading and writing. To create a pipe with separate file descriptors for reading and writing, use open2() with the /dev/pipe/new file.

Using Pipes

Pipes can be read from and written to using the expected read() and write() system calls. Pipes are blocking and pollable, following expected POSIX semantics.

Function Documentation

◆ pipe_close()

static void pipe_close ( file_t file)
static

◆ pipe_deinit()

void pipe_deinit ( void  )

Definition at line 259 of file pipe.c.

References DEREF, newFile, NULL, and pipeDir.

Referenced by _module_procedure().

◆ pipe_init()

uint64_t pipe_init ( void  )

Definition at line 239 of file pipe.c.

References DEREF, ERR, fileOps, LOG_ERR, newFile, NULL, pipeDir, sysfs_dir_new(), and sysfs_file_new().

Referenced by _module_procedure().

◆ pipe_open()

static uint64_t pipe_open ( file_t file)
static

◆ pipe_open2()

static uint64_t pipe_open2 ( file_t files[2])
static

◆ pipe_poll()

static wait_queue_t * pipe_poll ( file_t file,
poll_events_t revents 
)
static

Definition at line 213 of file pipe.c.

References file, LOCK_SCOPE, POLLIN, POLLOUT, dentry_t::private, ring_data_length(), and ring_free_length().

◆ pipe_read()

static uint64_t pipe_read ( file_t file,
void *  buffer,
uint64_t  count,
uint64_t offset 
)
static

◆ pipe_write()

static uint64_t pipe_write ( file_t file,
const void *  buffer,
uint64_t  count,
uint64_t offset 
)
static

Variable Documentation

◆ fileOps

file_ops_t fileOps
static
Initial value:
= {
.open = pipe_open,
.open2 = pipe_open2,
.close = pipe_close,
.read = pipe_read,
.write = pipe_write,
.poll = pipe_poll,
}
static uint64_t pipe_open(file_t *file)
Definition pipe.c:53
static void pipe_close(file_t *file)
Definition pipe.c:106
static uint64_t pipe_write(file_t *file, const void *buffer, uint64_t count, uint64_t *offset)
Definition pipe.c:172
static uint64_t pipe_open2(file_t *files[2])
Definition pipe.c:79
static uint64_t pipe_read(file_t *file, void *buffer, uint64_t count, uint64_t *offset)
Definition pipe.c:132
static wait_queue_t * pipe_poll(file_t *file, poll_events_t *revents)
Definition pipe.c:213

Definition at line 230 of file pipe.c.

Referenced by pipe_init().

◆ newFile

dentry_t* newFile = NULL
static

Definition at line 51 of file pipe.c.

Referenced by pipe_deinit(), and pipe_init().

◆ pipeDir

dentry_t* pipeDir = NULL
static

Definition at line 50 of file pipe.c.

Referenced by pipe_deinit(), and pipe_init().