diff --git a/include/minix/ipc.h b/include/minix/ipc.h index 7c0a1ae3b..552e2b19a 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -431,6 +431,26 @@ typedef struct { } mess_fs_vfs_readsuper; _ASSERT_MSG_SIZE(mess_fs_vfs_readsuper); +typedef struct { + ino_t inode; + off_t seek_pos; + + cp_grant_id_t grant; + size_t nbytes; + + uint8_t data[32]; +} mess_vfs_fs_readwrite; +_ASSERT_MSG_SIZE(mess_vfs_fs_readwrite); + +typedef struct { + off_t seek_pos; + + size_t nbytes; + + uint8_t data[44]; +} mess_fs_vfs_readwrite; +_ASSERT_MSG_SIZE(mess_fs_vfs_readwrite); + typedef struct { ino_t dir_old; ino_t dir_new; @@ -593,6 +613,8 @@ typedef struct { 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_fs_readwrite m_vfs_fs_readwrite; + mess_fs_vfs_readwrite m_fs_vfs_readwrite; mess_vfs_fs_slink m_vfs_fs_slink; mess_vfs_fs_stat m_vfs_fs_stat; mess_vfs_fs_statvfs m_vfs_fs_statvfs; diff --git a/lib/libpuffs/read.c b/lib/libpuffs/read.c index 9023e126b..84ee644b6 100644 --- a/lib/libpuffs/read.c +++ b/lib/libpuffs/read.c @@ -37,16 +37,16 @@ int fs_readwrite(void) struct vattr va; PUFFS_MAKECRED(pcr, &global_kcred); - if ((pn = puffs_pn_nodewalk(global_pu, 0, &fs_m_in.REQ_INODE_NR)) == NULL) { + if ((pn = puffs_pn_nodewalk(global_pu, 0, &fs_m_in.m_vfs_fs_readwrite.inode)) == NULL) { lpuffs_debug("walk failed...\n"); return(EINVAL); } /* Get the values from the request message */ rw_flag = (fs_m_in.m_type == REQ_READ ? READING : WRITING); - gid = (cp_grant_id_t) fs_m_in.REQ_GRANT; - pos = (off_t) fs_m_in.REQ_SEEK_POS; - nrbytes = bytes_left = (size_t) fs_m_in.REQ_NBYTES; + gid = fs_m_in.m_vfs_fs_readwrite.grant; + pos = fs_m_in.m_vfs_fs_readwrite.seek_pos; + nrbytes = bytes_left = fs_m_in.m_vfs_fs_readwrite.nbytes; if (nrbytes > RW_BUFSIZ) nrbytes = bytes_left = RW_BUFSIZ; @@ -98,8 +98,8 @@ int fs_readwrite(void) if (r != OK) return(EINVAL); - fs_m_out.RES_SEEK_POS = pos + bytes_done; - fs_m_out.RES_NBYTES = bytes_done; + fs_m_out.m_fs_vfs_readwrite.seek_pos = pos + bytes_done; + fs_m_out.m_fs_vfs_readwrite.nbytes = bytes_done; return(r); } diff --git a/lib/libsffs/read.c b/lib/libsffs/read.c index 9237f9806..a4bb9b528 100644 --- a/lib/libsffs/read.c +++ b/lib/libsffs/read.c @@ -22,13 +22,13 @@ int do_read(void) /* Read data from a file. */ struct inode *ino; - u64_t pos; + off_t pos; size_t count, size; vir_bytes off; char *ptr; int r, chunk; - if ((ino = find_inode(m_in.REQ_INODE_NR)) == NULL) + if ((ino = find_inode(m_in.m_vfs_fs_readwrite.inode)) == NULL) return EINVAL; if (IS_DIR(ino)) return EISDIR; @@ -36,8 +36,8 @@ int do_read(void) if ((r = get_handle(ino)) != OK) return r; - pos = m_in.REQ_SEEK_POS; - count = m_in.REQ_NBYTES; + pos = m_in.m_vfs_fs_readwrite.seek_pos; + count = m_in.m_vfs_fs_readwrite.nbytes; assert(count > 0); @@ -53,7 +53,7 @@ int do_read(void) chunk = r; - r = sys_safecopyto(m_in.m_source, m_in.REQ_GRANT, off, + r = sys_safecopyto(m_in.m_source, m_in.m_vfs_fs_readwrite.grant, off, (vir_bytes) ptr, chunk); if (r != OK) @@ -67,8 +67,8 @@ int do_read(void) if (r < 0) return r; - m_out.RES_SEEK_POS = pos; - m_out.RES_NBYTES = off; + m_out.m_fs_vfs_readwrite.seek_pos = pos; + m_out.m_fs_vfs_readwrite.nbytes = off; return OK; } diff --git a/lib/libsffs/write.c b/lib/libsffs/write.c index 22cbfa7d2..7059a1aa7 100644 --- a/lib/libsffs/write.c +++ b/lib/libsffs/write.c @@ -81,7 +81,7 @@ int do_write(void) /* Write data to a file. */ struct inode *ino; - u64_t pos; + off_t pos; size_t count; cp_grant_id_t grant; int r; @@ -89,22 +89,22 @@ int do_write(void) if (state.s_read_only) return EROFS; - if ((ino = find_inode(m_in.REQ_INODE_NR)) == NULL) + if ((ino = find_inode(m_in.m_vfs_fs_readwrite.inode)) == NULL) return EINVAL; if (IS_DIR(ino)) return EISDIR; - pos = m_in.REQ_SEEK_POS; - count = m_in.REQ_NBYTES; - grant = m_in.REQ_GRANT; + pos = m_in.m_vfs_fs_readwrite.seek_pos; + count = m_in.m_vfs_fs_readwrite.nbytes; + grant = m_in.m_vfs_fs_readwrite.grant; if (count == 0) return EINVAL; if ((r = write_file(ino, &pos, &count, &grant)) != OK) return r; - m_out.RES_SEEK_POS = pos; - m_out.RES_NBYTES = count; + m_out.m_fs_vfs_readwrite.seek_pos = pos; + m_out.m_fs_vfs_readwrite.nbytes = count; return OK; } diff --git a/lib/libvtreefs/read.c b/lib/libvtreefs/read.c index 358a114f9..ad3d6c202 100644 --- a/lib/libvtreefs/read.c +++ b/lib/libvtreefs/read.c @@ -22,7 +22,7 @@ int fs_read(void) int r; /* Try to get inode by to its inode number. */ - if ((node = find_inode(fs_m_in.REQ_INODE_NR)) == NULL) + if ((node = find_inode(fs_m_in.m_vfs_fs_readwrite.inode)) == NULL) return EINVAL; /* Check whether the node is a regular file. */ @@ -30,12 +30,12 @@ int fs_read(void) return EINVAL; /* Get the values from the request message. */ - gid = fs_m_in.REQ_GRANT; - pos = fs_m_in.REQ_SEEK_POS; + gid = fs_m_in.m_vfs_fs_readwrite.grant; + pos = fs_m_in.m_vfs_fs_readwrite.seek_pos; /* Call the read hook, if any. */ if (!is_inode_deleted(node) && vtreefs_hooks->read_hook != NULL) { - len = fs_m_in.REQ_NBYTES; + len = fs_m_in.m_vfs_fs_readwrite.nbytes; /* On success, the read hook provides us with a pointer to the * resulting data. This avoids copying overhead. @@ -43,11 +43,11 @@ int fs_read(void) r = vtreefs_hooks->read_hook(node, pos, &ptr, &len, get_inode_cbdata(node)); - assert(len <= fs_m_in.REQ_NBYTES); + assert(len <= fs_m_in.m_vfs_fs_readwrite.nbytes); /* Copy the resulting data to user space. */ if (r == OK && len > 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_readwrite.grant, 0, (vir_bytes) ptr, len); } } else { @@ -57,8 +57,8 @@ int fs_read(void) } if (r == OK) { - fs_m_out.RES_SEEK_POS = pos + len; - fs_m_out.RES_NBYTES = len; + fs_m_out.m_fs_vfs_readwrite.seek_pos = pos + len; + fs_m_out.m_fs_vfs_readwrite.nbytes = len; } return r; diff --git a/servers/ext2/read.c b/servers/ext2/read.c index 130a82710..09cb3ee50 100644 --- a/servers/ext2/read.c +++ b/servers/ext2/read.c @@ -37,7 +37,7 @@ int fs_readwrite(void) cp_grant_id_t gid; off_t position, f_size, bytes_left; unsigned int off, cum_io, block_size, chunk; - pmode_t mode_word; + mode_t mode_word; int completed; struct inode *rip; size_t nrbytes; @@ -45,7 +45,7 @@ int fs_readwrite(void) r = OK; /* Find the inode referred */ - if ((rip = find_inode(fs_dev, (pino_t) fs_m_in.REQ_INODE_NR)) == NULL) + if ((rip = find_inode(fs_dev, fs_m_in.m_vfs_fs_readwrite.inode)) == NULL) return(EINVAL); mode_word = rip->i_mode & I_TYPE; @@ -69,9 +69,9 @@ int fs_readwrite(void) case REQ_PEEK: rw_flag = PEEKING; break; default: panic("odd request"); } - gid = (cp_grant_id_t) fs_m_in.REQ_GRANT; - position = (off_t) fs_m_in.REQ_SEEK_POS; - nrbytes = (size_t) fs_m_in.REQ_NBYTES; + gid = fs_m_in.m_vfs_fs_readwrite.grant; + position = fs_m_in.m_vfs_fs_readwrite.seek_pos; + nrbytes = fs_m_in.m_vfs_fs_readwrite.nbytes; rdwt_err = OK; /* set to EIO if disk error occurs */ @@ -106,8 +106,9 @@ int fs_readwrite(void) position += (off_t) chunk; /* position within the file */ } - fs_m_out.RES_SEEK_POS = position; /* It might change later and the VFS - has to know this value */ + fs_m_out.m_fs_vfs_readwrite.seek_pos = position; /* It might change later + and the VFS has to know + this value */ /* On write, update file size and access time. */ if (rw_flag == WRITING) { @@ -135,7 +136,7 @@ int fs_readwrite(void) rip->i_dirt = IN_DIRTY; /* inode is thus now dirty */ } - fs_m_out.RES_NBYTES = cum_io; + fs_m_out.m_fs_vfs_readwrite.nbytes = cum_io; return(r); } diff --git a/servers/iso9660fs/read.c b/servers/iso9660fs/read.c index c5717d90b..75c2ac21d 100644 --- a/servers/iso9660fs/read.c +++ b/servers/iso9660fs/read.c @@ -14,7 +14,7 @@ static char getdents_buf[GETDENTS_BUFSIZ]; *===========================================================================*/ int fs_read(void) { int r, chunk, block_size; - int nrbytes; + size_t nrbytes; cp_grant_id_t gid; off_t position, f_size, bytes_left; unsigned int off, cum_io; @@ -31,13 +31,13 @@ int fs_read(void) { r = OK; /* Try to get inode according to its index */ - dir = get_dir_record(fs_m_in.REQ_INODE_NR); + dir = get_dir_record(fs_m_in.m_vfs_fs_readwrite.inode); if (dir == NULL) return(EINVAL); /* no inode found */ - position = fs_m_in.REQ_SEEK_POS; - nrbytes = (unsigned) fs_m_in.REQ_NBYTES; /* number of bytes to read */ + position = fs_m_in.m_vfs_fs_readwrite.seek_pos; + nrbytes = fs_m_in.m_vfs_fs_readwrite.nbytes; /* number of bytes to read */ block_size = v_pri.logical_block_size_l; - gid = fs_m_in.REQ_GRANT; + gid = fs_m_in.m_vfs_fs_readwrite.grant; f_size = dir->d_file_size; rdwt_err = OK; /* set to EIO if disk error occurs */ @@ -45,18 +45,19 @@ int fs_read(void) { cum_io = 0; /* Split the transfer into chunks that don't span two blocks. */ while (nrbytes != 0) { - off = (unsigned int) (position % block_size); + off = position % block_size; chunk = MIN(nrbytes, block_size - off); if (chunk < 0) chunk = block_size - off; bytes_left = f_size - position; if (position >= f_size) break; /* we are beyond EOF */ - if (chunk > bytes_left) chunk = (int) bytes_left; + if (chunk > bytes_left) chunk = (int32_t) bytes_left; /* Read or write 'chunk' bytes. */ - r = read_chunk(dir, ((u64_t)(position)), off, chunk, (unsigned) nrbytes, - gid, cum_io, block_size, &completed, rw); + r = read_chunk(dir, position, off, chunk, + (uint32_t) nrbytes, gid, cum_io, block_size, + &completed, rw); if (r != OK) break; /* EOF reached */ if (rdwt_err < 0) break; @@ -67,12 +68,12 @@ int fs_read(void) { position += chunk; /* position within the file */ } - fs_m_out.RES_SEEK_POS = position; + fs_m_out.m_fs_vfs_readwrite.seek_pos = position; if (rdwt_err != OK) r = rdwt_err; /* check for disk error */ if (rdwt_err == END_OF_FILE) r = OK; - fs_m_out.RES_NBYTES = cum_io; /*dir->d_file_size;*/ + fs_m_out.m_fs_vfs_readwrite.nbytes = cum_io; /*dir->d_file_size;*/ release_dir_record(dir); return(r); diff --git a/servers/mfs/read.c b/servers/mfs/read.c index f947cf57d..0d928efba 100644 --- a/servers/mfs/read.c +++ b/servers/mfs/read.c @@ -30,7 +30,7 @@ int fs_readwrite(void) cp_grant_id_t gid; off_t position, f_size, bytes_left; unsigned int off, cum_io, block_size, chunk; - pmode_t mode_word; + mode_t mode_word; int completed; struct inode *rip; size_t nrbytes; @@ -38,7 +38,7 @@ int fs_readwrite(void) r = OK; /* Find the inode referred */ - if ((rip = find_inode(fs_dev, (pino_t) fs_m_in.REQ_INODE_NR)) == NULL) + if ((rip = find_inode(fs_dev, (pino_t) fs_m_in.m_vfs_fs_readwrite.inode)) == NULL) return(EINVAL); mode_word = rip->i_mode & I_TYPE; @@ -61,9 +61,9 @@ int fs_readwrite(void) case REQ_PEEK: rw_flag = PEEKING; break; default: panic("odd request"); } - gid = (cp_grant_id_t) fs_m_in.REQ_GRANT; - position = (off_t) fs_m_in.REQ_SEEK_POS; - nrbytes = (size_t) fs_m_in.REQ_NBYTES; + gid = fs_m_in.m_vfs_fs_readwrite.grant; + position = fs_m_in.m_vfs_fs_readwrite.seek_pos; + nrbytes = fs_m_in.m_vfs_fs_readwrite.nbytes; lmfs_reset_rdwt_err(); @@ -113,8 +113,9 @@ int fs_readwrite(void) position += (off_t) chunk; /* position within the file */ } - fs_m_out.RES_SEEK_POS = position; /* It might change later and the VFS - has to know this value */ + fs_m_out.m_fs_vfs_readwrite.seek_pos = position; /* It might change later and + the VFS has to know this + value */ /* On write, update file size and access time. */ if (rw_flag == WRITING) { @@ -137,7 +138,7 @@ int fs_readwrite(void) IN_MARKDIRTY(rip); /* inode is thus now dirty */ } - fs_m_out.RES_NBYTES = cum_io; + fs_m_out.m_fs_vfs_readwrite.nbytes = cum_io; return(r); } diff --git a/servers/pfs/read.c b/servers/pfs/read.c index 342d0baf8..7a5100fb3 100644 --- a/servers/pfs/read.c +++ b/servers/pfs/read.c @@ -15,13 +15,13 @@ int fs_readwrite(message *fs_m_in, message *fs_m_out) cp_grant_id_t gid; off_t position, f_size; unsigned int nrbytes, cum_io; - pmode_t mode_word; + mode_t mode_word; struct inode *rip; - pino_t inumb; + ino_t inumb; r = OK; cum_io = 0; - inumb = (pino_t) fs_m_in->REQ_INODE_NR; + inumb = fs_m_in->m_vfs_fs_readwrite.inode; /* Find the inode referred */ if ((rip = find_inode(inumb)) == NULL) return(EINVAL); @@ -32,8 +32,8 @@ int fs_readwrite(message *fs_m_in, message *fs_m_out) /* Get the values from the request message */ rw_flag = (fs_m_in->m_type == REQ_READ ? READING : WRITING); - gid = (cp_grant_id_t) fs_m_in->REQ_GRANT; - nrbytes = (unsigned) fs_m_in->REQ_NBYTES; + gid = fs_m_in->m_vfs_fs_readwrite.grant; + nrbytes = (unsigned) fs_m_in->m_vfs_fs_readwrite.nbytes; /* We can't read beyond the max file position */ if (nrbytes > PIPE_BUF) return(EFBIG); @@ -87,8 +87,8 @@ int fs_readwrite(message *fs_m_in, message *fs_m_out) if (rw_flag == WRITING) rip->i_update |= CTIME | MTIME; } - fs_m_out->RES_NBYTES = (size_t) cum_io; - fs_m_out->RES_SEEK_POS = rip->i_size; + fs_m_out->m_fs_vfs_readwrite.nbytes = (size_t) cum_io; + fs_m_out->m_fs_vfs_readwrite.seek_pos = rip->i_size; put_inode(rip); put_block(rip->i_dev, rip->i_num); diff --git a/servers/vfs/request.c b/servers/vfs/request.c index d3bf60f13..64b6fb8ad 100644 --- a/servers/vfs/request.c +++ b/servers/vfs/request.c @@ -845,13 +845,13 @@ static int req_readwrite_actual(endpoint_t fs_e, ino_t inode_nr, off_t pos, /* Fill in request message */ m.m_type = rw_flag == READING ? REQ_READ : REQ_WRITE; - m.REQ_INODE_NR = (pino_t) inode_nr; - m.REQ_GRANT = grant_id; - m.REQ_SEEK_POS = pos; + m.m_vfs_fs_readwrite.inode = inode_nr; + m.m_vfs_fs_readwrite.grant = grant_id; + m.m_vfs_fs_readwrite.seek_pos = pos; if ((!(vmp->m_fs_flags & RES_64BIT)) && (pos > INT_MAX)) { return EINVAL; } - m.REQ_NBYTES = num_of_bytes; + m.m_vfs_fs_readwrite.nbytes = num_of_bytes; /* Send/rec request */ r = fs_sendrec(fs_e, &m); @@ -859,8 +859,8 @@ static int req_readwrite_actual(endpoint_t fs_e, ino_t inode_nr, off_t pos, if (r == OK) { /* Fill in response structure */ - *new_posp = m.RES_SEEK_POS; - *cum_iop = m.RES_NBYTES; + *new_posp = m.m_fs_vfs_readwrite.seek_pos; + *cum_iop = m.m_fs_vfs_readwrite.nbytes; } return(r); @@ -905,10 +905,10 @@ int req_peek(endpoint_t fs_e, ino_t inode_nr, off_t pos, unsigned int bytes) /* Fill in request message */ m.m_type = REQ_PEEK; - m.REQ_INODE_NR = inode_nr; - m.REQ_GRANT = -1; - m.REQ_SEEK_POS = pos; - m.REQ_NBYTES = bytes; + m.m_vfs_fs_readwrite.inode = inode_nr; + m.m_vfs_fs_readwrite.grant = -1; + m.m_vfs_fs_readwrite.seek_pos = pos; + m.m_vfs_fs_readwrite.nbytes = bytes; /* Send/rec request */ return fs_sendrec(fs_e, &m);