From 27baf1f58a47d845253615a2b9aff91db1ad9d03 Mon Sep 17 00:00:00 2001 From: Lionel Sambuc Date: Thu, 1 May 2014 13:45:58 +0200 Subject: [PATCH] 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 --- include/minix/ipc.h | 22 ++++++++++++++++++++++ lib/libminixfs/cache.c | 6 +++--- servers/ext2/read.c | 14 +++++++------- servers/iso9660fs/read.c | 10 +++++----- servers/mfs/read.c | 12 ++++++------ servers/vfs/request.c | 18 +++++++++--------- 6 files changed, 52 insertions(+), 30 deletions(-) diff --git a/include/minix/ipc.h b/include/minix/ipc.h index f0715624d..7c0a1ae3b 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -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; diff --git a/lib/libminixfs/cache.c b/lib/libminixfs/cache.c index d61e7a427..f503f8cc3 100644 --- a/lib/libminixfs/cache.c +++ b/lib/libminixfs/cache.c @@ -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); diff --git a/servers/ext2/read.c b/servers/ext2/read.c index 244baab1f..130a82710 100644 --- a/servers/ext2/read.c +++ b/servers/ext2/read.c @@ -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); } diff --git a/servers/iso9660fs/read.c b/servers/iso9660fs/read.c index a6f152ae1..c5717d90b 100644 --- a/servers/iso9660fs/read.c +++ b/servers/iso9660fs/read.c @@ -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); } diff --git a/servers/mfs/read.c b/servers/mfs/read.c index f3a0533b3..f947cf57d 100644 --- a/servers/mfs/read.c +++ b/servers/mfs/read.c @@ -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); } diff --git a/servers/vfs/request.c b/servers/vfs/request.c index c93795b63..d3bf60f13 100644 --- a/servers/vfs/request.c +++ b/servers/vfs/request.c @@ -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);