From 43d985050cfea4d8a35b7d1d85546165bcd1b4b6 Mon Sep 17 00:00:00 2001 From: Lionel Sambuc Date: Mon, 28 Jul 2014 07:13:42 +0200 Subject: [PATCH] Use one message type for all BDEV request. There are missing field assignements, and/or messsages being re-used without re-initializations, which allows for fields to be implicitly forwarded. This prevents me from creating per request message types, as I can't spend currently any more time debugging this issue. --- drivers/fb/fb_edid.c | 26 ++++++++-------- drivers/fbd/fbd.c | 44 +++++++++++++-------------- drivers/filter/driver.c | 36 +++++++++++------------ include/minix/com.h | 11 ------- include/minix/ipc.h | 19 ++++++++++++ lib/libbdev/bdev.c | 54 +++++++++++++++++----------------- lib/libbdev/ipc.c | 4 +-- lib/libbdev/minor.c | 6 ++-- lib/libblockdriver/driver.c | 40 ++++++++++++------------- lib/libblockdriver/driver_mt.c | 2 +- lib/libblockdriver/trace.c | 12 ++++---- lib/libchardriver/chardriver.c | 2 +- servers/vfs/device.c | 24 +++++++-------- test/blocktest/blocktest.c | 54 +++++++++++++++++----------------- 14 files changed, 171 insertions(+), 163 deletions(-) diff --git a/drivers/fb/fb_edid.c b/drivers/fb/fb_edid.c index 9c200d8a6..588e77a53 100644 --- a/drivers/fb/fb_edid.c +++ b/drivers/fb/fb_edid.c @@ -92,9 +92,9 @@ do_read(endpoint_t driver_endpt, uint8_t *buf, size_t bufsize) /* Open Device - required for drivers using libblockdriver */ memset(&m, '\0', sizeof(message)); m.m_type = BDEV_OPEN; - m.BDEV_ACCESS = BDEV_R_BIT; - m.BDEV_ID = 0; - m.BDEV_MINOR = 0; + m.m_lbdev_lblockdriver_msg.access = BDEV_R_BIT; + m.m_lbdev_lblockdriver_msg.id = 0; + m.m_lbdev_lblockdriver_msg.minor = 0; r = ipc_sendrec(driver_endpt, &m); if (r != OK) { @@ -108,12 +108,12 @@ do_read(endpoint_t driver_endpt, uint8_t *buf, size_t bufsize) /* Perform the read */ memset(&m, '\0', sizeof(message)); m.m_type = BDEV_READ; - m.BDEV_MINOR = 0; - m.BDEV_COUNT = bufsize; - m.BDEV_GRANT = grant_nr; - m.BDEV_FLAGS = BDEV_NOPAGE; /* the EEPROMs used for EDID are pageless */ - m.BDEV_ID = 0; - m.BDEV_POS = 0; + m.m_lbdev_lblockdriver_msg.minor = 0; + m.m_lbdev_lblockdriver_msg.count = bufsize; + m.m_lbdev_lblockdriver_msg.grant = grant_nr; + m.m_lbdev_lblockdriver_msg.flags = BDEV_NOPAGE; /* the EEPROMs used for EDID are pageless */ + m.m_lbdev_lblockdriver_msg.id = 0; + m.m_lbdev_lblockdriver_msg.pos = 0; r = ipc_sendrec(driver_endpt, &m); cpf_revoke(grant_nr); @@ -122,8 +122,8 @@ do_read(endpoint_t driver_endpt, uint8_t *buf, size_t bufsize) /* Clean-up: try to close the device */ memset(&m, '\0', sizeof(message)); m.m_type = BDEV_CLOSE; - m.BDEV_MINOR = 0; - m.BDEV_ID = 0; + m.m_lbdev_lblockdriver_msg.minor = 0; + m.m_lbdev_lblockdriver_msg.id = 0; ipc_sendrec(driver_endpt, &m); return r; } @@ -131,8 +131,8 @@ do_read(endpoint_t driver_endpt, uint8_t *buf, size_t bufsize) /* Close the device */ memset(&m, '\0', sizeof(message)); m.m_type = BDEV_CLOSE; - m.BDEV_MINOR = 0; - m.BDEV_ID = 0; + m.m_lbdev_lblockdriver_msg.minor = 0; + m.m_lbdev_lblockdriver_msg.id = 0; r = ipc_sendrec(driver_endpt, &m); if (r != OK) { log_debug(&log, "ipc_sendrec(BDEV_CLOSE) failed (r=%d)\n", r); diff --git a/drivers/fbd/fbd.c b/drivers/fbd/fbd.c index 40eb3527e..c85148a46 100644 --- a/drivers/fbd/fbd.c +++ b/drivers/fbd/fbd.c @@ -149,9 +149,9 @@ static int fbd_open(devminor_t UNUSED(minor), int access) /* We simply forward this request to the real driver. */ memset(&m, 0, sizeof(m)); m.m_type = BDEV_OPEN; - m.BDEV_MINOR = driver_minor; - m.BDEV_ACCESS = access; - m.BDEV_ID = 0; + m.m_lbdev_lblockdriver_msg.minor = driver_minor; + m.m_lbdev_lblockdriver_msg.access = access; + m.m_lbdev_lblockdriver_msg.id = 0; if ((r = ipc_sendrec(driver_endpt, &m)) != OK) panic("ipc_sendrec to driver failed (%d)\n", r); @@ -174,8 +174,8 @@ static int fbd_close(devminor_t UNUSED(minor)) /* We simply forward this request to the real driver. */ memset(&m, 0, sizeof(m)); m.m_type = BDEV_CLOSE; - m.BDEV_MINOR = driver_minor; - m.BDEV_ID = 0; + m.m_lbdev_lblockdriver_msg.minor = driver_minor; + m.m_lbdev_lblockdriver_msg.id = 0; if ((r = ipc_sendrec(driver_endpt, &m)) != OK) panic("ipc_sendrec to driver failed (%d)\n", r); @@ -212,11 +212,11 @@ static int fbd_ioctl(devminor_t UNUSED(minor), unsigned long request, memset(&m, 0, sizeof(m)); m.m_type = BDEV_IOCTL; - m.BDEV_MINOR = driver_minor; - m.BDEV_REQUEST = request; - m.BDEV_GRANT = gid; - m.BDEV_USER = NONE; - m.BDEV_ID = 0; + m.m_lbdev_lblockdriver_msg.minor = driver_minor; + m.m_lbdev_lblockdriver_msg.request = request; + m.m_lbdev_lblockdriver_msg.grant = gid; + m.m_lbdev_lblockdriver_msg.user = NONE; + m.m_lbdev_lblockdriver_msg.id = 0; if ((r = ipc_sendrec(driver_endpt, &m)) != OK) panic("ipc_sendrec to driver failed (%d)\n", r); @@ -253,12 +253,12 @@ static ssize_t fbd_transfer_direct(int do_write, u64_t position, assert(grant != GRANT_INVALID); m.m_type = do_write ? BDEV_SCATTER : BDEV_GATHER; - m.BDEV_MINOR = driver_minor; - m.BDEV_COUNT = count; - m.BDEV_GRANT = grant; - m.BDEV_FLAGS = flags; - m.BDEV_ID = 0; - m.BDEV_POS = position; + m.m_lbdev_lblockdriver_msg.minor = driver_minor; + m.m_lbdev_lblockdriver_msg.count = count; + m.m_lbdev_lblockdriver_msg.grant = grant; + m.m_lbdev_lblockdriver_msg.flags = flags; + m.m_lbdev_lblockdriver_msg.id = 0; + m.m_lbdev_lblockdriver_msg.pos = position; if ((r = ipc_sendrec(driver_endpt, &m)) != OK) panic("ipc_sendrec to driver failed (%d)\n", r); @@ -345,12 +345,12 @@ static ssize_t fbd_transfer_copy(int do_write, u64_t position, assert(grant != GRANT_INVALID); m.m_type = do_write ? BDEV_SCATTER : BDEV_GATHER; - m.BDEV_MINOR = driver_minor; - m.BDEV_COUNT = count; - m.BDEV_GRANT = grant; - m.BDEV_FLAGS = flags; - m.BDEV_ID = 0; - m.BDEV_POS = position; + m.m_lbdev_lblockdriver_msg.minor = driver_minor; + m.m_lbdev_lblockdriver_msg.count = count; + m.m_lbdev_lblockdriver_msg.grant = grant; + m.m_lbdev_lblockdriver_msg.flags = flags; + m.m_lbdev_lblockdriver_msg.id = 0; + m.m_lbdev_lblockdriver_msg.pos = position; if ((r = ipc_sendrec(driver_endpt, &m)) != OK) panic("ipc_sendrec to driver failed (%d)\n", r); diff --git a/drivers/filter/driver.c b/drivers/filter/driver.c index be0e9c460..352c00acd 100644 --- a/drivers/filter/driver.c +++ b/drivers/filter/driver.c @@ -30,9 +30,9 @@ static int driver_open(int which) memset(&msg, 0, sizeof(msg)); msg.m_type = BDEV_OPEN; - msg.BDEV_MINOR = driver[which].minor; - msg.BDEV_ACCESS = BDEV_R_BIT | BDEV_W_BIT; - msg.BDEV_ID = 0; + msg.m_lbdev_lblockdriver_msg.minor = driver[which].minor; + msg.m_lbdev_lblockdriver_msg.access = BDEV_R_BIT | BDEV_W_BIT; + msg.m_lbdev_lblockdriver_msg.id = 0; r = ipc_sendrec(driver[which].endpt, &msg); if (r != OK) { @@ -58,11 +58,11 @@ static int driver_open(int which) memset(&msg, 0, sizeof(msg)); msg.m_type = BDEV_IOCTL; - msg.BDEV_MINOR = driver[which].minor; - msg.BDEV_REQUEST = DIOCGETP; - msg.BDEV_GRANT = gid; - msg.BDEV_USER = NONE; - msg.BDEV_ID = 0; + msg.m_lbdev_lblockdriver_msg.minor = driver[which].minor; + msg.m_lbdev_lblockdriver_msg.request = DIOCGETP; + msg.m_lbdev_lblockdriver_msg.grant = gid; + msg.m_lbdev_lblockdriver_msg.user = NONE; + msg.m_lbdev_lblockdriver_msg.id = 0; r = ipc_sendrec(driver[which].endpt, &msg); @@ -113,8 +113,8 @@ static int driver_close(int which) memset(&msg, 0, sizeof(msg)); msg.m_type = BDEV_CLOSE; - msg.BDEV_MINOR = driver[which].minor; - msg.BDEV_ID = 0; + msg.m_lbdev_lblockdriver_msg.minor = driver[which].minor; + msg.m_lbdev_lblockdriver_msg.id = 0; r = ipc_sendrec(driver[which].endpt, &msg); if (r != OK) { @@ -526,8 +526,8 @@ static int flt_senda(message *mess, int which) asynmsg_t *amp; /* Fill in the last bits of the message. */ - mess->BDEV_MINOR = driver[which].minor; - mess->BDEV_ID = 0; + mess->m_lbdev_lblockdriver_msg.minor = driver[which].minor; + mess->m_lbdev_lblockdriver_msg.id = 0; /* Send the message asynchronously. */ amp = &amsgtable[which]; @@ -774,8 +774,8 @@ static int paired_sendrec(message *m1, message *m2, int both) #if DEBUG2 printf("paired_sendrec(%d) - <%d,%llx,%d> - %x,%x\n", - both, m1->m_type, m1->BDEV_POS, - m1->BDEV_COUNT, m1->BDEV_GRANT, m2->BDEV_GRANT); + both, m1->m_type, m1->m_lbdev_lblockdriver_msg.pos, + m1->m_lbdev_lblockdriver_msg.count, m1->m_lbdev_lblockdriver_msg.grant, m2->m_lbdev_lblockdriver_msg.grant); #endif if (both) @@ -921,13 +921,13 @@ int read_write(u64_t pos, char *bufa, char *bufb, size_t *sizep, int request) memset(&m1, 0, sizeof(m1)); m1.m_type = (request == FLT_WRITE) ? BDEV_SCATTER : BDEV_GATHER; - m1.BDEV_COUNT = count; - m1.BDEV_POS = pos; + m1.m_lbdev_lblockdriver_msg.count = count; + m1.m_lbdev_lblockdriver_msg.pos = pos; m2 = m1; - m1.BDEV_GRANT = gids[0]; - m2.BDEV_GRANT = gids[1]; + m1.m_lbdev_lblockdriver_msg.grant = gids[0]; + m2.m_lbdev_lblockdriver_msg.grant = gids[1]; r = paired_sendrec(&m1, &m2, both); diff --git a/include/minix/com.h b/include/minix/com.h index 7756c58b3..7736a62b2 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -926,17 +926,6 @@ /* Message types for block device responses. */ #define BDEV_REPLY (BDEV_RS_BASE + 0) /* general reply code */ -/* Field names for block device messages. */ -#define BDEV_MINOR m10_i1 /* minor device number */ -#define BDEV_ACCESS m10_i2 /* access bits for open requests */ -#define BDEV_COUNT m10_i2 /* number of bytes or elements in transfer */ -#define BDEV_GRANT m10_i3 /* grant ID of buffer or vector */ -#define BDEV_FLAGS m10_i4 /* transfer flags */ -#define BDEV_USER m10_i4 /* user endpoint requesting I/O control */ -#define BDEV_ID m10_l1 /* opaque request ID */ -#define BDEV_REQUEST m10_l2 /* I/O control request */ -#define BDEV_POS m10_ull1 /* transfer position */ - /* Bits in 'BDEV_ACCESS' field of block device open requests. */ # define BDEV_R_BIT 0x01 /* open with read access */ # define BDEV_W_BIT 0x02 /* open with write access */ diff --git a/include/minix/ipc.h b/include/minix/ipc.h index 7b1667e0a..b6d2fdac8 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -124,6 +124,24 @@ typedef struct { } mess_lsys_krn_readbios; _ASSERT_MSG_SIZE(mess_lsys_krn_readbios); +typedef struct { + off_t pos; + + int minor; + int id; + int access; + + int count; + cp_grant_id_t grant; + int flags; + + endpoint_t user; + int request; + + uint8_t padding[16]; +} mess_lbdev_lblockdriver_msg; +_ASSERT_MSG_SIZE(mess_lbdev_lblockdriver_msg); + typedef struct { int status; int id; @@ -2040,6 +2058,7 @@ typedef struct { mess_notify m_notify; mess_sigcalls m_sigcalls; + mess_lbdev_lblockdriver_msg m_lbdev_lblockdriver_msg; mess_lblockdriver_lbdev_reply m_lblockdriver_lbdev_reply; mess_lc_pm_cprof m_lc_pm_cprof; mess_lc_pm_sprof m_lc_pm_sprof; diff --git a/lib/libbdev/bdev.c b/lib/libbdev/bdev.c index 76737d75f..61f1fdfe2 100644 --- a/lib/libbdev/bdev.c +++ b/lib/libbdev/bdev.c @@ -68,8 +68,8 @@ static int bdev_opcl(int req, dev_t dev, int access) do { memset(&m, 0, sizeof(m)); m.m_type = req; - m.BDEV_MINOR = minor(dev); - m.BDEV_ACCESS = access; + m.m_lbdev_lblockdriver_msg.minor = minor(dev); + m.m_lbdev_lblockdriver_msg.access = access; r = bdev_sendrec(dev, &m); } while (bdev_retry(&driver_tries, NULL, &r)); @@ -134,11 +134,11 @@ static int bdev_rdwt_setup(int req, dev_t dev, u64_t pos, char *buf, memset(m, 0, sizeof(*m)); m->m_type = req; - m->BDEV_MINOR = minor(dev); - m->BDEV_POS = pos; - m->BDEV_COUNT = count; - m->BDEV_GRANT = grant; - m->BDEV_FLAGS = flags; + m->m_lbdev_lblockdriver_msg.minor = minor(dev); + m->m_lbdev_lblockdriver_msg.pos = pos; + m->m_lbdev_lblockdriver_msg.count = count; + m->m_lbdev_lblockdriver_msg.grant = grant; + m->m_lbdev_lblockdriver_msg.flags = flags; return OK; } @@ -148,7 +148,7 @@ static void bdev_rdwt_cleanup(const message *m) /* Clean up a single-buffer read/write request. */ - cpf_revoke(m->BDEV_GRANT); + cpf_revoke(m->m_lbdev_lblockdriver_msg.grant); } static ssize_t bdev_rdwt(int req, dev_t dev, u64_t pos, char *buf, @@ -225,11 +225,11 @@ static int bdev_vrdwt_setup(int req, dev_t dev, u64_t pos, iovec_t *vec, memset(m, 0, sizeof(*m)); m->m_type = req; - m->BDEV_MINOR = minor(dev); - m->BDEV_POS = pos; - m->BDEV_COUNT = count; - m->BDEV_GRANT = grant; - m->BDEV_FLAGS = flags; + m->m_lbdev_lblockdriver_msg.minor = minor(dev); + m->m_lbdev_lblockdriver_msg.pos = pos; + m->m_lbdev_lblockdriver_msg.count = count; + m->m_lbdev_lblockdriver_msg.grant = grant; + m->m_lbdev_lblockdriver_msg.flags = flags; return OK; } @@ -241,11 +241,11 @@ static void bdev_vrdwt_cleanup(const message *m, iovec_s_t *gvec) cp_grant_id_t grant; int i; - grant = m->BDEV_GRANT; + grant = m->m_lbdev_lblockdriver_msg.grant; cpf_revoke(grant); - for (i = m->BDEV_COUNT - 1; i >= 0; i--) + for (i = m->m_lbdev_lblockdriver_msg.count - 1; i >= 0; i--) cpf_revoke(gvec[i].iov_grant); } @@ -335,10 +335,10 @@ static int bdev_ioctl_setup(dev_t dev, int request, void *buf, memset(m, 0, sizeof(*m)); m->m_type = BDEV_IOCTL; - m->BDEV_MINOR = minor(dev); - m->BDEV_REQUEST = request; - m->BDEV_GRANT = grant; - m->BDEV_USER = user_endpt; + m->m_lbdev_lblockdriver_msg.minor = minor(dev); + m->m_lbdev_lblockdriver_msg.request = request; + m->m_lbdev_lblockdriver_msg.grant = grant; + m->m_lbdev_lblockdriver_msg.user = user_endpt; return OK; } @@ -348,7 +348,7 @@ static void bdev_ioctl_cleanup(const message *m) /* Clean up an I/O control request. */ - cpf_revoke(m->BDEV_GRANT); + cpf_revoke(m->m_lbdev_lblockdriver_msg.grant); } int bdev_ioctl(dev_t dev, int request, void *buf, endpoint_t user_endpt) @@ -603,9 +603,9 @@ int bdev_restart_asyn(bdev_call_t *call) bdev_rdwt_cleanup(&call->msg); r = bdev_rdwt_setup(type, call->dev, - call->msg.BDEV_POS, - (char *) call->vec[0].iov_addr, call->msg.BDEV_COUNT, - call->msg.BDEV_FLAGS, &call->msg); + call->msg.m_lbdev_lblockdriver_msg.pos, + (char *) call->vec[0].iov_addr, call->msg.m_lbdev_lblockdriver_msg.count, + call->msg.m_lbdev_lblockdriver_msg.flags, &call->msg); break; @@ -614,8 +614,8 @@ int bdev_restart_asyn(bdev_call_t *call) bdev_vrdwt_cleanup(&call->msg, call->gvec); r = bdev_vrdwt_setup(type, call->dev, - call->msg.BDEV_POS, - call->vec, call->msg.BDEV_COUNT, call->msg.BDEV_FLAGS, + call->msg.m_lbdev_lblockdriver_msg.pos, + call->vec, call->msg.m_lbdev_lblockdriver_msg.count, call->msg.m_lbdev_lblockdriver_msg.flags, &call->msg, call->gvec); break; @@ -623,8 +623,8 @@ int bdev_restart_asyn(bdev_call_t *call) case BDEV_IOCTL: bdev_ioctl_cleanup(&call->msg); - r = bdev_ioctl_setup(call->dev, call->msg.BDEV_REQUEST, - (char *) call->vec[0].iov_addr, call->msg.BDEV_USER, + r = bdev_ioctl_setup(call->dev, call->msg.m_lbdev_lblockdriver_msg.request, + (char *) call->vec[0].iov_addr, call->msg.m_lbdev_lblockdriver_msg.user, &call->msg); break; diff --git a/lib/libbdev/ipc.c b/lib/libbdev/ipc.c index 53ce3977c..7739d19d8 100644 --- a/lib/libbdev/ipc.c +++ b/lib/libbdev/ipc.c @@ -131,7 +131,7 @@ int bdev_senda(dev_t dev, const message *m_orig, bdev_id_t id) return EDEADSRCDST; m = *m_orig; - m.BDEV_ID = id; + m.m_lbdev_lblockdriver_msg.id = id; r = asynsend(endpt, &m); @@ -156,7 +156,7 @@ int bdev_sendrec(dev_t dev, const message *m_orig) /* Send the request and block until we receive a reply. */ m = *m_orig; - m.BDEV_ID = NO_ID; + m.m_lbdev_lblockdriver_msg.id = NO_ID; r = ipc_sendrec(endpt, &m); diff --git a/lib/libbdev/minor.c b/lib/libbdev/minor.c index 4f1aeb74e..ca827a7a8 100644 --- a/lib/libbdev/minor.c +++ b/lib/libbdev/minor.c @@ -42,9 +42,9 @@ int bdev_minor_reopen(dev_t dev) for (j = 0; j < open_dev[i].count; j++) { memset(&m, 0, sizeof(m)); m.m_type = BDEV_OPEN; - m.BDEV_MINOR = minor(open_dev[i].dev); - m.BDEV_ACCESS = open_dev[i].access; - m.BDEV_ID = NO_ID; + m.m_lbdev_lblockdriver_msg.minor = minor(open_dev[i].dev); + m.m_lbdev_lblockdriver_msg.access = open_dev[i].access; + m.m_lbdev_lblockdriver_msg.id = NO_ID; if ((r = ipc_sendrec(endpt, &m)) != OK) { printf("bdev: IPC to driver (%d) failed (%d)\n", diff --git a/lib/libblockdriver/driver.c b/lib/libblockdriver/driver.c index fd55aa7c3..a67c76669 100644 --- a/lib/libblockdriver/driver.c +++ b/lib/libblockdriver/driver.c @@ -162,7 +162,7 @@ void blockdriver_reply(message *m_ptr, int ipc_status, int reply) m_reply.m_type = BDEV_REPLY; m_reply.m_lblockdriver_lbdev_reply.status = reply; - m_reply.m_lblockdriver_lbdev_reply.id = m_ptr->BDEV_ID; + m_reply.m_lblockdriver_lbdev_reply.id = m_ptr->m_lbdev_lblockdriver_msg.id; send_reply(m_ptr->m_source, &m_reply, ipc_status); } @@ -174,7 +174,7 @@ static int do_open(struct blockdriver *bdp, message *mp) { /* Open a minor device. */ - return (*bdp->bdr_open)(mp->BDEV_MINOR, mp->BDEV_ACCESS); + return (*bdp->bdr_open)(mp->m_lbdev_lblockdriver_msg.minor, mp->m_lbdev_lblockdriver_msg.access); } /*===========================================================================* @@ -184,7 +184,7 @@ static int do_close(struct blockdriver *bdp, message *mp) { /* Close a minor device. */ - return (*bdp->bdr_close)(mp->BDEV_MINOR); + return (*bdp->bdr_close)(mp->m_lbdev_lblockdriver_msg.minor); } /*===========================================================================* @@ -199,18 +199,18 @@ static int do_rdwt(struct blockdriver *bdp, message *mp) ssize_t r; /* Disk address? Address and length of the user buffer? */ - if (mp->BDEV_COUNT < 0) return EINVAL; + if (mp->m_lbdev_lblockdriver_msg.count < 0) return EINVAL; /* Create a one element scatter/gather vector for the buffer. */ - iovec1.iov_addr = mp->BDEV_GRANT; - iovec1.iov_size = mp->BDEV_COUNT; + iovec1.iov_addr = mp->m_lbdev_lblockdriver_msg.grant; + iovec1.iov_size = mp->m_lbdev_lblockdriver_msg.count; /* Transfer bytes from/to the device. */ do_write = (mp->m_type == BDEV_WRITE); - position = mp->BDEV_POS; + position = mp->m_lbdev_lblockdriver_msg.pos; - r = (*bdp->bdr_transfer)(mp->BDEV_MINOR, do_write, position, mp->m_source, - &iovec1, 1, mp->BDEV_FLAGS); + r = (*bdp->bdr_transfer)(mp->m_lbdev_lblockdriver_msg.minor, do_write, position, mp->m_source, + &iovec1, 1, mp->m_lbdev_lblockdriver_msg.flags); /* Return the number of bytes transferred or an error code. */ return r; @@ -229,10 +229,10 @@ static int do_vrdwt(struct blockdriver *bdp, message *mp, thread_id_t id) ssize_t r, size; /* Copy the vector from the caller to kernel space. */ - nr_req = mp->BDEV_COUNT; /* Length of I/O vector */ + nr_req = mp->m_lbdev_lblockdriver_msg.count; /* Length of I/O vector */ if (nr_req > NR_IOREQS) nr_req = NR_IOREQS; - if (OK != sys_safecopyfrom(mp->m_source, (vir_bytes) mp->BDEV_GRANT, + if (OK != sys_safecopyfrom(mp->m_source, (vir_bytes) mp->m_lbdev_lblockdriver_msg.grant, 0, (vir_bytes) iovec, nr_req * sizeof(iovec[0]))) { printf("blockdriver: bad I/O vector by: %d\n", mp->m_source); return EINVAL; @@ -248,10 +248,10 @@ static int do_vrdwt(struct blockdriver *bdp, message *mp, thread_id_t id) /* Transfer bytes from/to the device. */ do_write = (mp->m_type == BDEV_SCATTER); - position = mp->BDEV_POS; + position = mp->m_lbdev_lblockdriver_msg.pos; - r = (*bdp->bdr_transfer)(mp->BDEV_MINOR, do_write, position, mp->m_source, - iovec, nr_req, mp->BDEV_FLAGS); + r = (*bdp->bdr_transfer)(mp->m_lbdev_lblockdriver_msg.minor, do_write, position, mp->m_source, + iovec, nr_req, mp->m_lbdev_lblockdriver_msg.flags); /* Return the number of bytes transferred or an error code. */ return r; @@ -322,10 +322,10 @@ static int do_ioctl(struct blockdriver *bdp, message *mp) endpoint_t user_endpt; int r; - minor = mp->BDEV_MINOR; - request = mp->BDEV_REQUEST; - grant = mp->BDEV_GRANT; - user_endpt = mp->BDEV_USER; + minor = mp->m_lbdev_lblockdriver_msg.minor; + request = mp->m_lbdev_lblockdriver_msg.request; + grant = mp->m_lbdev_lblockdriver_msg.grant; + user_endpt = mp->m_lbdev_lblockdriver_msg.user; switch (request) { case BIOCTRACEBUF: @@ -422,7 +422,7 @@ void blockdriver_process_on_thread(struct blockdriver *bdp, message *m_ptr, * requests on devices that have not previously been opened, signaling the * caller that something went wrong. */ - if (IS_BDEV_RQ(m_ptr->m_type) && !is_open_dev(m_ptr->BDEV_MINOR)) { + if (IS_BDEV_RQ(m_ptr->m_type) && !is_open_dev(m_ptr->m_lbdev_lblockdriver_msg.minor)) { /* Reply ERESTART to spurious requests for unopened devices. */ if (m_ptr->m_type != BDEV_OPEN) { blockdriver_reply(m_ptr, ipc_status, ERESTART); @@ -431,7 +431,7 @@ void blockdriver_process_on_thread(struct blockdriver *bdp, message *m_ptr, } /* Mark the device as opened otherwise. */ - set_open_dev(m_ptr->BDEV_MINOR); + set_open_dev(m_ptr->m_lbdev_lblockdriver_msg.minor); } trace_start(id, m_ptr); diff --git a/lib/libblockdriver/driver_mt.c b/lib/libblockdriver/driver_mt.c index fb1df760e..66d694854 100644 --- a/lib/libblockdriver/driver_mt.c +++ b/lib/libblockdriver/driver_mt.c @@ -298,7 +298,7 @@ static void master_handle_message(message *m_ptr, int ipc_status) } /* Query the device ID. Upon failure, send the error code to the caller. */ - r = (*bdtab->bdr_device)(m_ptr->BDEV_MINOR, &id); + r = (*bdtab->bdr_device)(m_ptr->m_lbdev_lblockdriver_msg.minor, &id); if (r != OK) { blockdriver_reply(m_ptr, ipc_status, r); diff --git a/lib/libblockdriver/trace.c b/lib/libblockdriver/trace.c index 008f7a114..63c2cec31 100644 --- a/lib/libblockdriver/trace.c +++ b/lib/libblockdriver/trace.c @@ -174,7 +174,7 @@ void trace_start(thread_id_t id, message *m_ptr) size_t size; int flags; - if (!trace_enabled || trace_dev != m_ptr->BDEV_MINOR) return; + if (!trace_enabled || trace_dev != m_ptr->m_lbdev_lblockdriver_msg.minor) return; assert(id >= 0 && id < MAX_THREADS + 1); @@ -196,7 +196,7 @@ void trace_start(thread_id_t id, message *m_ptr) case BDEV_OPEN: case BDEV_CLOSE: pos = 0; - size = m_ptr->BDEV_ACCESS; + size = m_ptr->m_lbdev_lblockdriver_msg.access; flags = 0; break; @@ -205,15 +205,15 @@ void trace_start(thread_id_t id, message *m_ptr) case BDEV_WRITE: case BDEV_GATHER: case BDEV_SCATTER: - pos = m_ptr->BDEV_POS; - size = m_ptr->BDEV_COUNT; - flags = m_ptr->BDEV_FLAGS; + pos = m_ptr->m_lbdev_lblockdriver_msg.pos; + size = m_ptr->m_lbdev_lblockdriver_msg.count; + flags = m_ptr->m_lbdev_lblockdriver_msg.flags; break; case BDEV_IOCTL: pos = 0; - size = m_ptr->BDEV_REQUEST; + size = m_ptr->m_lbdev_lblockdriver_msg.request; flags = 0; /* Do not log trace control requests. */ diff --git a/lib/libchardriver/chardriver.c b/lib/libchardriver/chardriver.c index 292eb4dcd..407df37d2 100644 --- a/lib/libchardriver/chardriver.c +++ b/lib/libchardriver/chardriver.c @@ -443,7 +443,7 @@ static void do_block_open(message *m_ptr, int ipc_status) m_reply.m_type = BDEV_REPLY; m_reply.m_lblockdriver_lbdev_reply.status = ENXIO; - m_reply.m_lblockdriver_lbdev_reply.id = m_ptr->BDEV_ID; + m_reply.m_lblockdriver_lbdev_reply.id = m_ptr->m_lbdev_lblockdriver_msg.id; send_reply(m_ptr->m_source, &m_reply, ipc_status); } diff --git a/servers/vfs/device.c b/servers/vfs/device.c index 06eec3984..c76951471 100644 --- a/servers/vfs/device.c +++ b/servers/vfs/device.c @@ -56,11 +56,11 @@ int bdev_open(dev_t dev, int access) memset(&dev_mess, 0, sizeof(dev_mess)); dev_mess.m_type = BDEV_OPEN; - dev_mess.BDEV_MINOR = minor_dev; - dev_mess.BDEV_ACCESS = 0; - if (access & R_BIT) dev_mess.BDEV_ACCESS |= BDEV_R_BIT; - if (access & W_BIT) dev_mess.BDEV_ACCESS |= BDEV_W_BIT; - dev_mess.BDEV_ID = 0; + dev_mess.m_lbdev_lblockdriver_msg.minor = minor_dev; + dev_mess.m_lbdev_lblockdriver_msg.access = 0; + if (access & R_BIT) dev_mess.m_lbdev_lblockdriver_msg.access |= BDEV_R_BIT; + if (access & W_BIT) dev_mess.m_lbdev_lblockdriver_msg.access |= BDEV_W_BIT; + dev_mess.m_lbdev_lblockdriver_msg.id = 0; /* Call the task. */ r = block_io(dmap[major_dev].dmap_driver, &dev_mess); @@ -89,8 +89,8 @@ int bdev_close(dev_t dev) memset(&dev_mess, 0, sizeof(dev_mess)); dev_mess.m_type = BDEV_CLOSE; - dev_mess.BDEV_MINOR = minor_dev; - dev_mess.BDEV_ID = 0; + dev_mess.m_lbdev_lblockdriver_msg.minor = minor_dev; + dev_mess.m_lbdev_lblockdriver_msg.id = 0; r = block_io(dmap[major_dev].dmap_driver, &dev_mess); if (r != OK) @@ -131,11 +131,11 @@ static int bdev_ioctl(dev_t dev, endpoint_t proc_e, unsigned long req, memset(&dev_mess, 0, sizeof(dev_mess)); dev_mess.m_type = BDEV_IOCTL; - dev_mess.BDEV_MINOR = minor_dev; - dev_mess.BDEV_REQUEST = req; - dev_mess.BDEV_GRANT = gid; - dev_mess.BDEV_USER = proc_e; - dev_mess.BDEV_ID = 0; + dev_mess.m_lbdev_lblockdriver_msg.minor = minor_dev; + dev_mess.m_lbdev_lblockdriver_msg.request = req; + dev_mess.m_lbdev_lblockdriver_msg.grant = gid; + dev_mess.m_lbdev_lblockdriver_msg.user = proc_e; + dev_mess.m_lbdev_lblockdriver_msg.id = 0; /* Call the task. */ r = block_io(dp->dmap_driver, &dev_mess); diff --git a/test/blocktest/blocktest.c b/test/blocktest/blocktest.c index ffd9f3f98..60ec18fe8 100644 --- a/test/blocktest/blocktest.c +++ b/test/blocktest/blocktest.c @@ -225,9 +225,9 @@ static void reopen_device(dev_t minor) memset(&m, 0, sizeof(m)); m.m_type = BDEV_OPEN; - m.BDEV_MINOR = minor; - m.BDEV_ACCESS = (may_write) ? (BDEV_R_BIT | BDEV_W_BIT) : BDEV_R_BIT; - m.BDEV_ID = 0; + m.m_lbdev_lblockdriver_msg.minor = minor; + m.m_lbdev_lblockdriver_msg.access = (may_write) ? (BDEV_R_BIT | BDEV_W_BIT) : BDEV_R_BIT; + m.m_lbdev_lblockdriver_msg.id = 0; (void) ipc_sendrec(driver_endpt, &m); } @@ -279,7 +279,7 @@ static int sendrec_driver(message *m_ptr, ssize_t exp, result_t *res) if (m_ptr->m_type != BDEV_REPLY) return set_result(res, RESULT_BADTYPE, m_ptr->m_type); - if (m_ptr->m_lblockdriver_lbdev_reply.id != m_orig.BDEV_ID) + if (m_ptr->m_lblockdriver_lbdev_reply.id != m_orig.m_lbdev_lblockdriver_msg.id) return set_result(res, RESULT_BADID, m_ptr->m_lblockdriver_lbdev_reply.id); @@ -310,11 +310,11 @@ static void raw_xfer(dev_t minor, u64_t pos, iovec_s_t *iovec, int nr_req, memset(&m, 0, sizeof(m)); m.m_type = write ? BDEV_SCATTER : BDEV_GATHER; - m.BDEV_MINOR = minor; - m.BDEV_POS = pos; - m.BDEV_COUNT = nr_req; - m.BDEV_GRANT = grant; - m.BDEV_ID = lrand48(); + m.m_lbdev_lblockdriver_msg.minor = minor; + m.m_lbdev_lblockdriver_msg.pos = pos; + m.m_lbdev_lblockdriver_msg.count = nr_req; + m.m_lbdev_lblockdriver_msg.grant = grant; + m.m_lbdev_lblockdriver_msg.id = lrand48(); r = sendrec_driver(&m, exp, res); @@ -428,11 +428,11 @@ static void bad_read1(void) */ memset(&mt, 0, sizeof(mt)); mt.m_type = BDEV_GATHER; - mt.BDEV_MINOR = driver_minor; - mt.BDEV_POS = 0LL; - mt.BDEV_COUNT = 1; - mt.BDEV_GRANT = grant; - mt.BDEV_ID = lrand48(); + mt.m_lbdev_lblockdriver_msg.minor = driver_minor; + mt.m_lbdev_lblockdriver_msg.pos = 0LL; + mt.m_lbdev_lblockdriver_msg.count = 1; + mt.m_lbdev_lblockdriver_msg.grant = grant; + mt.m_lbdev_lblockdriver_msg.id = lrand48(); memset(&iovt, 0, sizeof(iovt)); iovt.iov_grant = grant2; @@ -456,7 +456,7 @@ static void bad_read1(void) m = mt; iov = iovt; - m.BDEV_COUNT = 0; + m.m_lbdev_lblockdriver_msg.count = 0; sendrec_driver(&m, EINVAL, &res); @@ -465,7 +465,7 @@ static void bad_read1(void) /* Test bad iovec grant. */ m = mt; - m.BDEV_GRANT = GRANT_INVALID; + m.m_lbdev_lblockdriver_msg.grant = GRANT_INVALID; sendrec_driver(&m, EINVAL, &res); @@ -481,7 +481,7 @@ static void bad_read1(void) cpf_revoke(grant3); - m.BDEV_GRANT = grant3; + m.m_lbdev_lblockdriver_msg.grant = grant3; sendrec_driver(&m, EINVAL, &res); @@ -1108,9 +1108,9 @@ static void open_device(dev_t minor) memset(&m, 0, sizeof(m)); m.m_type = BDEV_OPEN; - m.BDEV_MINOR = minor; - m.BDEV_ACCESS = may_write ? (BDEV_R_BIT | BDEV_W_BIT) : BDEV_R_BIT; - m.BDEV_ID = lrand48(); + m.m_lbdev_lblockdriver_msg.minor = minor; + m.m_lbdev_lblockdriver_msg.access = may_write ? (BDEV_R_BIT | BDEV_W_BIT) : BDEV_R_BIT; + m.m_lbdev_lblockdriver_msg.id = lrand48(); sendrec_driver(&m, OK, &res); @@ -1135,8 +1135,8 @@ static void close_device(dev_t minor) memset(&m, 0, sizeof(m)); m.m_type = BDEV_CLOSE; - m.BDEV_MINOR = minor; - m.BDEV_ID = lrand48(); + m.m_lbdev_lblockdriver_msg.minor = minor; + m.m_lbdev_lblockdriver_msg.id = lrand48(); sendrec_driver(&m, OK, &res); @@ -1173,11 +1173,11 @@ static int vir_ioctl(dev_t minor, int req, void *ptr, ssize_t exp, memset(&m, 0, sizeof(m)); m.m_type = BDEV_IOCTL; - m.BDEV_MINOR = minor; - m.BDEV_REQUEST = req; - m.BDEV_GRANT = grant; - m.BDEV_USER = NONE; - m.BDEV_ID = lrand48(); + m.m_lbdev_lblockdriver_msg.minor = minor; + m.m_lbdev_lblockdriver_msg.request = req; + m.m_lbdev_lblockdriver_msg.grant = grant; + m.m_lbdev_lblockdriver_msg.user = NONE; + m.m_lbdev_lblockdriver_msg.id = lrand48(); r = sendrec_driver(&m, exp, res); -- 2.44.0