This source file includes following definitions.
- sd_ioctl
1
2
3
4
5
6
7 #include <linux/kernel.h>
8 #include <linux/sched.h>
9 #include <linux/mm.h>
10 #include <linux/fs.h>
11 #include <linux/hdreg.h>
12 #include <linux/errno.h>
13
14 #include <asm/segment.h>
15
16 #include <linux/blk.h>
17 #include "scsi.h"
18 #include "scsi_ioctl.h"
19 #include "hosts.h"
20 #include "sd.h"
21 #include <linux/scsicam.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 if(host->hostt->bios_param != NULL)
48 host->hostt->bios_param(&rscsi_disks[MINOR(dev) >> 4],
49 dev,
50 &diskinfo[0]);
51 else scsicam_bios_param(&rscsi_disks[MINOR(dev) >> 4],
52 dev, &diskinfo[0]);
53
54 put_user(diskinfo[0], &loc->heads);
55 put_user(diskinfo[1], &loc->sectors);
56 put_user(diskinfo[2], &loc->cylinders);
57 put_user(sd[MINOR(inode->i_rdev)].start_sect, &loc->start);
58 return 0;
59 case BLKGETSIZE:
60 if (!arg) return -EINVAL;
61 error = verify_area(VERIFY_WRITE, (long *) arg, sizeof(long));
62 if (error)
63 return error;
64 put_user(sd[MINOR(inode->i_rdev)].nr_sects,
65 (long *) arg);
66 return 0;
67
68 case BLKRASET:
69 if (!suser())
70 return -EACCES;
71 if(!(inode->i_rdev)) return -EINVAL;
72 if(arg > 0xff) return -EINVAL;
73 read_ahead[MAJOR(inode->i_rdev)] = arg;
74 return 0;
75
76 case BLKRAGET:
77 if (!arg)
78 return -EINVAL;
79 error = verify_area(VERIFY_WRITE, (int *) arg, sizeof(int));
80 if (error)
81 return error;
82 put_user(read_ahead[MAJOR(inode->i_rdev)], (int *) arg);
83 return 0;
84
85 case BLKFLSBUF:
86 if(!suser()) return -EACCES;
87 if(!(inode->i_rdev)) return -EINVAL;
88 fsync_dev(inode->i_rdev);
89 invalidate_buffers(inode->i_rdev);
90 return 0;
91
92 case BLKRRPART:
93 return revalidate_scsidisk(dev, 1);
94 default:
95 return scsi_ioctl(rscsi_disks[MINOR(dev) >> 4].device , cmd, (void *) arg);
96 }
97 }
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116