This source file includes following definitions.
- sd_ioctl
1 #ifdef MODULE
2 #include <linux/autoconf.h>
3 #include <linux/module.h>
4 #include <linux/version.h>
5 #endif
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 "../block/blk.h"
17 #include "scsi.h"
18 #include "scsi_ioctl.h"
19 #include "hosts.h"
20 #include "sd.h"
21
22 extern int revalidate_scsidisk(int, int);
23
24 int sd_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg)
25 {
26 int 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_REQ:
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 diskinfo[0] = 0;
40 diskinfo[1] = 0;
41 diskinfo[2] = 0;
42 if(host->hostt->bios_param != NULL)
43 host->hostt->bios_param(&rscsi_disks[MINOR(dev) >> 4],
44 dev,
45 &diskinfo[0]);
46 put_user(diskinfo[0], &loc->heads);
47 put_user(diskinfo[1], &loc->sectors);
48 put_user(diskinfo[2], &loc->cylinders);
49 put_user(sd[MINOR(inode->i_rdev)].start_sect, &loc->start);
50 return 0;
51 case BLKGETSIZE:
52 if (!arg) return -EINVAL;
53 error = verify_area(VERIFY_WRITE, (long *) arg, sizeof(long));
54 if (error)
55 return error;
56 put_user(sd[MINOR(inode->i_rdev)].nr_sects,
57 (long *) arg);
58 return 0;
59 case BLKRASET:
60 if(!suser()) return -EACCES;
61 if(!inode->i_rdev) return -EINVAL;
62 if(arg > 0xff) return -EINVAL;
63 read_ahead[MAJOR(inode->i_rdev)] = arg;
64 return 0;
65 case BLKFLSBUF:
66 if(!suser()) return -EACCES;
67 if(!inode->i_rdev) return -EINVAL;
68 fsync_dev(inode->i_rdev);
69 invalidate_buffers(inode->i_rdev);
70 return 0;
71
72 case BLKRRPART:
73 return revalidate_scsidisk(dev, 1);
74 default:
75 return scsi_ioctl(rscsi_disks[MINOR(dev) >> 4].device , cmd, (void *) arg);
76 }
77 }
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96