Message types for VFS mkdir

Change-Id: I05ea5b5e14e28afdfab6edcabc1dc761389f2638
This commit is contained in:
Lionel Sambuc 2014-04-30 19:44:48 +02:00
parent 169e0314ea
commit 2dc27154ad
6 changed files with 43 additions and 29 deletions

View file

@ -258,6 +258,19 @@ typedef struct {
} mess_fs_vfs_lookup;
_ASSERT_MSG_SIZE(mess_fs_vfs_lookup);
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_mkdir;
_ASSERT_MSG_SIZE(mess_vfs_fs_mkdir);
typedef struct {
ino_t inode;
@ -490,6 +503,7 @@ typedef struct {
mess_vfs_fs_link m_vfs_fs_link;
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_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

@ -216,22 +216,22 @@ int fs_mkdir(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_mkdir.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_mkdir.grant,
(vir_bytes) 0, (vir_bytes) pcn.pcn_name,
(phys_bytes) 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_mkdir.uid;
caller_gid = fs_m_in.m_vfs_fs_mkdir.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_mkdir.inode)) == NULL)
return(ENOENT);
cur_time = clock_timespec();
@ -241,7 +241,7 @@ int fs_mkdir(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_mkdir.mode;
va.va_uid = caller_uid;
va.va_gid = caller_gid;
va.va_atime = va.va_mtime = va.va_ctime = cur_time;

View file

@ -140,19 +140,19 @@ int do_mkdir(void)
return EROFS;
/* Get the path string and possibly an 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_mkdir.grant, m_in.m_vfs_fs_mkdir.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_mkdir.inode)) == NULL)
return EINVAL;
if ((r = verify_dentry(parent, name, path, &ino)) != OK)
return r;
/* Perform the actual mkdir call. */
r = sffs_table->t_mkdir(path, m_in.REQ_MODE);
r = sffs_table->t_mkdir(path, m_in.m_vfs_fs_mkdir.mode);
if (r != OK) {
if (ino != NULL)

View file

@ -124,24 +124,24 @@ int fs_mkdir()
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_mkdir.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_mkdir.grant,
(vir_bytes) 0, (vir_bytes) lastc, (phys_bytes) 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_mkdir.uid;
caller_gid = fs_m_in.m_vfs_fs_mkdir.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_mkdir.inode)) == NULL)
return(ENOENT);
/* Next make the inode. If that fails, return error code. */
rip = new_node(ldirp, lastc, (pino_t) fs_m_in.REQ_MODE, (block_t) 0);
rip = new_node(ldirp, lastc, fs_m_in.m_vfs_fs_mkdir.mode, (block_t) 0);
if(rip == NULL || err_code == EEXIST) {
put_inode(rip); /* can't make dir: it already exists */
@ -155,7 +155,7 @@ int fs_mkdir()
/* Now make dir entries for . and .. unless the disk is completely full. */
/* Use dot1 and dot2, so the mode of the directory isn't important. */
rip->i_mode = (pmode_t) fs_m_in.REQ_MODE; /* set mode */
rip->i_mode = fs_m_in.m_vfs_fs_mkdir.mode; /* set mode */
/* enter . in the new dir*/
r1 = search_dir(rip, dot1, &dot, ENTER, IGN_PERM, I_DIRECTORY);
/* enter .. in the new dir */

View file

@ -112,21 +112,21 @@ int fs_mkdir()
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_mkdir.path_len, sizeof(lastc));
err_code = sys_safecopyfrom(VFS_PROC_NR, fs_m_in.m_vfs_fs_mkdir.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_mkdir.uid;
caller_gid = fs_m_in.m_vfs_fs_mkdir.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_mkdir.inode)) == NULL)
return(ENOENT);
/* Next make the inode. If that fails, return error code. */
rip = new_node(ldirp, lastc, (pmode_t) fs_m_in.REQ_MODE, (zone_t) 0);
rip = new_node(ldirp, lastc, fs_m_in.m_vfs_fs_mkdir.mode, (zone_t) 0);
if(rip == NULL || err_code == EEXIST) {
put_inode(rip); /* can't make dir: it already exists */
@ -140,7 +140,7 @@ int fs_mkdir()
/* Now make dir entries for . and .. unless the disk is completely full. */
/* Use dot1 and dot2, so the mode of the directory isn't important. */
rip->i_mode = (pmode_t) fs_m_in.REQ_MODE; /* set mode */
rip->i_mode = fs_m_in.m_vfs_fs_mkdir.mode; /* set mode */
r1 = search_dir(rip, dot1, &dot, ENTER, IGN_PERM);/* enter . in the new dir*/
r2 = search_dir(rip, dot2, &dotdot, ENTER, IGN_PERM); /* enter .. in the new
dir */

View file

@ -542,12 +542,12 @@ int req_mkdir(
/* Fill in request message */
m.m_type = REQ_MKDIR;
m.REQ_INODE_NR = (pino_t) inode_nr;
m.REQ_MODE = (pmode_t) dmode;
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_mkdir.inode = inode_nr;
m.m_vfs_fs_mkdir.mode = dmode;
m.m_vfs_fs_mkdir.uid = uid;
m.m_vfs_fs_mkdir.gid = gid;
m.m_vfs_fs_mkdir.grant = grant_id;
m.m_vfs_fs_mkdir.path_len = len;
/* Send/rec request */
r = fs_sendrec(fs_e, &m);