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