This source file includes following definitions.
- sd_ioctl
1 #include <linux/kernel.h>
2 #include <linux/sched.h>
3 #include <linux/mm.h>
4 #include <linux/fs.h>
5 #include <linux/hdreg.h>
6 #include <linux/errno.h>
7
8 #include <asm/segment.h>
9
10 #include "../block/blk.h"
11 #include "scsi.h"
12 #include "scsi_ioctl.h"
13 #include "hosts.h"
14 #include "sd.h"
15
16 extern int revalidate_scsidisk(int, int);
17
18 int sd_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg)
19 {
20 int dev = inode->i_rdev;
21 int error;
22 struct Scsi_Host * host;
23 int diskinfo[4];
24 struct hd_geometry *loc = (struct hd_geometry *) arg;
25
26 switch (cmd) {
27 case HDIO_REQ:
28 if (!loc) return -EINVAL;
29 error = verify_area(VERIFY_WRITE, loc, sizeof(*loc));
30 if (error)
31 return error;
32 host = rscsi_disks[MINOR(dev) >> 4].device->host;
33 diskinfo[0] = 0;
34 diskinfo[1] = 0;
35 diskinfo[2] = 0;
36 if(host->hostt->bios_param != NULL)
37 host->hostt->bios_param(&rscsi_disks[MINOR(dev) >> 4],
38 dev,
39 &diskinfo[0]);
40 put_fs_byte(diskinfo[0],
41 (char *) &loc->heads);
42 put_fs_byte(diskinfo[1],
43 (char *) &loc->sectors);
44 put_fs_word(diskinfo[2],
45 (short *) &loc->cylinders);
46 put_fs_long(sd[MINOR(inode->i_rdev)].start_sect,
47 (long *) &loc->start);
48 return 0;
49 case BLKGETSIZE:
50 if (!arg) return -EINVAL;
51 error = verify_area(VERIFY_WRITE, (long *) arg, sizeof(long));
52 if (error)
53 return error;
54 put_fs_long(sd[MINOR(inode->i_rdev)].nr_sects,
55 (long *) arg);
56 return 0;
57 case BLKRASET:
58 if(!suser()) return -EACCES;
59 if(!inode->i_rdev) return -EINVAL;
60 if(arg > 0xff) return -EINVAL;
61 read_ahead[MAJOR(inode->i_rdev)] = arg;
62 return 0;
63 case BLKFLSBUF:
64 if(!suser()) return -EACCES;
65 if(!inode->i_rdev) return -EINVAL;
66 fsync_dev(inode->i_rdev);
67 invalidate_buffers(inode->i_rdev);
68 return 0;
69
70 case BLKRRPART:
71 return revalidate_scsidisk(dev, 1);
72 default:
73 return scsi_ioctl(rscsi_disks[MINOR(dev) >> 4].device , cmd, (void *) arg);
74 }
75 }
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91