[Toybox] Does anybody want to create a new "man 2 ioctl_list"?

Rob Landley rob at landley.net
Sat Sep 25 19:12:34 PDT 2021


Michael Kerrisk deleted the old ioctl_list man page last year because nobody was
maintaining it:

https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/man2?id=3de87d46840d

But it's not actually that _hard_, just time consuming. There are about 3500
interesting ioctl macro definitions in the current kernel source:

  $ egrep --include '*.[ch]' -r '[^A-Z]_IO(|C|W|R|WR)[(]' * | \
    grep -v 'drivers/staging' | grep -v 'tools/' | wc -l
  3533

Each of which boils down to some entry point handling it and handing it off to a
function that does a thing. Random example, the symbol SPI_IOC_RD_MODE from the
above list (without the wc -l) greps to drivers/spi/spidev.c in function
spidev_ioctl which winds up being:

        case SPI_IOC_RD_MODE:
                retval = put_user(spi->mode & SPI_MODE_MASK,
                                        (__u8 __user *)arg);

which is struct spi_device *spi; which is defined in include/linux/spi/spi.h
(Trick: grep spi_device include/ -r | grep '{' ) and then there's a comment
block before the header which has:

 * @mode: The spi mode defines how data is clocked out and in.
 *      This may be changed by the device's driver.
 *      The "active low" default for chipselect mode can be overridden
 *      (by specifying SPI_CS_HIGH) as can the "MSB first" default for
 *      each word in a transfer (by specifying SPI_LSB_FIRST).

So that ioctl reads that info into the supplied field.

It would be really nice if there was an automated way to do this, but so far...

Rob



More information about the Toybox mailing list