} 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;
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;
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;
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);
}
/* 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;
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);
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)
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;
}
/* Write data to a file.
*/
struct inode *ino;
- u64_t pos;
+ off_t pos;
size_t count;
cp_grant_id_t grant;
int r;
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;
}
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. */
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.
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 {
}
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;
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;
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;
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 */
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) {
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);
}
*===========================================================================*/
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;
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 */
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;
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);
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;
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;
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();
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) {
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);
}
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);
/* 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);
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);
/* 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);
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);
/* 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);