ddeb562e1a
- simplify and repair UDS request handling state machine; - simplify interface used between internal modules; - implement missing support for nonblocking I/O; - fix select implementation; - clean up global variables. Change-Id: Ia82c5c6f05cc3f0a498efc9a26de14b1cde6eace
54 lines
1.2 KiB
C
54 lines
1.2 KiB
C
#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;
|
|
pmode_t bits;
|
|
struct inode *rip;
|
|
uid_t uid;
|
|
gid_t gid;
|
|
dev_t dev;
|
|
|
|
uid = (uid_t) fs_m_in->REQ_UID;
|
|
gid = (gid_t) fs_m_in->REQ_GID;
|
|
bits = (pmode_t) fs_m_in->REQ_MODE;
|
|
dev = (dev_t) fs_m_in->REQ_DEV;
|
|
|
|
/* 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->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);
|
|
}
|