This source file includes following definitions.
- sd_ioctl
1 #include <linux/kernel.h>
2 #include <linux/sched.h>
3 #include <linux/fs.h>
4 #include <linux/hdreg.h>
5 #include <linux/errno.h>
6
7 #include <asm/segment.h>
8
9 #include "../blk.h"
10 #include "scsi.h"
11 #include "hosts.h"
12 #include "sd.h"
13
14 extern int scsi_ioctl (Scsi_Device *dev, int cmd, void *arg);
15 extern int revalidate_scsidisk(int, int);
16
17 int sd_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg)
18 {
19 int dev = inode->i_rdev;
20 int host, error;
21 int diskinfo[4];
22 struct hd_geometry *loc = (void *) arg;
23
24 switch (cmd) {
25 case HDIO_REQ:
26 if (!loc) return -EINVAL;
27 error = verify_area(VERIFY_WRITE, loc, sizeof(*loc));
28 if (error)
29 return error;
30 host = rscsi_disks[MINOR(dev) >> 4].device->host_no;
31 diskinfo[0] = 0;
32 diskinfo[1] = 0;
33 diskinfo[2] = 0;
34 if(scsi_hosts[host].bios_param != NULL)
35 scsi_hosts[host].bios_param(rscsi_disks[MINOR(dev) >> 4].capacity,
36 dev,
37 &diskinfo[0]);
38 put_fs_byte(diskinfo[0],
39 (char *) &loc->heads);
40 put_fs_byte(diskinfo[1],
41 (char *) &loc->sectors);
42 put_fs_word(diskinfo[2],
43 (short *) &loc->cylinders);
44 put_fs_long(sd[MINOR(inode->i_rdev)].start_sect,
45 (long *) &loc->start);
46 return 0;
47 case BLKGETSIZE:
48 if (!arg) return -EINVAL;
49 error = verify_area(VERIFY_WRITE, (long *) arg, sizeof(long));
50 if (error)
51 return error;
52 put_fs_long(sd[MINOR(inode->i_rdev)].nr_sects,
53 (long *) arg);
54 return 0;
55 case BLKRRPART:
56 return revalidate_scsidisk(dev, 1);
57 default:
58 return scsi_ioctl(rscsi_disks[MINOR(dev) >> 4].device , cmd, (void *) arg);
59 }
60 }