. service tells you which device it couldn't stat
[minix3.git] / servers / mfs / pipe.c
blob188cf27ed113e7dc2dd571a0a2b5baf6108380b6
2 #include "fs.h"
3 #include <fcntl.h>
4 #include <signal.h>
5 #include <minix/callnr.h>
6 #include <minix/endpoint.h>
7 #include <minix/com.h>
8 #include <sys/select.h>
9 #include <sys/time.h>
10 #include "inode.h"
11 #include "super.h"
13 #include <minix/vfsif.h>
17 /*===========================================================================*
18 * fs_pipe *
19 *===========================================================================*/
20 PUBLIC int fs_pipe(void)
22 struct inode *rip;
24 /* Get caller's user and group id from the request */
25 caller_uid = fs_m_in.REQ_UID;
26 caller_gid = fs_m_in.REQ_GID;
28 /* Try to allocate the inode */
29 if ( (rip = alloc_inode(fs_dev, I_REGULAR) ) == NIL_INODE) {
30 return err_code;
33 /* !!! already checked in alloc_inode
34 if (read_only(rip) != OK)
35 panic(__FILE__,"pipe device is read only", NO_NUM);
38 /* Fill in the fields of the inode */
39 rip->i_pipe = I_PIPE;
40 rip->i_mode &= ~I_REGULAR;
41 rip->i_mode |= I_NAMED_PIPE; /* pipes and FIFOs have this bit set */
43 /* We'll need it twice, nothing can go wrong here */
44 dup_inode(rip);
45 rw_inode(rip, WRITING); /* mark inode as allocated */
46 rip->i_update = ATIME | CTIME | MTIME;
48 /* Fill in the fields of the response message */
49 fs_m_out.m_source = fs_dev; /* filled with FS endpoint by the system */
50 fs_m_out.RES_INODE_NR = rip->i_num;
51 fs_m_out.RES_MODE = rip->i_mode;
52 fs_m_out.RES_INODE_INDEX = (rip - &inode[0]) / sizeof(struct inode);
54 return OK;