tools/llvm: Do not build with symbols
[minix3.git] / minix / fs / pfs / open.c
blobb3f17643cb93fa14eadf60a3432616feac6491c8
1 #include "fs.h"
2 #include <sys/stat.h>
3 #include "buf.h"
4 #include "inode.h"
5 #include <minix/vfsif.h>
8 /*===========================================================================*
9 * fs_newnode *
10 *===========================================================================*/
11 int fs_newnode(message *fs_m_in, message *fs_m_out)
13 register int r = OK;
14 mode_t bits;
15 struct inode *rip;
16 uid_t uid;
17 gid_t gid;
18 dev_t dev;
20 uid = fs_m_in->m_vfs_fs_newnode.uid;
21 gid = fs_m_in->m_vfs_fs_newnode.gid;
22 bits = fs_m_in->m_vfs_fs_newnode.mode;
23 dev = fs_m_in->m_vfs_fs_newnode.device;
25 /* Try to allocate the inode */
26 if( (rip = alloc_inode(dev, bits, uid, gid) ) == NULL) return(err_code);
28 switch (bits & S_IFMT) {
29 case S_IFBLK:
30 case S_IFCHR:
31 rip->i_rdev = dev; /* Major/minor dev numbers */
32 break;
33 case S_IFIFO:
34 if ((get_block(dev, rip->i_num)) == NULL)
35 r = EIO;
36 break;
37 default:
38 r = EIO; /* Unsupported file type */
41 if (r != OK) {
42 free_inode(rip);
43 } else {
44 /* Fill in the fields of the response message */
45 fs_m_out->m_fs_vfs_newnode.inode = rip->i_num;
46 fs_m_out->m_fs_vfs_newnode.mode = rip->i_mode;
47 fs_m_out->m_fs_vfs_newnode.file_size = rip->i_size;
48 fs_m_out->m_fs_vfs_newnode.uid = rip->i_uid;
49 fs_m_out->m_fs_vfs_newnode.gid = rip->i_gid;
50 fs_m_out->m_fs_vfs_newnode.device = dev;
53 return(r);