Repository navigation
Expand file tree
/
Copy pathopen.c
More file actions
54 lines (47 loc) · 1.33 KB
/
Copy pathopen.c
File metadata and controls
54 lines (47 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
6E33
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "fs.h"
#include <sys/stat.h>
#include "buf.h"
#include "inode.h"
#include <minix/vfsif.h>
/*===========================================================================*
* fs_newnode *
*===========================================================================*/
int fs_newnode(message *fs_m_in, message *fs_m_out)
{
register int r = OK;
mode_t bits;
struct inode *rip;
uid_t uid;
gid_t gid;
dev_t dev;
uid = fs_m_in->m_vfs_fs_newnode.uid;
gid = fs_m_in->m_vfs_fs_newnode.gid;
bits = fs_m_in->m_vfs_fs_newnode.mode;
dev = fs_m_in->m_vfs_fs_newnode.device;
/* Try to allocate the inode */
if( (rip = alloc_inode(dev, bits, uid, gid) ) == NULL) return(err_code);
switch (bits & S_IFMT) {
case S_IFBLK:
case S_IFCHR:
rip->i_rdev = dev; /* Major/minor dev numbers */
break;
case S_IFIFO:
if ((get_block(dev, rip->i_num)) == NULL)
r = EIO;
break;
default:
r = EIO; /* Unsupported file type */
}
if (r != OK) {
free_inode(rip);
} else {
/* Fill in the fields of the response message */
fs_m_out->m_fs_vfs_newnode.inode = rip->i_num;
fs_m_out->m_fs_vfs_newnode.mode = rip->i_mode;
fs_m_out->m_fs_vfs_newnode.file_size = rip->i_size;
fs_m_out->m_fs_vfs_newnode.uid = rip->i_uid;
fs_m_out->m_fs_vfs_newnode.gid = rip->i_gid;
fs_m_out->m_fs_vfs_newnode.device = dev;
}
return(r);
}