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
22 int sd_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg)
23 {
24 kdev_t dev = inode->i_rdev;
25 int error;
26 struct Scsi_Host * host;
27 int diskinfo[4];
28 struct hd_geometry *loc = (struct hd_geometry *) arg;
29
30 switch (cmd) {
31 case HDIO_GETGEO:
32 if (!loc) return -EINVAL;
33 error = verify_area(VERIFY_WRITE, loc, sizeof(*loc));
34 if (error)
35 return error;
36 host = rscsi_disks[MINOR(dev) >> 4].device->host;
37 diskinfo[0] = 0;
38 diskinfo[1] = 0;
39 diskinfo[2] = 0;
40 if(host->hostt->bios_param != NULL)
41 host->hostt->bios_param(&rscsi_disks[MINOR(dev) >> 4],
42 dev,
43 &diskinfo[0]);
44 put_user(diskinfo[0], &loc->heads);
45 put_user(diskinfo[1], &loc->sectors);
46 put_user(diskinfo[2], &loc->cylinders);
47 put_user(sd[MINOR(inode->i_rdev)].start_sect, &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_user(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
92
93
94