Message types for VFS bread, bwrite & bpeek

These two request are handled by the same function in some FSes, which
prevents us from using two different kinds of messages.

Change-Id: Ib2fc80bdd56ef67db6b4c51cf8963353a761aab1
This commit is contained in:
Lionel Sambuc 2014-05-01 13:45:58 +02:00
parent a65bf37e3b
commit 27baf1f58a
6 changed files with 52 additions and 30 deletions

View file

@ -146,6 +146,26 @@ typedef struct {
} mess_sigcalls;
_ASSERT_MSG_SIZE(mess_sigcalls);
typedef struct {
dev_t device;
off_t seek_pos;
cp_grant_id_t grant;
size_t nbytes;
uint8_t data[32];
} mess_vfs_fs_breadwrite;
_ASSERT_MSG_SIZE(mess_vfs_fs_breadwrite);
typedef struct {
off_t seek_pos;
size_t nbytes;
uint8_t data[44];
} mess_fs_vfs_breadwrite;
_ASSERT_MSG_SIZE(mess_fs_vfs_breadwrite);
typedef struct {
ino_t inode;
@ -547,6 +567,8 @@ typedef struct {
mess_sigcalls m_sigcalls;
mess_vfs_fs_newnode m_vfs_fs_newnode;
mess_fs_vfs_newnode m_fs_vfs_newnode;
mess_vfs_fs_breadwrite m_vfs_fs_breadwrite;
mess_fs_vfs_breadwrite m_fs_vfs_breadwrite;
mess_vfs_fs_chmod m_vfs_fs_chmod;
mess_fs_vfs_chmod m_fs_vfs_chmod;
mess_vfs_fs_chown m_vfs_fs_chown;

View file

@ -936,9 +936,9 @@ int lmfs_rdwt_err(void)
int lmfs_do_bpeek(message *m)
{
block_t startblock, b, limitblock;
dev_t dev = m->REQ_DEV;
off_t extra, pos = m->REQ_SEEK_POS;
size_t len = m->REQ_NBYTES;
dev_t dev = m->m_vfs_fs_breadwrite.device;
off_t extra, pos = m->m_vfs_fs_breadwrite.seek_pos;
size_t len = m->m_vfs_fs_breadwrite.nbytes;
struct buf *bp;
assert(m->m_type == REQ_BPEEK);

View file

@ -159,13 +159,13 @@ int fs_breadwrite(void)
/* Get the values from the request message */
rw_flag = (fs_m_in.m_type == REQ_BREAD ? READING : WRITING);
gid = (cp_grant_id_t) fs_m_in.REQ_GRANT;
position = fs_m_in.REQ_SEEK_POS;
nrbytes = (size_t) fs_m_in.REQ_NBYTES;
gid = fs_m_in.m_vfs_fs_breadwrite.grant;
position = fs_m_in.m_vfs_fs_breadwrite.seek_pos;
nrbytes = fs_m_in.m_vfs_fs_breadwrite.nbytes;
block_size = get_block_size(fs_m_in.REQ_DEV);
block_size = get_block_size(fs_m_in.m_vfs_fs_breadwrite.device);
rip.i_block[0] = (block_t) fs_m_in.REQ_DEV;
rip.i_block[0] = (block_t) fs_m_in.m_vfs_fs_breadwrite.device;
rip.i_mode = I_BLOCK_SPECIAL;
rip.i_size = 0;
@ -190,12 +190,12 @@ int fs_breadwrite(void)
position += chunk; /* position within the file */
}
fs_m_out.RES_SEEK_POS = position;
fs_m_out.m_fs_vfs_breadwrite.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;
fs_m_out.m_fs_vfs_breadwrite.nbytes = cum_io;
return(r);
}

View file

@ -95,9 +95,9 @@ int fs_bread(void)
r = OK;
rw_flag = (fs_m_in.m_type == REQ_BREAD ? READING : WRITING);
gid = fs_m_in.REQ_GRANT;
position = fs_m_in.REQ_SEEK_POS;
nrbytes = (unsigned) fs_m_in.REQ_NBYTES;
gid = fs_m_in.m_vfs_fs_breadwrite.grant;
position = fs_m_in.m_vfs_fs_breadwrite.seek_pos;
nrbytes = fs_m_in.m_vfs_fs_breadwrite.nbytes;
block_size = v_pri.logical_block_size_l;
dir = v_pri.dir_rec_root;
@ -125,12 +125,12 @@ int fs_bread(void)
position += chunk; /* position within the file */
}
fs_m_out.RES_SEEK_POS = position;
fs_m_out.m_fs_vfs_breadwrite.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;
fs_m_out.m_fs_vfs_breadwrite.nbytes = cum_io;
return(r);
}

View file

@ -160,13 +160,13 @@ int fs_breadwrite(void)
r = OK;
target_dev = fs_m_in.REQ_DEV;
target_dev = fs_m_in.m_vfs_fs_breadwrite.device;
/* Get the values from the request message */
rw_flag = (fs_m_in.m_type == REQ_BREAD ? READING : WRITING);
gid = (cp_grant_id_t) fs_m_in.REQ_GRANT;
position = fs_m_in.REQ_SEEK_POS;
nrbytes = (size_t) fs_m_in.REQ_NBYTES;
gid = fs_m_in.m_vfs_fs_breadwrite.grant;
position = fs_m_in.m_vfs_fs_breadwrite.seek_pos;
nrbytes = fs_m_in.m_vfs_fs_breadwrite.nbytes;
block_size = get_block_size(target_dev);
@ -199,12 +199,12 @@ int fs_breadwrite(void)
position += chunk; /* position within the file */
}
fs_m_out.RES_SEEK_POS = position;
fs_m_out.m_fs_vfs_breadwrite.seek_pos = position;
if (lmfs_rdwt_err() != OK) r = lmfs_rdwt_err(); /* check for disk error */
if (lmfs_rdwt_err() == END_OF_FILE) r = OK;
fs_m_out.RES_NBYTES = cum_io;
fs_m_out.m_fs_vfs_breadwrite.nbytes = cum_io;
return(r);
}

View file

@ -42,10 +42,10 @@ static int req_breadwrite_actual(endpoint_t fs_e, endpoint_t user_e, dev_t dev,
/* Fill in request message */
m.m_type = rw_flag == READING ? REQ_BREAD : REQ_BWRITE;
m.REQ_DEV = dev;
m.REQ_GRANT = grant_id;
m.REQ_SEEK_POS = pos;
m.REQ_NBYTES = num_of_bytes;
m.m_vfs_fs_breadwrite.device = dev;
m.m_vfs_fs_breadwrite.grant = grant_id;
m.m_vfs_fs_breadwrite.seek_pos = pos;
m.m_vfs_fs_breadwrite.nbytes = num_of_bytes;
/* Send/rec request */
r = fs_sendrec(fs_e, &m);
@ -53,8 +53,8 @@ static int req_breadwrite_actual(endpoint_t fs_e, endpoint_t user_e, dev_t dev,
if (r != OK) return(r);
/* Fill in response structure */
*new_pos = m.RES_SEEK_POS;
*cum_iop = m.RES_NBYTES;
*new_pos = m.m_fs_vfs_breadwrite.seek_pos;
*cum_iop = m.m_fs_vfs_breadwrite.nbytes;
return(OK);
}
@ -92,9 +92,9 @@ int req_bpeek(endpoint_t fs_e, dev_t dev, off_t pos, unsigned int num_of_bytes)
/* Fill in request message */
m.m_type = REQ_BPEEK;
m.REQ_DEV = dev;
m.REQ_SEEK_POS = pos;
m.REQ_NBYTES = num_of_bytes;
m.m_vfs_fs_breadwrite.device = dev;
m.m_vfs_fs_breadwrite.seek_pos = pos;
m.m_vfs_fs_breadwrite.nbytes = num_of_bytes;
/* Send/rec request */
return fs_sendrec(fs_e, &m);