[ Pobierz całość w formacie PDF ]
.If that is* what's happening here, we'll find out and correct* it later when "identifying" the drive.*/hd[i<<6].nr_sects = bios_info[i].head *bios_info[i].sect * bios_info[i].cyl;hd_ident_info[i] = (struct hd_driveid *) kmalloc(512,GFP_KERNEL);special_op[i] = 1;}if (NR_HD) {if (request_irq(HD_IRQ, hd_interrupt, SA_INTERRUPT, "hd")) {printk("hd: unable to get IRQ%d for the harddisk driver\n",HD_IRQ);NR_HD = 0;} else {request_region(HD_DATA, 8, "hd");request_region(HD_CMD, 1, "hd(cmd)");}}hd_gendisk.nr_real = NR_HD;for(i=0;i<(MAX_HD << 6);i++) hd_blocksizes[i] = 1024;blksize_size[MAJOR_NR] = hd_blocksizes;}static struct file_operations hd_fops = {NULL, /* lseek - default */block_read, /* read - general block-dev read */block_write, /* write - general block-dev write */NULL, /* readdir - bad */NULL, /* select */hd_ioctl, /* ioctl */NULL, /* mmap */hd_open, /* open */hd_release, /* release */block_fsync /* fsync */};unsigned long hd_init(unsigned long mem_start, unsigned long mem_end){if (register_blkdev(MAJOR_NR,"hd",&hd_fops)) {printk("hd: unable to get major %d for harddisk\n",MAJOR_NR);return mem_start;}blk_dev[MAJOR_NR].request_fn = DEVICE_REQUEST;read_ahead[MAJOR_NR] = 8; /* 8 sector (4kB) read-ahead */hd_gendisk.next = gendisk_head;gendisk_head = &hd_gendisk;timer_table[HD_TIMER].fn = hd_times_out;return mem_start;}#define DEVICE_BUSY busy[target]#define USAGE access_count[target]#define CAPACITY (bios_info[target].head*bios_info[target].sect*bios_info[target].cyl)/* We assume that the the bios parameters do not change, so the disk capacitywill not change */#undef MAYBE_REINIT#define GENDISK_STRUCT hd_gendisk/** This routine is called to flush all partitions and partition tables* for a changed scsi disk, and then re-read the new partition table.* If we are revalidating a disk because of a media change, then we* enter with usage == 0.If we are using an ioctl, we automatically have* usage == 1 (we need an open channel to use an ioctl :-), so this* is our limit.*/static int revalidate_hddisk(int dev, int maxusage){int target, major;struct gendisk * gdev;int max_p;int start;int i;long flags;target = DEVICE_NR(dev);gdev = &GENDISK_STRUCT;save_flags(flags);cli();if (DEVICE_BUSY || USAGE > maxusage) {restore_flags(flags);return -EBUSY;};DEVICE_BUSY = 1;restore_flags(flags);max_p = gdev->max_p;start = target << gdev->minor_shift;major = MAJOR_NR << 8;for (i=max_p - 1; i >=0 ; i--) {sync_dev(major | start | i);invalidate_inodes(major | start | i);invalidate_buffers(major | start | i);gdev->part[start+i].start_sect = 0;gdev->part[start+i].nr_sects = 0;};#ifdef MAYBE_REINITMAYBE_REINIT;#endifgdev->part[start].nr_sects = CAPACITY;resetup_one_dev(gdev, target);DEVICE_BUSY = 0;wake_up(&busy_wait);return 0;}
[ Pobierz całość w formacie PDF ]