This source file includes following definitions.
- sd_ioctl
1
2
3
4
5
6
7 #include <linux/config.h>
8 #include <linux/kernel.h>
9 #include <linux/sched.h>
10 #include <linux/mm.h>
11 #include <linux/fs.h>
12 #include <linux/hdreg.h>
13 #include <linux/errno.h>
14
15 #include <asm/segment.h>
16
17 #include <linux/blk.h>
18 #include "scsi.h"
19 #include "scsi_ioctl.h"
20 #include "hosts.h"
21 #include "sd.h"
22
23 int sd_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg)
24 {
25 kdev_t dev = inode->i_rdev;
26 int error;
27 struct Scsi_Host * host;
28 int diskinfo[4];
29 struct hd_geometry *loc = (struct hd_geometry *) arg;
30
31 switch (cmd) {
32 case HDIO_GETGEO:
33 if (!loc) return -EINVAL;
34 error = verify_area(VERIFY_WRITE, loc, sizeof(*loc));
35 if (error)
36 return error;
37 host = rscsi_disks[MINOR(dev) >> 4].device->host;
38
39
40
41 diskinfo[0] = 0x40;
42 diskinfo[1] = 0x20;
43 diskinfo[2] = rscsi_disks[MINOR(dev) >> 4].capacity >> 11;
44
45
46
47 #ifdef CONFIG_SCSI_AUTO_BIOSP
48 scsicam_bios_param(&rscsi_disks[MINOR(dev) >> 4],
49 dev, &diskinfo[0]);
50 #else
51 if(host->hostt->bios_param != NULL)
52 host->hostt->bios_param(&rscsi_disks[MINOR(dev) >> 4],
53 dev,
54 &diskinfo[0]);
55 #endif
56
57 put_user(diskinfo[0], &loc->heads);
58 put_user(diskinfo[1], &loc->sectors);
59 put_user(diskinfo[2], &loc->cylinders);
60 put_user(sd[MINOR(inode->i_rdev)].start_sect, &loc->start);
61 return 0;
62 case BLKGETSIZE:
63 if (!arg) return -EINVAL;
64 error = verify_area(VERIFY_WRITE, (long *) arg, sizeof(long));
65 if (error)
66 return error;
67 put_user(sd[MINOR(inode->i_rdev)].nr_sects,
68 (long *) arg);
69 return 0;
70
71 case BLKRASET:
72 if (!suser())
73 return -EACCES;
74 if(!(inode->i_rdev)) return -EINVAL;
75 if(arg > 0xff) return -EINVAL;
76 read_ahead[MAJOR(inode->i_rdev)] = arg;
77 return 0;
78
79 case BLKRAGET:
80 if (!arg)
81 return -EINVAL;
82 error = verify_area(VERIFY_WRITE, (int *) arg, sizeof(int));
83 if (error)
84 return error;
85 put_user(read_ahead[MAJOR(inode->i_rdev)], (int *) arg);
86 return 0;
87
88 case BLKFLSBUF:
89 if(!suser()) return -EACCES;
90 if(!(inode->i_rdev)) return -EINVAL;
91 fsync_dev(inode->i_rdev);
92 invalidate_buffers(inode->i_rdev);
93 return 0;
94
95 case BLKRRPART:
96 return revalidate_scsidisk(dev, 1);
97 default:
98 return scsi_ioctl(rscsi_disks[MINOR(dev) >> 4].device , cmd, (void *) arg);
99 }
100 }
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119