root/drivers/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 "../block/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 error;
  21         struct Scsi_Host * host;
  22         int diskinfo[4];
  23         struct hd_geometry *loc = (struct hd_geometry *) arg;
  24 
  25         switch (cmd) {
  26                 case HDIO_REQ:   /* Return BIOS disk parameters */
  27                         if (!loc)  return -EINVAL;
  28                         error = verify_area(VERIFY_WRITE, loc, sizeof(*loc));
  29                         if (error)
  30                                 return error;
  31                         host = rscsi_disks[MINOR(dev) >> 4].device->host;
  32                         diskinfo[0] = 0;
  33                         diskinfo[1] = 0;
  34                         diskinfo[2] = 0;
  35                         if(host->hostt->bios_param != NULL)
  36                               host->hostt->bios_param(rscsi_disks[MINOR(dev) >> 4].capacity,
  37                                                           dev,
  38                                                           &diskinfo[0]);
  39                         put_fs_byte(diskinfo[0],
  40                                 (char *) &loc->heads);
  41                         put_fs_byte(diskinfo[1],
  42                                 (char *) &loc->sectors);
  43                         put_fs_word(diskinfo[2],
  44                                 (short *) &loc->cylinders);
  45                         put_fs_long(sd[MINOR(inode->i_rdev)].start_sect,
  46                                 (long *) &loc->start);
  47                         return 0;
  48                 case BLKGETSIZE:   /* Return device size */
  49                         if (!arg)  return -EINVAL;
  50                         error = verify_area(VERIFY_WRITE, (long *) arg, sizeof(long));
  51                         if (error)
  52                                 return error;
  53                         put_fs_long(sd[MINOR(inode->i_rdev)].nr_sects,
  54                                 (long *) arg);
  55                         return 0;
  56                 case BLKRASET:
  57                         if(!suser())  return -EACCES;
  58                         if(!inode->i_rdev) return -EINVAL;
  59                         if(arg > 0xff) return -EINVAL;
  60                         read_ahead[MAJOR(inode->i_rdev)] = arg;
  61                         return 0;
  62                 case BLKFLSBUF:
  63                         if(!suser())  return -EACCES;
  64                         if(!inode->i_rdev) return -EINVAL;
  65                         fsync_dev(inode->i_rdev);
  66                         invalidate_buffers(inode->i_rdev);
  67                         return 0;
  68 
  69                 case BLKRRPART: /* Re-read partition tables */
  70                         return revalidate_scsidisk(dev, 1);
  71                 default:
  72                         return scsi_ioctl(rscsi_disks[MINOR(dev) >> 4].device , cmd, (void *) arg);
  73         }
  74 }

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