* Max allowable buffering per pipe.
* This is also the max size of the
* file created to implement the pipe.
* If this size is bigger than 4096,
* pipes will be implemented in LARG
* files, which is probably not good.
* Allocate an inode on the root device.
* Allocate 2 file structures.
* Put it all together with flags.
u
.u_ar0
[R1
] = u
.u_ar0
[R0
];
wf
->f_flag
= FWRITE
|FPIPE
;
rf
->f_flag
= FREAD
|FPIPE
;
* Read call directed to a pipe.
* Very conservative locking.
* If the head (read) has caught up with
* the tail (write), reset both to 0.
if(rp
->f_offset
[1] == ip
->i_size1
) {
if(rp
->f_offset
[1] != 0) {
* If there are not both reader and
* writer active, return without
u
.u_offset
[1] = rp
->f_offset
[1];
rp
->f_offset
[1] = u
.u_offset
[1];
* Write call directed to a pipe.
* If there are not both read and
* write sides of the pipe active,
* return error and signal too.
psignal(u
.u_procp
, SIGPIPE
);
* wait for reads to deplete
if(ip
->i_size1
== PIPSIZ
) {
* Write what is possible and
u
.u_offset
[1] = ip
->i_size1
;
u
.u_count
= min(c
, PIPSIZ
-u
.u_offset
[1]);
* set the WANT bit and sleep.
while(rp
->i_flag
&ILOCK
) {
* This routine is also used
* to unlock inodes in general.