title: How does a ioctl() call the driver code
body: <p>I am working on a testing tool for nvme-cli(written in c and can run on linux).</p>
  
  <p>For SSD validation purpose, i was actually looking for a custom command(For e.g. I/O command, write and then read the same and finally compare if both the data are same)</p>
  
  <p>For read the <code>ioctl()</code> function is used as shown in the below code.</p>
  
  <pre><code>struct nvme_user_io io = {
      .opcode     = opcode,
      .flags      = 0,
      .control    = control,
      .nblocks    = nblocks,
      .rsvd       = 0,
      .metadata   = (__u64)(uintptr_t) metadata,
      .addr       = (__u64)(uintptr_t) data,
      .slba       = slba,
      .dsmgmt     = dsmgmt,
      .reftag     = reftag,
      .appmask    = appmask,
      .apptag     = apptag,
  };
  err = ioctl(fd, NVME_IOCTL_SUBMIT_IO, &amp;io);
  </code></pre>
  
  <p>Can I to where exactly the control of execution goes in order to understand the read.</p>
  
  <p>Also I want to have another command that looks like</p>
  
  <p><code>err = ioctl(fd,NVME_IOCTL_WRITE_AND_COMPARE_IO, &amp;io);</code>  </p>
  
  <p>so that I can internally do a write, then read the same location and finally compare the both data to ensure that the disk contains only the data that I wanted to write.</p>
  
  <p>Since I am new to this nvme/ioctl(), if there is any mistakes please correct me.</p>