static struct openflags global_openflags = OPEN_FLAGS;
 
 struct cow {
+       /* This is the backing file, actually */
        char *file;
        int fd;
        unsigned long *bitmap;
                }
        }
        dev->count++;
-       if((filp->f_mode & FMODE_WRITE) && !dev->openflags.w){
+       set_disk_ro(disk, !dev->openflags.w);
+
+       /* This should no more be needed. And it didn't work anyway to exclude
+        * read-write remounting of filesystems.*/
+       /*if((filp->f_mode & FMODE_WRITE) && !dev->openflags.w){
                if(--dev->count == 0) ubd_close(dev);
                err = -EROFS;
-       }
+       }*/
  out:
        return(err);
 }
 
        if(req->rq_status == RQ_INACTIVE) return(1);
 
+       /* This should be impossible now */
        if((rq_data_dir(req) == WRITE) && !dev->openflags.w){
                printk("Write attempted on readonly ubd device %s\n", 
                       disk->disk_name);
 
                /* It's a write to a ubd device */
 
+               /* This should be impossible now */
                if(!dev->openflags.w){
                        /* It's a write access on a read-only device - probably
                         * shouldn't happen.  If the kernel is trying to change
                                }
                        } while((n < len) && (n != 0));
                        if (n < len) memset(&buf[n], 0, len - n);
-               }
-               else {
+               } else {
                        n = os_write_file(req->fds[bit], buf, len);
                        if(n != len){
                                printk("do_io - write failed err = %d "