The next commit will make mode_t 32-bits, ino_t 64-bits, nlink_t 32-bits, and off_t 64-bits. However, in the protocol there is no room for that. When analyzing the usage of these data types we can see that of mode_t we currently use 15 bits and that future flags (if copied from NetBSD) are only of importance to VFS and not to the actual file system on disk. Therefore we can get away with keeping the protocol version of mode_t (pmode_t) 16 bits. At this point it is unlikely that MINIX will support file systems that can hold more than 2^32 files. Keeping the protocol version of ino_t (pino_t) 32-bits and exposing it as 64-bits to the rest of the system is fine. uid_t and gid_t are already 32-bits, but in behind the scenes they're 16-bits. This is sufficient since we don't support uid/gids larger than 2^16-1. off_t will become 64-bits, but the protocol had room reserved for that since it was revised years ago. So to make the difference clear between what the protocol supports and what is exposed to the system, we define protocol version of these data types. Change-Id: Ifb883aafb222142e69d6dcc3049a47170b78b3ee
53 lines
1.2 KiB
C
53 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;
|
|
dev_t dev;
|
|
|
|
caller_uid = (uid_t) fs_m_in->REQ_UID;
|
|
caller_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) ) == 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);
|
|
}
|