From: Lionel Sambuc Date: Thu, 1 May 2014 08:06:10 +0000 (+0200) Subject: Message types for VFS unlink & rmdir X-Git-Tag: v3.3.0~334 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/NetBSD.png?a=commitdiff_plain;h=169e0314ea15f24062a390f2f0b9ed82212d9ce0;p=minix.git 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 --- diff --git a/include/minix/ipc.h b/include/minix/ipc.h index 68310235b..609525f05 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -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; diff --git a/lib/libpuffs/link.c b/lib/libpuffs/link.c index 595cc1089..99740ade2 100644 --- a/lib/libpuffs/link.c +++ b/lib/libpuffs/link.c @@ -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? */ diff --git a/lib/libsffs/link.c b/lib/libsffs/link.c index 85285c097..d5d63b32f 100644 --- a/lib/libsffs/link.c +++ b/lib/libsffs/link.c @@ -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) diff --git a/servers/ext2/link.c b/servers/ext2/link.c index 51371c2de..03d273bcd 100644 --- a/servers/ext2/link.c +++ b/servers/ext2/link.c @@ -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? */ diff --git a/servers/mfs/link.c b/servers/mfs/link.c index 524196c68..32358485d 100644 --- a/servers/mfs/link.c +++ b/servers/mfs/link.c @@ -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? */ diff --git a/servers/vfs/request.c b/servers/vfs/request.c index 8fbbe6479..b209e2f52 100644 --- a/servers/vfs/request.c +++ b/servers/vfs/request.c @@ -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);