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 *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC int fs_newnode()
|
|
|
|
{
|
|
|
|
register int r = OK;
|
|
|
|
mode_t bits;
|
|
|
|
struct inode *rip;
|
|
|
|
dev_t dev;
|
|
|
|
|
2010-05-28 11:39:18 +02:00
|
|
|
caller_uid = (uid_t) fs_m_in.REQ_UID;
|
|
|
|
caller_gid = (gid_t) fs_m_in.REQ_GID;
|
|
|
|
bits = (mode_t) fs_m_in.REQ_MODE;
|
|
|
|
dev = (dev_t) fs_m_in.REQ_DEV;
|
2009-12-20 21:41:50 +01:00
|
|
|
|
|
|
|
/* Try to allocate the inode */
|
2010-05-10 15:26:00 +02:00
|
|
|
if( (rip = alloc_inode(dev, bits) ) == NULL) return(err_code);
|
2009-12-20 21:41:50 +01:00
|
|
|
|
2010-03-30 17:00:09 +02:00
|
|
|
switch (bits & S_IFMT) {
|
|
|
|
case S_IFBLK:
|
|
|
|
case S_IFCHR:
|
|
|
|
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 */
|
|
|
|
fs_m_out.RES_INODE_NR = rip->i_num;
|
|
|
|
fs_m_out.RES_MODE = rip->i_mode;
|
|
|
|
fs_m_out.RES_FILE_SIZE_LO = rip->i_size;
|
|
|
|
fs_m_out.RES_UID = rip->i_uid;
|
|
|
|
fs_m_out.RES_GID = rip->i_gid;
|
|
|
|
fs_m_out.RES_DEV = dev;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(r);
|
|
|
|
}
|
|
|
|
|