jb2019
jb2019

Reputation: 111

Linux block device IOCTL cmd codes

I am developing a Linux block driver and I am currently testing it. I have an IOCTL function which doesnt do anything at the moment. I just use a printk to print the cmd and arg parameters. When Linux starts up it calls the IOCTL function with a cmd of 5331 and arg of 0. I am trying to find out what this cmd could be. The only thing I can find is a reference to a CDROM capability. Does Linux think my device is a CDROM? If so how can I tell it otherwise? thanks

static int mydrv_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg)

Upvotes: 0

Views: 504

Answers (1)

jb2019
jb2019

Reputation: 111

I found some example code for a ram block device. They implement an ioctl function and check for the 0x5331 code. They just return an error if the flag GENHD_FL_CD is not set.

 case CDROM_GET_CAPABILITY: //0x5331  / * get capabilities * / 
      {
          struct gendisk *disk = bdev->bd_disk;

          if (bdev->bd_disk && (disk->flags & GENHD_FL_CD))
              ret = SUCCESS;
          else
              ret = -EINVAL;
          break;
      }

Upvotes: 0

Related Questions