From: David van Moolenbroek Date: Fri, 26 Jul 2013 22:49:49 +0000 (+0200) Subject: Block protocol: use own [RW]_BIT definitions X-Git-Tag: v3.3.0~593 X-Git-Url: http://zhaoyanbai.com/repos/COPYRIGHT?a=commitdiff_plain;h=refs%2Fchanges%2F64%2F964%2F2;p=minix.git Block protocol: use own [RW]_BIT definitions The original R_BIT and W_BIT definitions have nothing to do with the way these bits are used. Their distinct usage is more apparent when they have different names. Change-Id: Ia984457f900078b2e3502ceed565fead4e5bb965 --- diff --git a/drivers/ahci/ahci.c b/drivers/ahci/ahci.c index 81dd59e3e..a695702ee 100644 --- a/drivers/ahci/ahci.c +++ b/drivers/ahci/ahci.c @@ -2497,7 +2497,7 @@ static int ahci_open(devminor_t minor, int access) return ENXIO; /* Some devices may only be opened in read-only mode. */ - if ((ps->flags & FLAG_READONLY) && (access & W_BIT)) + if ((ps->flags & FLAG_READONLY) && (access & BDEV_W_BIT)) return EACCES; if (ps->open_count == 0) { diff --git a/drivers/at_wini/at_wini.c b/drivers/at_wini/at_wini.c index 23b822723..dc87257cb 100644 --- a/drivers/at_wini/at_wini.c +++ b/drivers/at_wini/at_wini.c @@ -622,7 +622,7 @@ static int w_do_open(devminor_t minor, int access) } #if ENABLE_ATAPI - if ((wn->state & ATAPI) && (access & W_BIT)) + if ((wn->state & ATAPI) && (access & BDEV_W_BIT)) return(EACCES); #endif diff --git a/drivers/fb/fb_edid.c b/drivers/fb/fb_edid.c index 116b64434..f2a16c4f6 100644 --- a/drivers/fb/fb_edid.c +++ b/drivers/fb/fb_edid.c @@ -92,7 +92,7 @@ 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 = R_BIT; + m.BDEV_ACCESS = BDEV_R_BIT; m.BDEV_ID = 0; m.BDEV_MINOR = 0; diff --git a/drivers/filter/driver.c b/drivers/filter/driver.c index d0a959078..131ccbd78 100644 --- a/drivers/filter/driver.c +++ b/drivers/filter/driver.c @@ -31,7 +31,7 @@ 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 = R_BIT | W_BIT; + msg.BDEV_ACCESS = BDEV_R_BIT | BDEV_W_BIT; msg.BDEV_ID = 0; r = sendrec(driver[which].endpt, &msg); diff --git a/drivers/virtio_blk/virtio_blk.c b/drivers/virtio_blk/virtio_blk.c index 652f8691c..cef52ee46 100644 --- a/drivers/virtio_blk/virtio_blk.c +++ b/drivers/virtio_blk/virtio_blk.c @@ -124,7 +124,8 @@ virtio_blk_open(devminor_t minor, int access) return ENXIO; /* Read only devices should only be mounted... read-only */ - if ((access & W_BIT) && virtio_host_supports(blk_dev, VIRTIO_BLK_F_RO)) + if ((access & BDEV_W_BIT) && + virtio_host_supports(blk_dev, VIRTIO_BLK_F_RO)) return EACCES; /* Partition magic when opened the first time or re-opened after diff --git a/include/minix/com.h b/include/minix/com.h index a2b805380..520836722 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -1329,6 +1329,10 @@ #define BDEV_POS_LO m10_l2 /* transfer position (low bits) */ #define BDEV_POS_HI m10_l3 /* transfer position (high bits) */ +/* 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 */ + /* Bits in 'BDEV_FLAGS' field of block device transfer requests. */ # define BDEV_NOFLAGS 0x00 /* no flags are set */ # define BDEV_FORCEWRITE 0x01 /* force write to disk immediately */ diff --git a/servers/ext2/mount.c b/servers/ext2/mount.c index d72f8ef79..f97edc062 100644 --- a/servers/ext2/mount.c +++ b/servers/ext2/mount.c @@ -54,7 +54,8 @@ int fs_readsuper() bdev_driver(fs_dev, fs_dev_label); /* Open the device the file system lives on. */ - if (bdev_open(fs_dev, readonly ? R_BIT : (R_BIT|W_BIT)) != OK) { + if (bdev_open(fs_dev, readonly ? BDEV_R_BIT : (BDEV_R_BIT|BDEV_W_BIT)) != + OK) { return(EINVAL); } diff --git a/servers/iso9660fs/mount.c b/servers/iso9660fs/mount.c index fa7e4b9d5..443b71dac 100644 --- a/servers/iso9660fs/mount.c +++ b/servers/iso9660fs/mount.c @@ -32,7 +32,7 @@ int fs_readsuper() { bdev_driver(fs_dev, fs_dev_label); /* Open the device the file system lives on in read only mode */ - if (bdev_open(fs_dev, R_BIT) != OK) { + if (bdev_open(fs_dev, BDEV_R_BIT) != OK) { return(EINVAL); } diff --git a/servers/mfs/mount.c b/servers/mfs/mount.c index 00fedeba7..60a6b50f7 100644 --- a/servers/mfs/mount.c +++ b/servers/mfs/mount.c @@ -44,7 +44,8 @@ int fs_readsuper() bdev_driver(fs_dev, fs_dev_label); /* Open the device the file system lives on. */ - if (bdev_open(fs_dev, readonly ? R_BIT : (R_BIT|W_BIT) ) != OK) { + if (bdev_open(fs_dev, readonly ? BDEV_R_BIT : (BDEV_R_BIT|BDEV_W_BIT) ) != + OK) { return(EINVAL); } @@ -71,7 +72,7 @@ int fs_readsuper() panic("couldn't bdev_close after found unclean FS"); readonly = 1; - if (bdev_open(fs_dev, R_BIT) != OK) { + if (bdev_open(fs_dev, BDEV_R_BIT) != OK) { panic("couldn't bdev_open after found unclean FS"); return(EINVAL); } diff --git a/servers/vfs/device.c b/servers/vfs/device.c index 2eff10979..7e7111c36 100644 --- a/servers/vfs/device.c +++ b/servers/vfs/device.c @@ -386,7 +386,9 @@ int gen_opcl( memset(&dev_mess, 0, sizeof(dev_mess)); dev_mess.m_type = op; dev_mess.BDEV_MINOR = minor_dev; - dev_mess.BDEV_ACCESS = flags; + dev_mess.BDEV_ACCESS = 0; + if (flags & R_BIT) dev_mess.BDEV_ACCESS |= BDEV_R_BIT; + if (flags & W_BIT) dev_mess.BDEV_ACCESS |= BDEV_W_BIT; dev_mess.BDEV_ID = 0; /* Call the task. */ diff --git a/test/blocktest/blocktest.c b/test/blocktest/blocktest.c index e512d93e9..ee0f149e7 100644 --- a/test/blocktest/blocktest.c +++ b/test/blocktest/blocktest.c @@ -169,7 +169,7 @@ 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) ? (R_BIT | W_BIT) : R_BIT; + m.BDEV_ACCESS = (may_write) ? (BDEV_R_BIT | BDEV_W_BIT) : BDEV_R_BIT; m.BDEV_ID = 0; (void) sendrec(driver_endpt, &m); @@ -1025,7 +1025,7 @@ 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 ? (R_BIT | W_BIT) : R_BIT; + m.BDEV_ACCESS = may_write ? (BDEV_R_BIT | BDEV_W_BIT) : BDEV_R_BIT; m.BDEV_ID = lrand48(); sendrec_driver(&m, OK, &res);