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
This commit is contained in:
David van Moolenbroek 2013-07-27 00:49:49 +02:00 committed by Lionel Sambuc
parent 3fb735cc74
commit 113635b019
11 changed files with 21 additions and 12 deletions

View file

@ -2497,7 +2497,7 @@ static int ahci_open(devminor_t minor, int access)
return ENXIO; return ENXIO;
/* Some devices may only be opened in read-only mode. */ /* 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; return EACCES;
if (ps->open_count == 0) { if (ps->open_count == 0) {

View file

@ -622,7 +622,7 @@ static int w_do_open(devminor_t minor, int access)
} }
#if ENABLE_ATAPI #if ENABLE_ATAPI
if ((wn->state & ATAPI) && (access & W_BIT)) if ((wn->state & ATAPI) && (access & BDEV_W_BIT))
return(EACCES); return(EACCES);
#endif #endif

View file

@ -92,7 +92,7 @@ do_read(endpoint_t driver_endpt, uint8_t *buf, size_t bufsize)
/* Open Device - required for drivers using libblockdriver */ /* Open Device - required for drivers using libblockdriver */
memset(&m, '\0', sizeof(message)); memset(&m, '\0', sizeof(message));
m.m_type = BDEV_OPEN; m.m_type = BDEV_OPEN;
m.BDEV_ACCESS = R_BIT; m.BDEV_ACCESS = BDEV_R_BIT;
m.BDEV_ID = 0; m.BDEV_ID = 0;
m.BDEV_MINOR = 0; m.BDEV_MINOR = 0;

View file

@ -31,7 +31,7 @@ static int driver_open(int which)
memset(&msg, 0, sizeof(msg)); memset(&msg, 0, sizeof(msg));
msg.m_type = BDEV_OPEN; msg.m_type = BDEV_OPEN;
msg.BDEV_MINOR = driver[which].minor; 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; msg.BDEV_ID = 0;
r = sendrec(driver[which].endpt, &msg); r = sendrec(driver[which].endpt, &msg);

View file

@ -124,7 +124,8 @@ virtio_blk_open(devminor_t minor, int access)
return ENXIO; return ENXIO;
/* Read only devices should only be mounted... read-only */ /* 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; return EACCES;
/* Partition magic when opened the first time or re-opened after /* Partition magic when opened the first time or re-opened after

View file

@ -1329,6 +1329,10 @@
#define BDEV_POS_LO m10_l2 /* transfer position (low bits) */ #define BDEV_POS_LO m10_l2 /* transfer position (low bits) */
#define BDEV_POS_HI m10_l3 /* transfer position (high 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. */ /* Bits in 'BDEV_FLAGS' field of block device transfer requests. */
# define BDEV_NOFLAGS 0x00 /* no flags are set */ # define BDEV_NOFLAGS 0x00 /* no flags are set */
# define BDEV_FORCEWRITE 0x01 /* force write to disk immediately */ # define BDEV_FORCEWRITE 0x01 /* force write to disk immediately */

View file

@ -54,7 +54,8 @@ int fs_readsuper()
bdev_driver(fs_dev, fs_dev_label); bdev_driver(fs_dev, fs_dev_label);
/* Open the device the file system lives on. */ /* 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); return(EINVAL);
} }

View file

@ -32,7 +32,7 @@ int fs_readsuper() {
bdev_driver(fs_dev, fs_dev_label); bdev_driver(fs_dev, fs_dev_label);
/* Open the device the file system lives on in read only mode */ /* 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); return(EINVAL);
} }

View file

@ -44,7 +44,8 @@ int fs_readsuper()
bdev_driver(fs_dev, fs_dev_label); bdev_driver(fs_dev, fs_dev_label);
/* Open the device the file system lives on. */ /* 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); return(EINVAL);
} }
@ -71,7 +72,7 @@ int fs_readsuper()
panic("couldn't bdev_close after found unclean FS"); panic("couldn't bdev_close after found unclean FS");
readonly = 1; 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"); panic("couldn't bdev_open after found unclean FS");
return(EINVAL); return(EINVAL);
} }

View file

@ -386,7 +386,9 @@ int gen_opcl(
memset(&dev_mess, 0, sizeof(dev_mess)); memset(&dev_mess, 0, sizeof(dev_mess));
dev_mess.m_type = op; dev_mess.m_type = op;
dev_mess.BDEV_MINOR = minor_dev; 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; dev_mess.BDEV_ID = 0;
/* Call the task. */ /* Call the task. */

View file

@ -169,7 +169,7 @@ static void reopen_device(dev_t minor)
memset(&m, 0, sizeof(m)); memset(&m, 0, sizeof(m));
m.m_type = BDEV_OPEN; m.m_type = BDEV_OPEN;
m.BDEV_MINOR = minor; 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; m.BDEV_ID = 0;
(void) sendrec(driver_endpt, &m); (void) sendrec(driver_endpt, &m);
@ -1025,7 +1025,7 @@ static void open_device(dev_t minor)
memset(&m, 0, sizeof(m)); memset(&m, 0, sizeof(m));
m.m_type = BDEV_OPEN; m.m_type = BDEV_OPEN;
m.BDEV_MINOR = minor; 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(); m.BDEV_ID = lrand48();
sendrec_driver(&m, OK, &res); sendrec_driver(&m, OK, &res);