clinux-kernelttyioctl

Was there a previous version of tty_ldisc_ops.ioctl() that also required a file argument?


I am porting some code that defined tty_ldisc_ops.ioctl() as:

static int ...ldisc_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)

But the current spec is:

static int ...ldisc_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)

What happened to the "file" argument? I looked for change logs and source.


I grabbed a random older kernel from (https://mirrors.edge.kernel.org/pub/linux/kernel/v2.1/).

int n_tty_ioctl(struct tty_struct * tty, struct file * file,
                       unsigned int cmd, unsigned long arg) { ... tty->driver.ioctl(tty, file, cmd, arg); ...

tty.h, struct tty_struct { ... struct tty_driver driver; ...

tty_driver.h: struct tty_driver { ... int  (*ioctl)(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg); ...

Then the trail goes cold.


Solution

  • By browsing through the Git history of the Linux kernel project, you may find that v5.17 is the first one with the file being removed. This commit made that happened. According to it you need to look for the previous patches, one of which seems explaining why that has been done:

    The only user of 'file' parameter in tty_mode_ioctl is a BUG_ON check. Provided it never crashed for anyone, it's an overkill to pass the parameter to tty_mode_ioctl only for this check.

    So, in other words it was never used for anything related to the TTY layer and hence had been removed.