Message types for VFS mknod

Change-Id: I41772ffe0efc520b3cd204857c33c8c76d81a5a8
This commit is contained in:
Lionel Sambuc 2014-04-30 20:00:29 +02:00
parent 2dc27154ad
commit f90ed467fc
5 changed files with 43 additions and 28 deletions

View file

@ -271,6 +271,20 @@ typedef struct {
} mess_vfs_fs_mkdir;
_ASSERT_MSG_SIZE(mess_vfs_fs_mkdir);
typedef struct {
dev_t device;
ino_t inode;
mode_t mode;
uid_t uid;
gid_t gid;
cp_grant_id_t grant;
size_t path_len;
uint8_t data[20];
} mess_vfs_fs_mknod;
_ASSERT_MSG_SIZE(mess_vfs_fs_mknod);
typedef struct {
ino_t inode;
@ -504,6 +518,7 @@ typedef struct {
mess_vfs_fs_lookup m_vfs_fs_lookup;
mess_fs_vfs_lookup m_fs_vfs_lookup;
mess_vfs_fs_mkdir m_vfs_fs_mkdir;
mess_vfs_fs_mknod m_vfs_fs_mknod;
mess_vfs_fs_mountpoint m_vfs_fs_mountpoint;
mess_vfs_fs_new_driver m_vfs_fs_new_driver;
mess_vfs_fs_putnode m_vfs_fs_putnode;

View file

@ -133,22 +133,22 @@ int fs_mknod(void)
}
/* Copy the last component and set up caller's user and group id */
len = fs_m_in.REQ_PATH_LEN;
len = fs_m_in.m_vfs_fs_mknod.path_len;
pcn.pcn_namelen = len - 1;
if (pcn.pcn_namelen > NAME_MAX)
return(ENAMETOOLONG);
err_code = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_GRANT,
err_code = sys_safecopyfrom(VFS_PROC_NR, fs_m_in.m_vfs_fs_mknod.grant,
(vir_bytes) 0, (vir_bytes) pcn.pcn_name,
(size_t) len);
if (err_code != OK) return(err_code);
NUL(pcn.pcn_name, len, sizeof(pcn.pcn_name));
caller_uid = (uid_t) fs_m_in.REQ_UID;
caller_gid = (gid_t) fs_m_in.REQ_GID;
caller_uid = fs_m_in.m_vfs_fs_mknod.uid;
caller_gid = fs_m_in.m_vfs_fs_mknod.gid;
/* Get last directory pnode */
if ((pn_dir = puffs_pn_nodewalk(global_pu, 0, &fs_m_in.REQ_INODE_NR)) == NULL)
if ((pn_dir = puffs_pn_nodewalk(global_pu, 0, &fs_m_in.m_vfs_fs_mknod.inode)) == NULL)
return(ENOENT);
memset(&pni, 0, sizeof(pni));
@ -158,10 +158,10 @@ int fs_mknod(void)
memset(&va, 0, sizeof(va));
va.va_type = VDIR;
va.va_mode = (mode_t) fs_m_in.REQ_MODE;
va.va_mode = fs_m_in.m_vfs_fs_mknod.mode;
va.va_uid = caller_uid;
va.va_gid = caller_gid;
va.va_rdev = fs_m_in.REQ_DEV;
va.va_rdev = fs_m_in.m_vfs_fs_mknod.device;
va.va_atime = va.va_mtime = va.va_ctime = cur_time;
if (buildpath) {

View file

@ -86,25 +86,25 @@ int fs_mknod()
phys_bytes len;
/* Copy the last component and set up caller's user and group id */
len = fs_m_in.REQ_PATH_LEN; /* including trailing '\0' */
len = fs_m_in.m_vfs_fs_mknod.path_len; /* including trailing '\0' */
if (len > NAME_MAX + 1 || len > EXT2_NAME_MAX + 1)
return(ENAMETOOLONG);
err_code = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_GRANT,
err_code = sys_safecopyfrom(VFS_PROC_NR, fs_m_in.m_vfs_fs_mknod.grant,
(vir_bytes) 0, (vir_bytes) lastc, (size_t) len);
if (err_code != OK) return err_code;
NUL(lastc, len, sizeof(lastc));
caller_uid = (uid_t) fs_m_in.REQ_UID;
caller_gid = (gid_t) fs_m_in.REQ_GID;
caller_uid = fs_m_in.m_vfs_fs_mknod.uid;
caller_gid = fs_m_in.m_vfs_fs_mknod.gid;
/* Get last directory inode */
if((ldirp = get_inode(fs_dev, (pino_t) fs_m_in.REQ_INODE_NR)) == NULL)
if((ldirp = get_inode(fs_dev, fs_m_in.m_vfs_fs_mknod.inode)) == NULL)
return(ENOENT);
/* Try to create the new node */
ip = new_node(ldirp, lastc, (pmode_t) fs_m_in.REQ_MODE,
(block_t) fs_m_in.REQ_DEV);
ip = new_node(ldirp, lastc, fs_m_in.m_vfs_fs_mknod.mode,
(block_t) fs_m_in.m_vfs_fs_mknod.device);
put_inode(ip);
put_inode(ldirp);

View file

@ -77,22 +77,22 @@ int fs_mknod()
phys_bytes len;
/* Copy the last component and set up caller's user and group id */
len = min( (unsigned) fs_m_in.REQ_PATH_LEN, sizeof(lastc));
err_code = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_GRANT,
len = min(fs_m_in.m_vfs_fs_mknod.path_len, sizeof(lastc));
err_code = sys_safecopyfrom(VFS_PROC_NR, fs_m_in.m_vfs_fs_mknod.grant,
(vir_bytes) 0, (vir_bytes) lastc, (size_t) len);
if (err_code != OK) return err_code;
NUL(lastc, len, sizeof(lastc));
caller_uid = (uid_t) fs_m_in.REQ_UID;
caller_gid = (gid_t) fs_m_in.REQ_GID;
caller_uid = fs_m_in.m_vfs_fs_mknod.uid;
caller_gid = fs_m_in.m_vfs_fs_mknod.gid;
/* Get last directory inode */
if((ldirp = get_inode(fs_dev, (pino_t) fs_m_in.REQ_INODE_NR)) == NULL)
if((ldirp = get_inode(fs_dev, fs_m_in.m_vfs_fs_mknod.inode)) == NULL)
return(ENOENT);
/* Try to create the new node */
ip = new_node(ldirp, lastc, (pmode_t) fs_m_in.REQ_MODE,
(zone_t) fs_m_in.REQ_DEV);
ip = new_node(ldirp, lastc, fs_m_in.m_vfs_fs_mknod.mode,
(zone_t) fs_m_in.m_vfs_fs_mknod.device);
put_inode(ip);
put_inode(ldirp);

View file

@ -582,13 +582,13 @@ int req_mknod(
/* Fill in request message */
m.m_type = REQ_MKNOD;
m.REQ_INODE_NR = (pino_t) inode_nr;
m.REQ_MODE = (pmode_t) dmode;
m.REQ_DEV = dev;
m.REQ_UID = (puid_t) uid;
m.REQ_GID = (pgid_t) gid;
m.REQ_GRANT = grant_id;
m.REQ_PATH_LEN = len;
m.m_vfs_fs_mknod.inode = inode_nr;
m.m_vfs_fs_mknod.mode = dmode;
m.m_vfs_fs_mknod.device = dev;
m.m_vfs_fs_mknod.uid = uid;
m.m_vfs_fs_mknod.gid = gid;
m.m_vfs_fs_mknod.grant = grant_id;
m.m_vfs_fs_mknod.path_len = len;
/* Send/rec request */
r = fs_sendrec(fs_e, &m);