Message types for VFS create

Change-Id: Ibeba338337eb16814b5b25f7135da958e8316a99
This commit is contained in:
Lionel Sambuc 2014-04-28 18:25:26 +02:00
parent 02dc6498da
commit 3f567bdb11
6 changed files with 83 additions and 57 deletions

View file

@ -146,6 +146,31 @@ typedef struct {
} mess_sigcalls;
_ASSERT_MSG_SIZE(mess_sigcalls);
typedef struct {
ino_t inode;
mode_t mode;
uid_t uid;
gid_t gid;
cp_grant_id_t grant;
size_t path_len;
uint8_t data[28];
} mess_vfs_fs_create;
_ASSERT_MSG_SIZE(mess_vfs_fs_create);
typedef struct {
off_t file_size;
ino_t inode;
mode_t mode;
uid_t uid;
gid_t gid;
uint8_t data[28];
} mess_fs_vfs_create;
_ASSERT_MSG_SIZE(mess_fs_vfs_create);
typedef struct {
ino_t dir_ino;
ino_t root_ino;
@ -275,6 +300,8 @@ typedef struct {
mess_mmap m_mmap;
mess_notify m_notify;
mess_sigcalls m_sigcalls;
mess_vfs_fs_create m_vfs_fs_create;
mess_fs_vfs_create m_fs_vfs_create;
mess_vfs_fs_lookup m_vfs_fs_lookup;
mess_fs_vfs_lookup m_fs_vfs_lookup;
mess_vfs_fs_readsuper m_vfs_fs_readsuper;

View file

@ -21,7 +21,7 @@ int fs_create(void)
int r;
struct puffs_node *pn_dir;
struct puffs_node *pn;
pmode_t omode;
mode_t omode;
struct puffs_newinfo pni;
struct puffs_kcn pkcnp;
PUFFS_MAKECRED(pcr, &global_kcred);
@ -36,24 +36,24 @@ int fs_create(void)
}
/* Read request message */
omode = (pmode_t) fs_m_in.REQ_MODE;
caller_uid = (uid_t) fs_m_in.REQ_UID;
caller_gid = (gid_t) fs_m_in.REQ_GID;
omode = fs_m_in.m_vfs_fs_create.mode;
caller_uid = fs_m_in.m_vfs_fs_create.uid;
caller_gid = fs_m_in.m_vfs_fs_create.gid;
/* Copy the last component (i.e., file name) */
len = fs_m_in.REQ_PATH_LEN;
len = fs_m_in.m_vfs_fs_create.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_create.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));
/* Get last directory pnode (i.e., directory that will hold the new 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_create.inode)) == NULL)
return(ENOENT);
memset(&pni, 0, sizeof(pni));
@ -63,7 +63,7 @@ int fs_create(void)
memset(&va, 0, sizeof(va));
va.va_type = VREG;
va.va_mode = (mode_t) omode;
va.va_mode = omode;
va.va_uid = caller_uid;
va.va_gid = caller_gid;
va.va_atime = va.va_mtime = va.va_ctime = cur_time;
@ -99,13 +99,13 @@ int fs_create(void)
update_timens(pn_dir, MTIME | CTIME, &cur_time);
/* Reply message */
fs_m_out.RES_INODE_NR = pn->pn_va.va_fileid;
fs_m_out.RES_MODE = pn->pn_va.va_mode;
fs_m_out.RES_FILE_SIZE = pn->pn_va.va_size;
fs_m_out.m_fs_vfs_create.inode = pn->pn_va.va_fileid;
fs_m_out.m_fs_vfs_create.mode = pn->pn_va.va_mode;
fs_m_out.m_fs_vfs_create.file_size = pn->pn_va.va_size;
/* This values are needed for the execution */
fs_m_out.RES_UID = pn->pn_va.va_uid;
fs_m_out.RES_GID = pn->pn_va.va_gid;
fs_m_out.m_fs_vfs_create.uid = pn->pn_va.va_uid;
fs_m_out.m_fs_vfs_create.gid = pn->pn_va.va_gid;
return(OK);
}

View file

@ -35,12 +35,12 @@ int do_create(void)
return EROFS;
/* Get path, name, parent inode and possibly inode for the given path. */
if ((r = get_name(m_in.REQ_GRANT, m_in.REQ_PATH_LEN, name)) != OK)
if ((r = get_name(m_in.m_vfs_fs_create.grant, m_in.m_vfs_fs_create.path_len, name)) != OK)
return r;
if (!strcmp(name, ".") || !strcmp(name, "..")) return EEXIST;
if ((parent = find_inode(m_in.REQ_INODE_NR)) == NULL)
if ((parent = find_inode(m_in.m_vfs_fs_create.inode)) == NULL)
return EINVAL;
if ((r = verify_dentry(parent, name, path, &ino)) != OK)
@ -59,7 +59,7 @@ int do_create(void)
}
/* Perform the actual create call. */
r = sffs_table->t_open(path, O_CREAT | O_EXCL | O_RDWR, m_in.REQ_MODE,
r = sffs_table->t_open(path, O_CREAT | O_EXCL | O_RDWR, m_in.m_vfs_fs_create.mode,
&handle);
if (r != OK) {
@ -115,12 +115,11 @@ int do_create(void)
add_dentry(parent, name, ino);
m_out.RES_INODE_NR = INODE_NR(ino);
m_out.RES_MODE = get_mode(ino, attr.a_mode);
m_out.RES_FILE_SIZE = attr.a_size;
m_out.RES_UID = sffs_params->p_uid;
m_out.RES_GID = sffs_params->p_gid;
m_out.RES_DEV = NO_DEV;
m_out.m_fs_vfs_create.inode = INODE_NR(ino);
m_out.m_fs_vfs_create.mode = get_mode(ino, attr.a_mode);
m_out.m_fs_vfs_create.file_size = attr.a_size;
m_out.m_fs_vfs_create.uid = sffs_params->p_uid;
m_out.m_fs_vfs_create.gid = sffs_params->p_gid;
return OK;
}

View file

@ -25,28 +25,28 @@ int fs_create()
int r;
struct inode *ldirp;
struct inode *rip;
pmode_t omode;
mode_t omode;
char lastc[NAME_MAX + 1];
/* Read request message */
omode = (pmode_t) fs_m_in.REQ_MODE;
caller_uid = (uid_t) fs_m_in.REQ_UID;
caller_gid = (gid_t) fs_m_in.REQ_GID;
omode = fs_m_in.m_vfs_fs_create.mode;
caller_uid = fs_m_in.m_vfs_fs_create.uid;
caller_gid = fs_m_in.m_vfs_fs_create.gid;
/* Try to make the file. */
/* Copy the last component (i.e., file name) */
len = fs_m_in.REQ_PATH_LEN; /* including trailing '\0' */
len = fs_m_in.m_vfs_fs_create.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_create.grant,
(vir_bytes) 0, (vir_bytes) lastc, (size_t) len);
if (err_code != OK) return err_code;
NUL(lastc, len, sizeof(lastc));
/* Get last directory inode (i.e., directory that will hold the new 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_create.inode)) == NULL)
return(ENOENT);
/* Create a new inode by calling new_node(). */
@ -61,13 +61,13 @@ int fs_create()
}
/* Reply message */
fs_m_out.RES_INODE_NR = rip->i_num;
fs_m_out.RES_MODE = rip->i_mode;
fs_m_out.RES_FILE_SIZE = rip->i_size;
fs_m_out.m_fs_vfs_create.inode = rip->i_num;
fs_m_out.m_fs_vfs_create.mode = rip->i_mode;
fs_m_out.m_fs_vfs_create.file_size = rip->i_size;
/* This values are needed for the execution */
fs_m_out.RES_UID = rip->i_uid;
fs_m_out.RES_GID = rip->i_gid;
fs_m_out.m_fs_vfs_create.uid = rip->i_uid;
fs_m_out.m_fs_vfs_create.gid = rip->i_gid;
/* Drop parent dir */
put_inode(ldirp);

View file

@ -19,25 +19,25 @@ int fs_create()
int r;
struct inode *ldirp;
struct inode *rip;
pmode_t omode;
mode_t omode;
char lastc[MFS_NAME_MAX];
/* Read request message */
omode = (pmode_t) fs_m_in.REQ_MODE;
caller_uid = (uid_t) fs_m_in.REQ_UID;
caller_gid = (gid_t) fs_m_in.REQ_GID;
omode = fs_m_in.m_vfs_fs_create.mode;
caller_uid = fs_m_in.m_vfs_fs_create.uid;
caller_gid = fs_m_in.m_vfs_fs_create.gid;
/* Try to make the file. */
/* Copy the last component (i.e., file name) */
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_create.path_len, sizeof(lastc));
err_code = sys_safecopyfrom(VFS_PROC_NR, fs_m_in.m_vfs_fs_create.grant,
(vir_bytes) 0, (vir_bytes) lastc, len);
if (err_code != OK) return err_code;
NUL(lastc, len, sizeof(lastc));
/* Get last directory inode (i.e., directory that will hold the new 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_create.inode)) == NULL)
return(ENOENT);
/* Create a new inode by calling new_node(). */
@ -52,13 +52,13 @@ int fs_create()
}
/* Reply message */
fs_m_out.RES_INODE_NR = rip->i_num;
fs_m_out.RES_MODE = rip->i_mode;
fs_m_out.RES_FILE_SIZE = rip->i_size;
fs_m_out.m_fs_vfs_create.inode = rip->i_num;
fs_m_out.m_fs_vfs_create.mode = rip->i_mode;
fs_m_out.m_fs_vfs_create.file_size = rip->i_size;
/* These values are needed for the execution */
fs_m_out.RES_UID = rip->i_uid;
fs_m_out.RES_GID = rip->i_gid;
fs_m_out.m_fs_vfs_create.uid = rip->i_uid;
fs_m_out.m_fs_vfs_create.gid = rip->i_gid;
/* Drop parent dir */
put_inode(ldirp);

View file

@ -186,12 +186,12 @@ int req_create(
/* Fill in request message */
m.m_type = REQ_CREATE;
m.REQ_INODE_NR = (pino_t) inode_nr;
m.REQ_MODE = (pmode_t) omode;
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_create.inode = inode_nr;
m.m_vfs_fs_create.mode = omode;
m.m_vfs_fs_create.uid = uid;
m.m_vfs_fs_create.gid = gid;
m.m_vfs_fs_create.grant = grant_id;
m.m_vfs_fs_create.path_len = len;
/* Send/rec request */
r = fs_sendrec(fs_e, &m);
@ -200,11 +200,11 @@ int req_create(
/* Fill in response structure */
res->fs_e = m.m_source;
res->inode_nr = (ino_t) m.RES_INODE_NR;
res->fmode = (mode_t) m.RES_MODE;
res->fsize = m.RES_FILE_SIZE;
res->uid = (uid_t) m.RES_UID;
res->gid = (gid_t) m.RES_GID;
res->inode_nr = m.m_fs_vfs_create.inode;
res->fmode = m.m_fs_vfs_create.mode;
res->fsize = m.m_fs_vfs_create.file_size;
res->uid = m.m_fs_vfs_create.uid;
res->gid = m.m_fs_vfs_create.gid;
res->dev = NO_DEV;
return(OK);