 /* set underlying gendisk policy to reflect real ro/rw status */ if (UTESTF(FD_DISK_WRITABLE)) inode->i_bdev->bd_disk->policy = 0; else inode->i_bdev->bd_disk->policy = 1; 
static int floppy_open(struct inode *inode, struct file *filp){	int drive = (long)inode->i_bdev->bd_disk->private_data;	int old_dev;	int try;	int res = -EBUSY;	char *tmp;	filp->private_data = (void *)0;	down(&open_lock);	old_dev = UDRS->fd_device;	if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev)		goto out2;	if (!UDRS->fd_ref && (UDP->flags & FD_BROKEN_DCL)) {		USETF(FD_DISK_CHANGED);		USETF(FD_VERIFY);	}	if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (filp->f_flags & O_EXCL)))		goto out2;	if (floppy_grab_irq_and_dma())		goto out2;	if (filp->f_flags & O_EXCL)		UDRS->fd_ref = -1;	else		UDRS->fd_ref++;	opened_bdev[drive] = inode->i_bdev;	res = -ENXIO;	if (!floppy_track_buffer) {		/* if opening an ED drive, reserve a big buffer,		 * else reserve a small one */		if ((UDP->cmos == 6) || (UDP->cmos == 5))			try = 64;	/* Only 48 actually useful */		else			try = 32;	/* Only 24 actually useful */		tmp = (char *)fd_dma_mem_alloc(1024 * try);		if (!tmp && !floppy_track_buffer) {			try >>= 1;	/* buffer only one side */			INFBOUND(try, 16);			tmp = (char *)fd_dma_mem_alloc(1024 * try);		}		if (!tmp && !floppy_track_buffer) {			fallback_on_nodma_alloc(&tmp, 2048 * try);		}		if (!tmp && !floppy_track_buffer) {			DPRINT("Unable to allocate DMA memory\n");			goto out;		}		if (floppy_track_buffer) {			if (tmp)				fd_dma_mem_free((unsigned long)tmp, try * 1024);		} else {			buffer_min = buffer_max = -1;			floppy_track_buffer = tmp;			max_buffer_sectors = try;		}	}	UDRS->fd_device = iminor(inode);	set_capacity(disks[drive], floppy_sizes[iminor(inode)]);	if (old_dev != -1 && old_dev != iminor(inode)) {		if (buffer_drive == drive)			buffer_track = -1;	}	/* Allow ioctls if we have write-permissions even if read-only open.	 * Needed so that programs such as fdrawcmd still can work on write	 * protected disks */	if (filp->f_mode & 2	    || permission(filp->f_dentry->d_inode, 2, NULL) == 0)		filp->private_data = (void *)8;	if (UFDCS->rawcmd == 1)		UFDCS->rawcmd = 2;	if (!(filp->f_flags & O_NDELAY)) {		if (filp->f_mode & 3) {			UDRS->last_checked = 0;			check_disk_change(inode->i_bdev);			if (UTESTF(FD_DISK_CHANGED))				goto out;		}		res = -EROFS;		if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE)))			goto out;	}	up(&open_lock);	return 0;out:	if (UDRS->fd_ref < 0)		UDRS->fd_ref = 0;	else		UDRS->fd_ref--;	if (!UDRS->fd_ref)		opened_bdev[drive] = NULL;	floppy_release_irq_and_dma();out2:	up(&open_lock);	return res;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/88baf3e85af72f606363a85e9a60e9e61cc64a6c/floppy.c/buggy/drivers/block/floppy.c