AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
pipe.h
Go to the documentation of this file.
1#ifndef _FS_PIPE_H
2#define _FS_PIPE_H
3
4#include <core/system.h>
5
6struct pipe;
7
8#include <fs/vfs.h>
9#include <ds/ringbuf.h>
10
11/* Pipes and FIFOs (fs/pipe.c). */
12
13/* The size of a pipe's buffer. */
14#define PIPE_BUFLEN 1024
15
17struct pipe {
19 struct vnode *r_node;
20 struct vnode *w_node;
21 struct vnode *rw_node;
22
24 struct waitq queue;
25
29 unsigned long r_opens;
30 unsigned long w_opens;
31
33 struct vnode *fifo;
34
36 struct ringbuf *ring;
37};
38
39/* The pipes' filesystem; makes a pipe's two ends; opens a FIFO. */
40extern struct fs pipefs;
41int pipefs_pipe(struct file *read, struct file *write);
42int pipefs_fifo_open(struct file *file);
43
44#endif /* ! _FS_PIPE_H */
struct fs pipefs
Definition pipe.c:308
int pipefs_fifo_open(struct file *file)
Opens a FIFO: the open file's vnode becomes an end of the FIFO's pipe, made by its first open.
Definition pipe.c:239
int pipefs_pipe(struct file *read, struct file *write)
Makes an anonymous pipe, for pipe(): one open file for each end.
Definition pipe.c:199
An open file (POSIX's "open file description", fs/file.c).
Definition vfs.h:157
A filesystem type.
Definition vfs.h:98
A pipe, or a FIFO's pipe.
Definition pipe.h:17
struct waitq queue
readers and writers sleep here
Definition pipe.h:24
struct vnode * r_node
its ends, NULL once closed (rw_node: a FIFO opened read-write)
Definition pipe.h:19
struct vnode * w_node
Definition pipe.h:20
unsigned long w_opens
Definition pipe.h:30
struct vnode * fifo
the FIFO this is the pipe of, or NULL for pipe()
Definition pipe.h:33
struct ringbuf * ring
the data written, not read yet
Definition pipe.h:36
unsigned long r_opens
how many times a FIFO was opened for reading and for writing, so far: an open waiting for the other s...
Definition pipe.h:29
struct vnode * rw_node
Definition pipe.h:21
A ring buffer.
Definition ringbuf.h:18
A file in memory (a vnode): what its inode says, and the kernel's own state.
Definition vfs.h:113
Definition waitq.h:19