2009-12-20 21:41:50 +01:00
|
|
|
#include "fs.h"
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include "buf.h"
|
|
|
|
#include "inode.h"
|
|
|
|
#include <minix/vfsif.h>
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* fs_newnode *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int fs_newnode(message *fs_m_in, message *fs_m_out)
|
2009-12-20 21:41:50 +01:00
|
|
|
{
|
|
|
|
register int r = OK;
|
2014-04-28 18:54:18 +02:00
|
|
|
mode_t bits;
|
2009-12-20 21:41:50 +01:00
|
|
|
struct inode *rip;
|
2013-09-03 02:00:20 +02:00
|
|
|
uid_t uid;
|
|
|
|
gid_t gid;
|
2009-12-20 21:41:50 +01:00
|
|
|
dev_t dev;
|
|
|
|
|
2014-04-28 18:54:18 +02:00
|
|
|
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;
|
2009-12-20 21:41:50 +01:00
|
|
|
|
|
|
|
/* Try to allocate the inode */
|
2013-09-03 02:00:20 +02:00
|
|
|
if( (rip = alloc_inode(dev, bits, uid, gid) ) == NULL) return(err_code);
|
2009-12-20 21:41:50 +01:00
|
|
|
|
2010-03-30 17:00:09 +02:00
|
|
|
switch (bits & S_IFMT) {
|
2012-02-13 16:28:04 +01:00
|
|
|
case S_IFBLK:
|
|
|
|
case S_IFCHR:
|
2010-03-30 17:00:09 +02:00
|
|
|
rip->i_rdev = dev; /* Major/minor dev numbers */
|
|
|
|
break;
|
|
|
|
case S_IFIFO:
|
2010-05-10 15:26:00 +02:00
|
|
|
if ((get_block(dev, rip->i_num)) == NULL)
|
2010-03-30 17:00:09 +02:00
|
|
|
r = EIO;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
r = EIO; /* Unsupported file type */
|
|
|
|
}
|
2009-12-20 21:41:50 +01:00
|
|
|
|
|
|
|
if (r != OK) {
|
|
|
|
free_inode(rip);
|
|
|
|
} else {
|
|
|
|
/* Fill in the fields of the response message */
|
2014-04-28 18:54:18 +02:00
|
|
|
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;
|
2009-12-20 21:41:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return(r);
|
|
|
|
}
|