From a725c62a66d1e606d39ba0b6cffc6e3ac35bd175 Mon Sep 17 00:00:00 2001 From: Lionel Sambuc Date: Tue, 29 Apr 2014 18:36:15 +0200 Subject: [PATCH] Message types for VFS rename Change-Id: I48a4098c16519e9c104b287d7bdf95ed6a2a7323 --- include/minix/ipc.h | 14 ++++++++++++++ lib/libpuffs/link.c | 12 ++++++------ lib/libsffs/link.c | 8 ++++---- servers/ext2/link.c | 12 ++++++------ servers/mfs/link.c | 12 ++++++------ servers/vfs/request.c | 13 +++++++------ 6 files changed, 43 insertions(+), 28 deletions(-) diff --git a/include/minix/ipc.h b/include/minix/ipc.h index 629635494..7bc5cc293 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -269,6 +269,19 @@ typedef struct { } 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 { time_t atime; time_t mtime; @@ -348,6 +361,7 @@ typedef struct { mess_vfs_fs_mountpoint m_vfs_fs_mountpoint; mess_vfs_fs_readsuper m_vfs_fs_readsuper; mess_fs_vfs_readsuper m_fs_vfs_readsuper; + mess_vfs_fs_rename m_vfs_fs_rename; mess_vfs_utimens m_vfs_utimens; mess_vm_vfs_mmap m_vm_vfs_mmap; mess_vmmcp m_vmmcp; diff --git a/lib/libpuffs/link.c b/lib/libpuffs/link.c index f934d0777..19ee0242a 100644 --- a/lib/libpuffs/link.c +++ b/lib/libpuffs/link.c @@ -214,29 +214,29 @@ int fs_rename(void) return(EINVAL); /* 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) 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); if (r != OK) return(r); NUL(pcn_src.pcn_name, len, sizeof(pcn_src.pcn_name)); pcn_src.pcn_namelen = len - 1; /* 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) 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); if (r != OK) return(r); NUL(pcn_targ.pcn_name, len, sizeof(pcn_targ.pcn_name)); pcn_targ.pcn_namelen = len - 1; /* 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) return(ENOENT); @@ -253,7 +253,7 @@ int fs_rename(void) } /* 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) { r = ENOENT; } else { diff --git a/lib/libsffs/link.c b/lib/libsffs/link.c index ddc323e46..85285c097 100644 --- a/lib/libsffs/link.c +++ b/lib/libsffs/link.c @@ -344,17 +344,17 @@ int do_rename(void) /* Get path strings, names, directory inodes and possibly preexisting inodes * 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; - 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; if (!strcmp(old_name, ".") || !strcmp(old_name, "..") || !strcmp(new_name, ".") || !strcmp(new_name, "..")) return EINVAL; - if ((old_parent = find_inode(m_in.REQ_REN_OLD_DIR)) == NULL || - (new_parent = find_inode(m_in.REQ_REN_NEW_DIR)) == NULL) + if ((old_parent = find_inode(m_in.m_vfs_fs_rename.dir_old)) == NULL || + (new_parent = find_inode(m_in.m_vfs_fs_rename.dir_new)) == NULL) return EINVAL; if ((r = verify_dentry(old_parent, old_name, old_path, &old_ino)) != OK) diff --git a/servers/ext2/link.c b/servers/ext2/link.c index d4144acab..b32fabd83 100644 --- a/servers/ext2/link.c +++ b/servers/ext2/link.c @@ -314,27 +314,27 @@ int fs_rename() phys_bytes len; /* 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) 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); if (r != OK) return r; NUL(old_name, len, sizeof(old_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) 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); if (r != OK) return r; NUL(new_name, len, sizeof(new_name)); /* 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); old_ip = advance(old_dirp, old_name, IGN_PERM); @@ -350,7 +350,7 @@ int fs_rename() } /* 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_dirp); return(err_code); diff --git a/servers/mfs/link.c b/servers/mfs/link.c index d6d482ca2..dd99e11ee 100644 --- a/servers/mfs/link.c +++ b/servers/mfs/link.c @@ -295,21 +295,21 @@ int fs_rename() phys_bytes len; /* Copy the last component of the old name */ - len = min( (unsigned) fs_m_in.REQ_REN_LEN_OLD, sizeof(old_name)); - r = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_REN_GRANT_OLD, + len = min( (unsigned) fs_m_in.m_vfs_fs_rename.len_old, sizeof(old_name)); + 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); if (r != OK) return r; NUL(old_name, len, sizeof(old_name)); /* Copy the last component of the new name */ - len = min( (unsigned) fs_m_in.REQ_REN_LEN_NEW, sizeof(new_name)); - r = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_REN_GRANT_NEW, + len = min( (unsigned) fs_m_in.m_vfs_fs_rename.len_new, sizeof(new_name)); + 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); if (r != OK) return r; NUL(new_name, len, sizeof(new_name)); /* 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); old_ip = advance(old_dirp, old_name, IGN_PERM); @@ -328,7 +328,7 @@ int fs_rename() } /* 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_dirp); return(err_code); diff --git a/servers/vfs/request.c b/servers/vfs/request.c index 9928fb294..14cc3cf7d 100644 --- a/servers/vfs/request.c +++ b/servers/vfs/request.c @@ -941,12 +941,13 @@ char *new_name; /* Fill in request message */ m.m_type = REQ_RENAME; - m.REQ_REN_OLD_DIR = (pino_t) old_dir; - m.REQ_REN_NEW_DIR = (pino_t) new_dir; - m.REQ_REN_GRANT_OLD = gid_old; - m.REQ_REN_LEN_OLD = len_old; - m.REQ_REN_GRANT_NEW = gid_new; - m.REQ_REN_LEN_NEW = len_new; + m.m_vfs_fs_rename.dir_old = old_dir; + m.m_vfs_fs_rename.grant_old = gid_old; + m.m_vfs_fs_rename.len_old = len_old; + + m.m_vfs_fs_rename.dir_new = new_dir; + m.m_vfs_fs_rename.grant_new = gid_new; + m.m_vfs_fs_rename.len_new = len_new; /* Send/rec request */ r = fs_sendrec(fs_e, &m);