Message types for VFS unlink & rmdir
These two request are handled by the same function in some FSes, which prevents us from using two different kinds of messages. Change-Id: Iede3a0251d8d84ca7f121c56f30f42b045b0c737
This commit is contained in:
parent
df7e2766c5
commit
169e0314ea
6 changed files with 30 additions and 19 deletions
|
@ -387,6 +387,16 @@ typedef struct {
|
|||
} mess_vfs_fs_stat;
|
||||
_ASSERT_MSG_SIZE(mess_vfs_fs_stat);
|
||||
|
||||
typedef struct {
|
||||
ino_t inode;
|
||||
|
||||
cp_grant_id_t grant;
|
||||
size_t path_len;
|
||||
|
||||
uint8_t data[40];
|
||||
} mess_vfs_fs_unlink;
|
||||
_ASSERT_MSG_SIZE(mess_vfs_fs_unlink);
|
||||
|
||||
typedef struct {
|
||||
ino_t inode;
|
||||
time_t actime;
|
||||
|
@ -490,6 +500,7 @@ typedef struct {
|
|||
mess_vfs_fs_rename m_vfs_fs_rename;
|
||||
mess_vfs_fs_slink m_vfs_fs_slink;
|
||||
mess_vfs_fs_stat m_vfs_fs_stat;
|
||||
mess_vfs_fs_unlink m_vfs_fs_unlink;
|
||||
mess_vfs_fs_utime m_vfs_fs_utime;
|
||||
mess_vfs_utimens m_vfs_utimens;
|
||||
mess_vm_vfs_mmap m_vm_vfs_mmap;
|
||||
|
|
|
@ -408,18 +408,18 @@ int fs_unlink(void)
|
|||
int len;
|
||||
|
||||
/* Copy the last component */
|
||||
len = fs_m_in.REQ_PATH_LEN;
|
||||
len = fs_m_in.m_vfs_fs_unlink.path_len;
|
||||
pcn.pcn_namelen = len - 1;
|
||||
if (pcn.pcn_namelen > NAME_MAX)
|
||||
return(ENAMETOOLONG);
|
||||
|
||||
r = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_GRANT,
|
||||
r = sys_safecopyfrom(VFS_PROC_NR, fs_m_in.m_vfs_fs_unlink.grant,
|
||||
(vir_bytes) 0, (vir_bytes) pcn.pcn_name,
|
||||
(size_t) len);
|
||||
if (r != OK) return (r);
|
||||
NUL(pcn.pcn_name, len, sizeof(pcn.pcn_name));
|
||||
|
||||
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_unlink.inode)) == NULL)
|
||||
return(EINVAL);
|
||||
|
||||
/* The last directory exists. Does the file also exist? */
|
||||
|
|
|
@ -245,12 +245,12 @@ int do_unlink(void)
|
|||
return EROFS;
|
||||
|
||||
/* Get the path string and possibly preexisting 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_unlink.grant, m_in.m_vfs_fs_unlink.path_len, name)) != OK)
|
||||
return r;
|
||||
|
||||
if (!strcmp(name, ".") || !strcmp(name, "..")) return EPERM;
|
||||
|
||||
if ((parent = find_inode(m_in.REQ_INODE_NR)) == NULL)
|
||||
if ((parent = find_inode(m_in.m_vfs_fs_unlink.inode)) == NULL)
|
||||
return EINVAL;
|
||||
|
||||
if ((r = verify_dentry(parent, name, path, &ino)) != OK)
|
||||
|
@ -292,13 +292,13 @@ int do_rmdir(void)
|
|||
return EROFS;
|
||||
|
||||
/* Get the path string and possibly preexisting 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_unlink.grant, m_in.m_vfs_fs_unlink.path_len, name)) != OK)
|
||||
return r;
|
||||
|
||||
if (!strcmp(name, ".")) return EINVAL;
|
||||
if (!strcmp(name, "..")) return ENOTEMPTY;
|
||||
|
||||
if ((parent = find_inode(m_in.REQ_INODE_NR)) == NULL)
|
||||
if ((parent = find_inode(m_in.m_vfs_fs_unlink.inode)) == NULL)
|
||||
return EINVAL;
|
||||
|
||||
if ((r = verify_dentry(parent, name, path, &ino)) != OK)
|
||||
|
|
|
@ -130,17 +130,17 @@ int fs_unlink()
|
|||
phys_bytes len;
|
||||
|
||||
/* Copy the last component */
|
||||
len = fs_m_in.REQ_PATH_LEN; /* including trailing '\0' */
|
||||
len = fs_m_in.m_vfs_fs_unlink.path_len; /* including trailing '\0' */
|
||||
if (len > NAME_MAX + 1 || len > EXT2_NAME_MAX + 1)
|
||||
return(ENAMETOOLONG);
|
||||
|
||||
r = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_GRANT,
|
||||
r = sys_safecopyfrom(VFS_PROC_NR, fs_m_in.m_vfs_fs_unlink.grant,
|
||||
(vir_bytes) 0, (vir_bytes) string, (size_t) len);
|
||||
if (r != OK) return r;
|
||||
NUL(string, len, sizeof(string));
|
||||
|
||||
/* Temporarily open the dir. */
|
||||
if( (rldirp = get_inode(fs_dev, (pino_t) fs_m_in.REQ_INODE_NR)) == NULL)
|
||||
if((rldirp = get_inode(fs_dev, fs_m_in.m_vfs_fs_unlink.inode)) == NULL)
|
||||
return(EINVAL);
|
||||
|
||||
/* The last directory exists. Does the file also exist? */
|
||||
|
|
|
@ -122,14 +122,14 @@ int fs_unlink()
|
|||
phys_bytes len;
|
||||
|
||||
/* Copy the last component */
|
||||
len = min( (unsigned) fs_m_in.REQ_PATH_LEN, sizeof(string));
|
||||
r = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_GRANT,
|
||||
len = min(fs_m_in.m_vfs_fs_unlink.path_len, sizeof(string));
|
||||
r = sys_safecopyfrom(VFS_PROC_NR, fs_m_in.m_vfs_fs_unlink.grant,
|
||||
(vir_bytes) 0, (vir_bytes) string, (size_t) len);
|
||||
if (r != OK) return r;
|
||||
NUL(string, len, sizeof(string));
|
||||
|
||||
/* Temporarily open the dir. */
|
||||
if( (rldirp = get_inode(fs_dev, (pino_t) fs_m_in.REQ_INODE_NR)) == NULL)
|
||||
if((rldirp = get_inode(fs_dev, fs_m_in.m_vfs_fs_unlink.inode)) == NULL)
|
||||
return(EINVAL);
|
||||
|
||||
/* The last directory exists. Does the file also exist? */
|
||||
|
|
|
@ -978,9 +978,9 @@ char *lastc;
|
|||
|
||||
/* Fill in request message */
|
||||
m.m_type = REQ_RMDIR;
|
||||
m.REQ_INODE_NR = (pino_t) inode_nr;
|
||||
m.REQ_GRANT = grant_id;
|
||||
m.REQ_PATH_LEN = len;
|
||||
m.m_vfs_fs_unlink.inode = inode_nr;
|
||||
m.m_vfs_fs_unlink.grant = grant_id;
|
||||
m.m_vfs_fs_unlink.path_len = len;
|
||||
|
||||
/* Send/rec request */
|
||||
r = fs_sendrec(fs_e, &m);
|
||||
|
@ -1161,9 +1161,9 @@ char *lastc;
|
|||
|
||||
/* Fill in request message */
|
||||
m.m_type = REQ_UNLINK;
|
||||
m.REQ_INODE_NR = (pino_t) inode_nr;
|
||||
m.REQ_GRANT = grant_id;
|
||||
m.REQ_PATH_LEN = len;
|
||||
m.m_vfs_fs_unlink.inode = inode_nr;
|
||||
m.m_vfs_fs_unlink.grant = grant_id;
|
||||
m.m_vfs_fs_unlink.path_len = len;
|
||||
|
||||
/* Send/rec request */
|
||||
r = fs_sendrec(fs_e, &m);
|
||||
|
|
Loading…
Reference in a new issue