From: Lionel Sambuc Date: Wed, 30 Apr 2014 07:55:55 +0000 (+0200) Subject: Message types for VFS getdents X-Git-Tag: v3.3.0~340 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/mdoc.3.txt?a=commitdiff_plain;h=591227dc383d3fe86cd025de8114606dc3f30c39;p=minix.git Message types for VFS getdents Change-Id: I7474d7547f1fd52f4da54754ccfe984ba1a2baa8 --- diff --git a/include/minix/ipc.h b/include/minix/ipc.h index f1bf5ac31..c67d1bda0 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -187,6 +187,26 @@ typedef struct { } mess_vfs_fs_ftrunc; _ASSERT_MSG_SIZE(mess_vfs_fs_ftrunc); +typedef struct { + ino_t inode; + off_t seek_pos; + + cp_grant_id_t grant; + size_t mem_size; + + uint8_t data[32]; +} mess_vfs_fs_getdents; +_ASSERT_MSG_SIZE(mess_vfs_fs_getdents); + +typedef struct { + off_t seek_pos; + + size_t nbytes; + + uint8_t data[44]; +} mess_fs_vfs_getdents; +_ASSERT_MSG_SIZE(mess_fs_vfs_getdents); + typedef struct { ino_t dir_ino; ino_t root_ino; @@ -402,6 +422,8 @@ typedef struct { mess_fs_vfs_create m_fs_vfs_create; mess_vfs_fs_flush m_vfs_fs_flush; mess_vfs_fs_ftrunc m_vfs_fs_ftrunc; + mess_vfs_fs_getdents m_vfs_fs_getdents; + mess_fs_vfs_getdents m_fs_vfs_getdents; mess_vfs_fs_lookup m_vfs_fs_lookup; mess_fs_vfs_lookup m_fs_vfs_lookup; mess_vfs_fs_mountpoint m_vfs_fs_mountpoint; diff --git a/lib/libpuffs/read.c b/lib/libpuffs/read.c index ded210067..9023e126b 100644 --- a/lib/libpuffs/read.c +++ b/lib/libpuffs/read.c @@ -123,7 +123,7 @@ int fs_getdents(void) { int r; register struct puffs_node *pn; - pino_t ino; + ino_t ino; cp_grant_id_t gid; size_t size, buf_left; off_t pos; @@ -132,10 +132,10 @@ int fs_getdents(void) size_t written; PUFFS_MAKECRED(pcr, &global_kcred); - ino = (pino_t) fs_m_in.REQ_INODE_NR; - gid = (cp_grant_id_t) fs_m_in.REQ_GRANT; - size = buf_left = (size_t) fs_m_in.REQ_MEM_SIZE; - pos = (off_t) fs_m_in.REQ_SEEK_POS; + ino = fs_m_in.m_vfs_fs_getdents.inode; + gid = fs_m_in.m_vfs_fs_getdents.grant; + size = buf_left = fs_m_in.m_vfs_fs_getdents.mem_size; + pos = fs_m_in.m_vfs_fs_getdents.seek_pos; if ((pn = puffs_pn_nodewalk(global_pu, 0, &ino)) == NULL) { lpuffs_debug("walk failed...\n"); @@ -171,8 +171,8 @@ int fs_getdents(void) update_timens(pn, ATIME, NULL); - fs_m_out.RES_NBYTES = written; - fs_m_out.RES_SEEK_POS = pos; + fs_m_out.m_fs_vfs_getdents.nbytes = written; + fs_m_out.m_fs_vfs_getdents.seek_pos = pos; return(OK); } diff --git a/lib/libsffs/read.c b/lib/libsffs/read.c index 180aafe87..9237f9806 100644 --- a/lib/libsffs/read.c +++ b/lib/libsffs/read.c @@ -92,10 +92,10 @@ int do_getdents(void) attr.a_mask = SFFS_ATTR_MODE; - if ((ino = find_inode(m_in.REQ_INODE_NR)) == NULL) + if ((ino = find_inode(m_in.m_vfs_fs_getdents.inode)) == NULL) return EINVAL; - if(m_in.REQ_SEEK_POS >= ULONG_MAX) return EINVAL; + if(m_in.m_vfs_fs_getdents.seek_pos >= ULONG_MAX) return EINVAL; if (!IS_DIR(ino)) return ENOTDIR; @@ -108,13 +108,13 @@ int do_getdents(void) off = 0; user_off = 0; - user_left = m_in.REQ_MEM_SIZE; + user_left = m_in.m_vfs_fs_getdents.mem_size; /* We use the seek position as file index number. The first position is for * the "." entry, the second position is for the ".." entry, and the next * position numbers each represent a file in the directory. */ - for (pos = m_in.REQ_SEEK_POS; ; pos++) { + for (pos = m_in.m_vfs_fs_getdents.seek_pos; ; pos++) { /* Determine which inode and name to use for this entry. * We have no idea whether the host will give us "." and/or "..", * so generate our own and skip those from the host. @@ -190,7 +190,7 @@ int do_getdents(void) /* If our own buffer cannot contain the new record, copy out first. */ if (off + len > sizeof(buf)) { - r = sys_safecopyto(m_in.m_source, m_in.REQ_GRANT, + r = sys_safecopyto(m_in.m_source, m_in.m_vfs_fs_getdents.grant, user_off, (vir_bytes) buf, off); if (r != OK) { @@ -219,7 +219,7 @@ int do_getdents(void) /* If there is anything left in our own buffer, copy that out now. */ if (off > 0) { - r = sys_safecopyto(m_in.m_source, m_in.REQ_GRANT, user_off, + r = sys_safecopyto(m_in.m_source, m_in.m_vfs_fs_getdents.grant, user_off, (vir_bytes) buf, off); if (r != OK) @@ -228,8 +228,8 @@ int do_getdents(void) user_off += off; } - m_out.RES_SEEK_POS = pos; - m_out.RES_NBYTES = user_off; + m_out.m_fs_vfs_getdents.seek_pos = pos; + m_out.m_fs_vfs_getdents.nbytes = user_off; return OK; } diff --git a/lib/libvtreefs/read.c b/lib/libvtreefs/read.c index 3de271d20..358a114f9 100644 --- a/lib/libvtreefs/read.c +++ b/lib/libvtreefs/read.c @@ -79,15 +79,15 @@ int fs_getdents(void) int r, skip, get_next, indexed; static char buf[GETDENTS_BUFSIZ]; - if (fs_m_in.REQ_SEEK_POS >= ULONG_MAX) + if (fs_m_in.m_vfs_fs_getdents.seek_pos >= ULONG_MAX) return EIO; - if ((node = find_inode(fs_m_in.REQ_INODE_NR)) == NULL) + if ((node = find_inode(fs_m_in.m_vfs_fs_getdents.inode)) == NULL) return EINVAL; off = 0; user_off = 0; - user_left = fs_m_in.REQ_MEM_SIZE; + user_left = fs_m_in.m_vfs_fs_getdents.mem_size; indexed = node->i_indexed; get_next = FALSE; child = NULL; @@ -98,7 +98,7 @@ int fs_getdents(void) if (r != OK) return r; } - for (pos = fs_m_in.REQ_SEEK_POS; ; pos++) { + for (pos = fs_m_in.m_vfs_fs_getdents.seek_pos; ; pos++) { /* Determine which inode and name to use for this entry. */ if (pos == 0) { /* The "." entry. */ @@ -176,7 +176,7 @@ int fs_getdents(void) * first. */ if (off + len > sizeof(buf)) { - r = sys_safecopyto(fs_m_in.m_source, fs_m_in.REQ_GRANT, + r = sys_safecopyto(fs_m_in.m_source, fs_m_in.m_vfs_fs_getdents.grant, user_off, (vir_bytes) buf, off); if (r != OK) return r; @@ -198,7 +198,7 @@ int fs_getdents(void) /* If there is anything left in our own buffer, copy that out now. */ if (off > 0) { - r = sys_safecopyto(fs_m_in.m_source, fs_m_in.REQ_GRANT, + r = sys_safecopyto(fs_m_in.m_source, fs_m_in.m_vfs_fs_getdents.grant, user_off, (vir_bytes) buf, off); if (r != OK) return r; @@ -206,8 +206,8 @@ int fs_getdents(void) user_off += off; } - fs_m_out.RES_SEEK_POS = pos; - fs_m_out.RES_NBYTES = user_off; + fs_m_out.m_fs_vfs_getdents.seek_pos = pos; + fs_m_out.m_fs_vfs_getdents.nbytes = user_off; return OK; } diff --git a/servers/ext2/read.c b/servers/ext2/read.c index be856b578..244baab1f 100644 --- a/servers/ext2/read.c +++ b/servers/ext2/read.c @@ -620,7 +620,7 @@ int fs_getdents(void) struct inode *rip; int r, done; unsigned int block_size, len, reclen; - pino_t ino; + ino_t ino; cp_grant_id_t gid; size_t size, tmpbuf_off, userbuf_off; off_t pos, off, block_pos, new_pos, ent_pos; @@ -628,10 +628,10 @@ int fs_getdents(void) struct ext2_disk_dir_desc *d_desc; struct dirent *dep; - ino = (pino_t) fs_m_in.REQ_INODE_NR; - gid = (cp_grant_id_t) fs_m_in.REQ_GRANT; - size = (size_t) fs_m_in.REQ_MEM_SIZE; - pos = (off_t) fs_m_in.REQ_SEEK_POS; + ino = fs_m_in.m_vfs_fs_getdents.inode; + gid = fs_m_in.m_vfs_fs_getdents.grant; + size = fs_m_in.m_vfs_fs_getdents.mem_size; + pos = fs_m_in.m_vfs_fs_getdents.seek_pos; /* Check whether the position is properly aligned */ if ((unsigned int) pos % DIR_ENTRY_ALIGN) @@ -759,8 +759,8 @@ int fs_getdents(void) if (done && userbuf_off == 0) r = EINVAL; /* The user's buffer is too small */ else { - fs_m_out.RES_NBYTES = userbuf_off; - fs_m_out.RES_SEEK_POS = new_pos; + fs_m_out.m_fs_vfs_getdents.nbytes = userbuf_off; + fs_m_out.m_fs_vfs_getdents.seek_pos = new_pos; rip->i_update |= ATIME; rip->i_dirt = IN_DIRTY; r = OK; diff --git a/servers/iso9660fs/read.c b/servers/iso9660fs/read.c index cec013a0a..a6f152ae1 100644 --- a/servers/iso9660fs/read.c +++ b/servers/iso9660fs/read.c @@ -159,9 +159,9 @@ int fs_getdents(void) memset(name_old,'\0',NAME_MAX); /* Get input parameters */ - ino = fs_m_in.REQ_INODE_NR; - gid = fs_m_in.REQ_GRANT; - pos = fs_m_in.REQ_SEEK_POS; + ino = fs_m_in.m_vfs_fs_getdents.inode; + gid = fs_m_in.m_vfs_fs_getdents.grant; + pos = fs_m_in.m_vfs_fs_getdents.seek_pos; block_size = v_pri.logical_block_size_l; cur_pos = pos; /* The current position */ @@ -277,8 +277,8 @@ int fs_getdents(void) userbuf_off += tmpbuf_offset; } - fs_m_out.RES_NBYTES = userbuf_off; - fs_m_out.RES_SEEK_POS = cur_pos; + fs_m_out.m_fs_vfs_getdents.nbytes = userbuf_off; + fs_m_out.m_fs_vfs_getdents.seek_pos = cur_pos; release_dir_record(dir); /* release the inode */ return(OK); diff --git a/servers/mfs/read.c b/servers/mfs/read.c index b89afd452..f3a0533b3 100644 --- a/servers/mfs/read.c +++ b/servers/mfs/read.c @@ -616,10 +616,10 @@ int fs_getdents(void) struct dirent *dep; char *cp; - ino = (pino_t) fs_m_in.REQ_INODE_NR; - gid = (cp_grant_id_t) fs_m_in.REQ_GRANT; - size = (size_t) fs_m_in.REQ_MEM_SIZE; - pos = (off_t) fs_m_in.REQ_SEEK_POS; + ino = fs_m_in.m_vfs_fs_getdents.inode; + gid = fs_m_in.m_vfs_fs_getdents.grant; + size = fs_m_in.m_vfs_fs_getdents.mem_size; + pos = fs_m_in.m_vfs_fs_getdents.seek_pos; /* Check whether the position is properly aligned */ if( (unsigned int) pos % DIR_ENTRY_SIZE) @@ -729,8 +729,8 @@ int fs_getdents(void) if (done && userbuf_off == 0) r = EINVAL; /* The user's buffer is too small */ else { - fs_m_out.RES_NBYTES = userbuf_off; - fs_m_out.RES_SEEK_POS = new_pos; + fs_m_out.m_fs_vfs_getdents.nbytes = userbuf_off; + fs_m_out.m_fs_vfs_getdents.seek_pos = new_pos; if(!rip->i_sp->s_rd_only) { rip->i_update |= ATIME; IN_MARKDIRTY(rip); diff --git a/servers/vfs/request.c b/servers/vfs/request.c index 17df01af2..019a7fa40 100644 --- a/servers/vfs/request.c +++ b/servers/vfs/request.c @@ -314,10 +314,10 @@ static int req_getdents_actual( grant_id); m.m_type = REQ_GETDENTS; - m.REQ_INODE_NR = (pino_t) inode_nr; - m.REQ_GRANT = grant_id; - m.REQ_MEM_SIZE = size; - m.REQ_SEEK_POS = pos; + m.m_vfs_fs_getdents.inode = inode_nr; + m.m_vfs_fs_getdents.grant = grant_id; + m.m_vfs_fs_getdents.mem_size = size; + m.m_vfs_fs_getdents.seek_pos = pos; if (!(vmp->m_fs_flags & RES_64BIT) && (pos > INT_MAX)) { /* FS does not support 64-bit off_t and 32 bits is not enough */ return EINVAL; @@ -327,8 +327,8 @@ static int req_getdents_actual( cpf_revoke(grant_id); if (r == OK) { - *new_pos = m.RES_SEEK_POS; - r = m.RES_NBYTES; + *new_pos = m.m_fs_vfs_getdents.seek_pos; + r = m.m_fs_vfs_getdents.nbytes; } return(r);