root/kernel/blk_drv/scsi/sd_ioctl.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. sd_ioctl

   1 #include <linux/kernel.h>
   2 #include <linux/sched.h>
   3 #include <linux/fs.h>
   4 #include <linux/hdreg.h>
   5 #include <linux/errno.h>
   6 
   7 #include <asm/segment.h>
   8 
   9 #include "../blk.h"
  10 #include "scsi.h"
  11 #include "scsi_ioctl.h"
  12 #include "hosts.h"
  13 #include "sd.h"
  14 
  15 extern int revalidate_scsidisk(int, int);
  16 
  17 int sd_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg)
     /* [previous][next][first][last][top][bottom][index][help] */
  18 {
  19         int dev = inode->i_rdev;
  20         int host, error;
  21         int diskinfo[4];
  22         struct hd_geometry *loc = (struct hd_geometry *) arg;
  23 
  24         switch (cmd) {
  25                 case HDIO_REQ:   /* Return BIOS disk parameters */
  26                         if (!loc)  return -EINVAL;
  27                         error = verify_area(VERIFY_WRITE, loc, sizeof(*loc));
  28                         if (error)
  29                                 return error;
  30                         host = rscsi_disks[MINOR(dev) >> 4].device->host_no;
  31                         diskinfo[0] = 0;
  32                         diskinfo[1] = 0;
  33                         diskinfo[2] = 0;
  34                         if(scsi_hosts[host].bios_param != NULL)
  35                               scsi_hosts[host].bios_param(rscsi_disks[MINOR(dev) >> 4].capacity,
  36                                                           dev,
  37                                                           &diskinfo[0]);
  38                         put_fs_byte(diskinfo[0],
  39                                 (char *) &loc->heads);
  40                         put_fs_byte(diskinfo[1],
  41                                 (char *) &loc->sectors);
  42                         put_fs_word(diskinfo[2],
  43                                 (short *) &loc->cylinders);
  44                         put_fs_long(sd[MINOR(inode->i_rdev)].start_sect,
  45                                 (long *) &loc->start);
  46                         return 0;
  47                 case BLKGETSIZE:   /* Return device size */
  48                         if (!arg)  return -EINVAL;
  49                         error = verify_area(VERIFY_WRITE, (long *) arg, sizeof(long));
  50                         if (error)
  51                                 return error;
  52                         put_fs_long(sd[MINOR(inode->i_rdev)].nr_sects,
  53                                 (long *) arg);
  54                         return 0;
  55                 case BLKFLSBUF:
  56                         if(!suser())  return -EACCES;
  57                         if(!inode->i_rdev) return -EINVAL;
  58                         sync_dev(inode->i_rdev);
  59                         invalidate_buffers(inode->i_rdev);
  60                         return 0;
  61 
  62                 case BLKRRPART: /* Re-read partition tables */
  63                         return revalidate_scsidisk(dev, 1);
  64                 default:
  65                         return scsi_ioctl(rscsi_disks[MINOR(dev) >> 4].device , cmd, (void *) arg);
  66         }
  67 }

/* [previous][next][first][last][top][bottom][index][help] */