title: Where are ioctl parameters (such as 0x1268 / BLKSSZGET) actually specified?
body: <p>I am looking for a definitive specification describing the expected arguments and behavior of ioctl 0x1268 (BLKSSZGET).</p>
  
  <p>This number is declared in many places (none of which contain a definitive reference source), such as <code>linux/fs.h</code>, but I can find no specification for it.</p>
  
  <p>Surely, somebody at some point in the past decided that 0x1268 would get the physical sector size of a device and documented that somewhere. Where does this information come from and where can I find it?</p>
  
  <p>Edit: I am not asking what BLKSSZGET does in general, nor am I asking what header it is defined in. I am looking for a definitive, standardized source that states what argument types it should take and what its behavior should be for any driver that implements it.</p>
  
  <p>Specifically, I am asking because there <em>appears</em> to be a bug in <code>blkdiscard</code> in util-linux 2.23 (and 2.24) where the sector size is queried in to a <code>uint64_t</code>, but the high 32-bits are untouched since BLKSSZGET <em>appears</em> to expect a 32-bit integer, and this leads to an incorrect sector size, incorrect alignment calculations, and failures in <code>blkdiscard</code> when it should succeed. So before I submit a patch, I need to determine, with absolute certainty, if the problem is that <code>blkdiscard</code> should be using a 32-bit integer, or if the driver implementation in my kernel should be using a 64-bit integer.</p>
  
  <p>Edit 2: Since we're on the topic, the proposed patch <em>presuming <code>blkdiscard</code> is incorrect</em> is:</p>
  
  <pre><code>--- sys-utils/blkdiscard.c-2.23 2013-11-01 18:28:19.270004947 -0400
  +++ sys-utils/blkdiscard.c  2013-11-01 18:29:07.334002382 -0400
  @@ -71,7 +71,8 @@
   {
      char *path;
      int c, fd, verbose = 0, secure = 0;
  -   uint64_t end, blksize, secsize, range[2];
  +   uint64_t end, blksize, range[2];
  +   uint32_t secsize;
      struct stat sb;
  
      static const struct option longopts[] = {
  @@ -146,8 +147,8 @@
          err(EXIT_FAILURE, _("%s: BLKSSZGET ioctl failed"), path);
  
      /* align range to the sector size */
  -   range[0] = (range[0] + secsize - 1) &amp; ~(secsize - 1);
  -   range[1] &amp;= ~(secsize - 1);
  +   range[0] = (range[0] + (uint64_t)secsize - 1) &amp; ~((uint64_t)secsize - 1);
  +   range[1] &amp;= ~((uint64_t)secsize - 1);
  
      /* is the range end behind the end of the device ?*/
      end = range[0] + range[1];
  </code></pre>
  
  <p>Applied to e.g. <a href="https://www.kernel.org/pub/linux/utils/util-linux/v2.23/" rel="noreferrer">https://www.kernel.org/pub/linux/utils/util-linux/v2.23/</a>.</p>