--- linux-2.4.31-wt1/drivers/block/loop.c.bad 2005-06-02 18:03:19.000000000 +0200 +++ linux-2.4.31-wt1/drivers/block/loop.c 2005-06-02 18:07:18.000000000 +0200 @@ -1417,33 +1417,49 @@ if (!(file->f_mode & FMODE_WRITE)) lo_flags |= LO_FLAGS_READ_ONLY; +#if CONFIG_BLK_DEV_LOOP_KEYSCRUB + lo->lo_keyscrub_fn = 0; +#endif + lo->lo_offset = lo->lo_sizelimit = 0; + lo->lo_offs_sec = lo->lo_iv_remove = 0; + lo->lo_bh_free = lo->lo_bh_que2 = lo->lo_bh_que1 = lo->lo_bh_que0 = NULL; + lo->lo_bh_need = lo->lo_bh_flsh = 0; + init_waitqueue_head(&lo->lo_bh_wait); if (S_ISBLK(inode->i_mode)) { lo_device = inode->i_rdev; if (lo_device == dev) { error = -EBUSY; goto out_putf; } + if (loop_prealloc_init(lo, 0)) { + error = -ENOMEM; + goto out_putf; + } + hardsz = get_hardsect_size(lo_device); } else if (S_ISREG(inode->i_mode)) { - struct address_space_operations *aops = inode->i_mapping->a_ops; /* * If we can't read - sorry. If we only can't write - well, * it's going to be read-only. */ - if (!aops->readpage) + if (!file->f_op || !file->f_op->read) goto out_putf; - if (!aops->prepare_write || !aops->commit_write) + if (!file->f_op->write) lo_flags |= LO_FLAGS_READ_ONLY; lo_device = inode->i_dev; lo_flags |= LO_FLAGS_DO_BMAP; + if (loop_prealloc_init(lo, 1)) { + error = -ENOMEM; + goto out_putf; + } error = 0; } else goto out_putf; get_file(file); - if (IS_RDONLY (inode) || MNT_IS_RDONLY(file->f_vfsmnt) + if ((S_ISREG(inode->i_mode) && IS_RDONLY(inode)) || is_read_only(lo_device) || is_read_only(lo_device) || !(lo_file->f_mode & FMODE_WRITE)) lo_flags |= LO_FLAGS_READ_ONLY;