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) {
}
#if ENABLE_ATAPI
- if ((wn->state & ATAPI) && (access & W_BIT))
+ if ((wn->state & ATAPI) && (access & BDEV_W_BIT))
return(EACCES);
#endif
/* 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;
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);
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
#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 */
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);
}
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);
}
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);
}
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);
}
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. */
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);
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);