Message types for VFS rename
Change-Id: I48a4098c16519e9c104b287d7bdf95ed6a2a7323
This commit is contained in:
parent
5d682d17ee
commit
a725c62a66
6 changed files with 43 additions and 28 deletions
|
@ -269,6 +269,19 @@ typedef struct {
|
||||||
} mess_fs_vfs_readsuper;
|
} mess_fs_vfs_readsuper;
|
||||||
_ASSERT_MSG_SIZE(mess_fs_vfs_readsuper);
|
_ASSERT_MSG_SIZE(mess_fs_vfs_readsuper);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
ino_t dir_old;
|
||||||
|
ino_t dir_new;
|
||||||
|
|
||||||
|
size_t len_old;
|
||||||
|
size_t len_new;
|
||||||
|
cp_grant_id_t grant_old;
|
||||||
|
cp_grant_id_t grant_new;
|
||||||
|
|
||||||
|
uint8_t data[24];
|
||||||
|
} mess_vfs_fs_rename;
|
||||||
|
_ASSERT_MSG_SIZE(mess_vfs_fs_rename);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
time_t atime;
|
time_t atime;
|
||||||
time_t mtime;
|
time_t mtime;
|
||||||
|
@ -348,6 +361,7 @@ typedef struct {
|
||||||
mess_vfs_fs_mountpoint m_vfs_fs_mountpoint;
|
mess_vfs_fs_mountpoint m_vfs_fs_mountpoint;
|
||||||
mess_vfs_fs_readsuper m_vfs_fs_readsuper;
|
mess_vfs_fs_readsuper m_vfs_fs_readsuper;
|
||||||
mess_fs_vfs_readsuper m_fs_vfs_readsuper;
|
mess_fs_vfs_readsuper m_fs_vfs_readsuper;
|
||||||
|
mess_vfs_fs_rename m_vfs_fs_rename;
|
||||||
mess_vfs_utimens m_vfs_utimens;
|
mess_vfs_utimens m_vfs_utimens;
|
||||||
mess_vm_vfs_mmap m_vm_vfs_mmap;
|
mess_vm_vfs_mmap m_vm_vfs_mmap;
|
||||||
mess_vmmcp m_vmmcp;
|
mess_vmmcp m_vmmcp;
|
||||||
|
|
|
@ -214,29 +214,29 @@ int fs_rename(void)
|
||||||
return(EINVAL);
|
return(EINVAL);
|
||||||
|
|
||||||
/* Copy the last component of the old name */
|
/* Copy the last component of the old name */
|
||||||
len = fs_m_in.REQ_REN_LEN_OLD; /* including trailing '\0' */
|
len = fs_m_in.m_vfs_fs_rename.len_old; /* including trailing '\0' */
|
||||||
if (len > NAME_MAX + 1)
|
if (len > NAME_MAX + 1)
|
||||||
return(ENAMETOOLONG);
|
return(ENAMETOOLONG);
|
||||||
|
|
||||||
r = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_REN_GRANT_OLD,
|
r = sys_safecopyfrom(VFS_PROC_NR, fs_m_in.m_vfs_fs_rename.grant_old,
|
||||||
(vir_bytes) 0, (vir_bytes) pcn_src.pcn_name, (size_t) len);
|
(vir_bytes) 0, (vir_bytes) pcn_src.pcn_name, (size_t) len);
|
||||||
if (r != OK) return(r);
|
if (r != OK) return(r);
|
||||||
NUL(pcn_src.pcn_name, len, sizeof(pcn_src.pcn_name));
|
NUL(pcn_src.pcn_name, len, sizeof(pcn_src.pcn_name));
|
||||||
pcn_src.pcn_namelen = len - 1;
|
pcn_src.pcn_namelen = len - 1;
|
||||||
|
|
||||||
/* Copy the last component of the new name */
|
/* Copy the last component of the new name */
|
||||||
len = fs_m_in.REQ_REN_LEN_NEW; /* including trailing '\0' */
|
len = fs_m_in.m_vfs_fs_rename.len_new; /* including trailing '\0' */
|
||||||
if (len > NAME_MAX + 1)
|
if (len > NAME_MAX + 1)
|
||||||
return(ENAMETOOLONG);
|
return(ENAMETOOLONG);
|
||||||
|
|
||||||
r = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_REN_GRANT_NEW,
|
r = sys_safecopyfrom(VFS_PROC_NR, fs_m_in.m_vfs_fs_rename.grant_new,
|
||||||
(vir_bytes) 0, (vir_bytes) pcn_targ.pcn_name, (size_t) len);
|
(vir_bytes) 0, (vir_bytes) pcn_targ.pcn_name, (size_t) len);
|
||||||
if (r != OK) return(r);
|
if (r != OK) return(r);
|
||||||
NUL(pcn_targ.pcn_name, len, sizeof(pcn_targ.pcn_name));
|
NUL(pcn_targ.pcn_name, len, sizeof(pcn_targ.pcn_name));
|
||||||
pcn_targ.pcn_namelen = len - 1;
|
pcn_targ.pcn_namelen = len - 1;
|
||||||
|
|
||||||
/* Get old dir pnode */
|
/* Get old dir pnode */
|
||||||
if ((old_dirp = puffs_pn_nodewalk(global_pu, 0, &fs_m_in.REQ_REN_OLD_DIR))
|
if ((old_dirp = puffs_pn_nodewalk(global_pu, 0, &fs_m_in.m_vfs_fs_rename.dir_old))
|
||||||
== NULL)
|
== NULL)
|
||||||
return(ENOENT);
|
return(ENOENT);
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ int fs_rename(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get new dir pnode */
|
/* Get new dir pnode */
|
||||||
if ((new_dirp = puffs_pn_nodewalk(global_pu, 0, &fs_m_in.REQ_REN_NEW_DIR))
|
if ((new_dirp = puffs_pn_nodewalk(global_pu, 0, &fs_m_in.m_vfs_fs_rename.dir_new))
|
||||||
== NULL) {
|
== NULL) {
|
||||||
r = ENOENT;
|
r = ENOENT;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -344,17 +344,17 @@ int do_rename(void)
|
||||||
/* Get path strings, names, directory inodes and possibly preexisting inodes
|
/* Get path strings, names, directory inodes and possibly preexisting inodes
|
||||||
* for the old and new paths.
|
* for the old and new paths.
|
||||||
*/
|
*/
|
||||||
if ((r = get_name(m_in.REQ_REN_GRANT_OLD, m_in.REQ_REN_LEN_OLD,
|
if ((r = get_name(m_in.m_vfs_fs_rename.grant_old, m_in.m_vfs_fs_rename.len_old,
|
||||||
old_name)) != OK) return r;
|
old_name)) != OK) return r;
|
||||||
|
|
||||||
if ((r = get_name(m_in.REQ_REN_GRANT_NEW, m_in.REQ_REN_LEN_NEW,
|
if ((r = get_name(m_in.m_vfs_fs_rename.grant_new, m_in.m_vfs_fs_rename.len_new,
|
||||||
new_name)) != OK) return r;
|
new_name)) != OK) return r;
|
||||||
|
|
||||||
if (!strcmp(old_name, ".") || !strcmp(old_name, "..") ||
|
if (!strcmp(old_name, ".") || !strcmp(old_name, "..") ||
|
||||||
!strcmp(new_name, ".") || !strcmp(new_name, "..")) return EINVAL;
|
!strcmp(new_name, ".") || !strcmp(new_name, "..")) return EINVAL;
|
||||||
|
|
||||||
if ((old_parent = find_inode(m_in.REQ_REN_OLD_DIR)) == NULL ||
|
if ((old_parent = find_inode(m_in.m_vfs_fs_rename.dir_old)) == NULL ||
|
||||||
(new_parent = find_inode(m_in.REQ_REN_NEW_DIR)) == NULL)
|
(new_parent = find_inode(m_in.m_vfs_fs_rename.dir_new)) == NULL)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
if ((r = verify_dentry(old_parent, old_name, old_path, &old_ino)) != OK)
|
if ((r = verify_dentry(old_parent, old_name, old_path, &old_ino)) != OK)
|
||||||
|
|
|
@ -314,27 +314,27 @@ int fs_rename()
|
||||||
phys_bytes len;
|
phys_bytes len;
|
||||||
|
|
||||||
/* Copy the last component of the old name */
|
/* Copy the last component of the old name */
|
||||||
len = fs_m_in.REQ_REN_LEN_OLD; /* including trailing '\0' */
|
len = fs_m_in.m_vfs_fs_rename.len_old; /* including trailing '\0' */
|
||||||
if (len > NAME_MAX + 1 || len > EXT2_NAME_MAX + 1)
|
if (len > NAME_MAX + 1 || len > EXT2_NAME_MAX + 1)
|
||||||
return(ENAMETOOLONG);
|
return(ENAMETOOLONG);
|
||||||
|
|
||||||
r = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_REN_GRANT_OLD,
|
r = sys_safecopyfrom(VFS_PROC_NR, fs_m_in.m_vfs_fs_rename.grant_old,
|
||||||
(vir_bytes) 0, (vir_bytes) old_name, (size_t) len);
|
(vir_bytes) 0, (vir_bytes) old_name, (size_t) len);
|
||||||
if (r != OK) return r;
|
if (r != OK) return r;
|
||||||
NUL(old_name, len, sizeof(old_name));
|
NUL(old_name, len, sizeof(old_name));
|
||||||
|
|
||||||
/* Copy the last component of the new name */
|
/* Copy the last component of the new name */
|
||||||
len = fs_m_in.REQ_REN_LEN_NEW; /* including trailing '\0' */
|
len = fs_m_in.m_vfs_fs_rename.len_new; /* including trailing '\0' */
|
||||||
if (len > NAME_MAX + 1 || len > EXT2_NAME_MAX + 1)
|
if (len > NAME_MAX + 1 || len > EXT2_NAME_MAX + 1)
|
||||||
return(ENAMETOOLONG);
|
return(ENAMETOOLONG);
|
||||||
|
|
||||||
r = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_REN_GRANT_NEW,
|
r = sys_safecopyfrom(VFS_PROC_NR, fs_m_in.m_vfs_fs_rename.grant_new,
|
||||||
(vir_bytes) 0, (vir_bytes) new_name, (size_t) len);
|
(vir_bytes) 0, (vir_bytes) new_name, (size_t) len);
|
||||||
if (r != OK) return r;
|
if (r != OK) return r;
|
||||||
NUL(new_name, len, sizeof(new_name));
|
NUL(new_name, len, sizeof(new_name));
|
||||||
|
|
||||||
/* Get old dir inode */
|
/* Get old dir inode */
|
||||||
if( (old_dirp = get_inode(fs_dev, (pino_t) fs_m_in.REQ_REN_OLD_DIR)) == NULL)
|
if( (old_dirp = get_inode(fs_dev, (pino_t) fs_m_in.m_vfs_fs_rename.dir_old)) == NULL)
|
||||||
return(err_code);
|
return(err_code);
|
||||||
|
|
||||||
old_ip = advance(old_dirp, old_name, IGN_PERM);
|
old_ip = advance(old_dirp, old_name, IGN_PERM);
|
||||||
|
@ -350,7 +350,7 @@ int fs_rename()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get new dir inode */
|
/* Get new dir inode */
|
||||||
if ((new_dirp = get_inode(fs_dev, (pino_t) fs_m_in.REQ_REN_NEW_DIR)) == NULL){
|
if ((new_dirp = get_inode(fs_dev, (pino_t) fs_m_in.m_vfs_fs_rename.dir_new)) == NULL){
|
||||||
put_inode(old_ip);
|
put_inode(old_ip);
|
||||||
put_inode(old_dirp);
|
put_inode(old_dirp);
|
||||||
return(err_code);
|
return(err_code);
|
||||||
|
|
|
@ -295,21 +295,21 @@ int fs_rename()
|
||||||
phys_bytes len;
|
phys_bytes len;
|
||||||
|
|
||||||
/* Copy the last component of the old name */
|
/* Copy the last component of the old name */
|
||||||
len = min( (unsigned) fs_m_in.REQ_REN_LEN_OLD, sizeof(old_name));
|
len = min( (unsigned) fs_m_in.m_vfs_fs_rename.len_old, sizeof(old_name));
|
||||||
r = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_REN_GRANT_OLD,
|
r = sys_safecopyfrom(VFS_PROC_NR, fs_m_in.m_vfs_fs_rename.grant_old,
|
||||||
(vir_bytes) 0, (vir_bytes) old_name, (size_t) len);
|
(vir_bytes) 0, (vir_bytes) old_name, (size_t) len);
|
||||||
if (r != OK) return r;
|
if (r != OK) return r;
|
||||||
NUL(old_name, len, sizeof(old_name));
|
NUL(old_name, len, sizeof(old_name));
|
||||||
|
|
||||||
/* Copy the last component of the new name */
|
/* Copy the last component of the new name */
|
||||||
len = min( (unsigned) fs_m_in.REQ_REN_LEN_NEW, sizeof(new_name));
|
len = min( (unsigned) fs_m_in.m_vfs_fs_rename.len_new, sizeof(new_name));
|
||||||
r = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_REN_GRANT_NEW,
|
r = sys_safecopyfrom(VFS_PROC_NR, fs_m_in.m_vfs_fs_rename.grant_new,
|
||||||
(vir_bytes) 0, (vir_bytes) new_name, (size_t) len);
|
(vir_bytes) 0, (vir_bytes) new_name, (size_t) len);
|
||||||
if (r != OK) return r;
|
if (r != OK) return r;
|
||||||
NUL(new_name, len, sizeof(new_name));
|
NUL(new_name, len, sizeof(new_name));
|
||||||
|
|
||||||
/* Get old dir inode */
|
/* Get old dir inode */
|
||||||
if ((old_dirp = get_inode(fs_dev, (pino_t) fs_m_in.REQ_REN_OLD_DIR)) == NULL)
|
if ((old_dirp = get_inode(fs_dev, fs_m_in.m_vfs_fs_rename.dir_old)) == NULL)
|
||||||
return(err_code);
|
return(err_code);
|
||||||
|
|
||||||
old_ip = advance(old_dirp, old_name, IGN_PERM);
|
old_ip = advance(old_dirp, old_name, IGN_PERM);
|
||||||
|
@ -328,7 +328,7 @@ int fs_rename()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get new dir inode */
|
/* Get new dir inode */
|
||||||
if ((new_dirp = get_inode(fs_dev, (pino_t) fs_m_in.REQ_REN_NEW_DIR)) == NULL){
|
if ((new_dirp = get_inode(fs_dev, (pino_t) fs_m_in.m_vfs_fs_rename.dir_new)) == NULL){
|
||||||
put_inode(old_ip);
|
put_inode(old_ip);
|
||||||
put_inode(old_dirp);
|
put_inode(old_dirp);
|
||||||
return(err_code);
|
return(err_code);
|
||||||
|
|
|
@ -941,12 +941,13 @@ char *new_name;
|
||||||
|
|
||||||
/* Fill in request message */
|
/* Fill in request message */
|
||||||
m.m_type = REQ_RENAME;
|
m.m_type = REQ_RENAME;
|
||||||
m.REQ_REN_OLD_DIR = (pino_t) old_dir;
|
m.m_vfs_fs_rename.dir_old = old_dir;
|
||||||
m.REQ_REN_NEW_DIR = (pino_t) new_dir;
|
m.m_vfs_fs_rename.grant_old = gid_old;
|
||||||
m.REQ_REN_GRANT_OLD = gid_old;
|
m.m_vfs_fs_rename.len_old = len_old;
|
||||||
m.REQ_REN_LEN_OLD = len_old;
|
|
||||||
m.REQ_REN_GRANT_NEW = gid_new;
|
m.m_vfs_fs_rename.dir_new = new_dir;
|
||||||
m.REQ_REN_LEN_NEW = len_new;
|
m.m_vfs_fs_rename.grant_new = gid_new;
|
||||||
|
m.m_vfs_fs_rename.len_new = len_new;
|
||||||
|
|
||||||
/* Send/rec request */
|
/* Send/rec request */
|
||||||
r = fs_sendrec(fs_e, &m);
|
r = fs_sendrec(fs_e, &m);
|
||||||
|
|
Loading…
Reference in a new issue