Index: head/sys/boot/common/md.c =================================================================== --- head/sys/boot/common/md.c +++ head/sys/boot/common/md.c @@ -106,7 +106,7 @@ if (rsize != NULL) *rsize = size; - switch (rw) { + switch (rw & F_MASK) { case F_READ: bcopy(md_image.start + ofs, buf, size); return (0); Index: head/sys/boot/efi/libefi/efipart.c =================================================================== --- head/sys/boot/efi/libefi/efipart.c +++ head/sys/boot/efi/libefi/efipart.c @@ -819,7 +819,7 @@ if ((blk + nblks - 1) > blkio->Media->LastBlock) return (EIO); - switch (rw) { + switch (rw & F_MASK) { case F_READ: status = blkio->ReadBlocks(blkio, blkio->Media->MediaId, blk, nblks * blkio->Media->BlockSize, buf); Index: head/sys/boot/i386/libi386/bioscd.c =================================================================== --- head/sys/boot/i386/libi386/bioscd.c +++ head/sys/boot/i386/libi386/bioscd.c @@ -268,7 +268,7 @@ return (EINVAL); #endif - if (rw != F_READ) + if ((rw & F_MASK) != F_READ) return(EROFS); dev = (struct i386_devdesc *)devdata; unit = dev->d_unit; Index: head/sys/boot/i386/libi386/biosdisk.c =================================================================== --- head/sys/boot/i386/libi386/biosdisk.c +++ head/sys/boot/i386/libi386/biosdisk.c @@ -618,7 +618,7 @@ DEBUG("short read %d", blks); } - switch(rw){ + switch (rw & F_MASK) { case F_READ: DEBUG("read %d from %lld to %p", blks, dblk, buf); Index: head/sys/boot/mips/beri/loader/beri_disk_cfi.c =================================================================== --- head/sys/boot/mips/beri/loader/beri_disk_cfi.c +++ head/sys/boot/mips/beri/loader/beri_disk_cfi.c @@ -73,6 +73,7 @@ { int error; + flag &= F_MASK; if (flag == F_WRITE) return (EROFS); if (flag != F_READ) Index: head/sys/boot/mips/beri/loader/beri_disk_sdcard.c =================================================================== --- head/sys/boot/mips/beri/loader/beri_disk_sdcard.c +++ head/sys/boot/mips/beri/loader/beri_disk_sdcard.c @@ -73,6 +73,7 @@ { int error; + flag &= F_MASK; if (flag == F_WRITE) return (EROFS); if (flag != F_READ) Index: head/sys/boot/powerpc/ps3/ps3cdrom.c =================================================================== --- head/sys/boot/powerpc/ps3/ps3cdrom.c +++ head/sys/boot/powerpc/ps3/ps3cdrom.c @@ -83,6 +83,7 @@ DEBUG("d_unit=%u dblk=%llu size=%u", dev->d_unit, dblk, size); + flag &= F_MASK; if (flag != F_READ) { dev_printf(dev, "write operation is not supported!"); return EROFS; Index: head/sys/boot/powerpc/ps3/ps3disk.c =================================================================== --- head/sys/boot/powerpc/ps3/ps3disk.c +++ head/sys/boot/powerpc/ps3/ps3disk.c @@ -115,6 +115,7 @@ struct open_dev *od = (struct open_dev *) dev->d_disk.data; int err; + flag &= F_MASK; if (flag != F_READ) { dev_printf(dev, "write operation is not supported!\n"); return EROFS; Index: head/sys/boot/uboot/lib/disk.c =================================================================== --- head/sys/boot/uboot/lib/disk.c +++ head/sys/boot/uboot/lib/disk.c @@ -149,6 +149,7 @@ daddr_t bcount; int err; + rw &= F_MASK; if (rw != F_READ) { stor_printf("write attempt, operation not supported!\n"); return (EROFS); Index: head/sys/boot/usb/storage/umass_loader.c =================================================================== --- head/sys/boot/usb/storage/umass_loader.c +++ head/sys/boot/usb/storage/umass_loader.c @@ -92,6 +92,7 @@ if (rsizep != NULL) *rsizep = 0; + flag &= F_MASK; if (flag == F_WRITE) { if (usb_msc_write_10(umass_uaa.device, 0, dblk, size >> 9, buf) != 0) return (EINVAL); Index: head/sys/boot/userboot/userboot/userboot_disk.c =================================================================== --- head/sys/boot/userboot/userboot/userboot_disk.c +++ head/sys/boot/userboot/userboot/userboot_disk.c @@ -211,6 +211,7 @@ size_t resid; int rc; + rw &= F_MASK; if (rw == F_WRITE) return (EROFS); if (rw != F_READ)