> Don't do this hard-coded form of extensiblity. ioctl()s are inherently > extensible because they encode the size. Instead of switching on the > full ioctl, switch on the ioctl number. See for example fs/pidfs: > > /* Extensible IOCTL. */ > if (_IOC_NR(cmd) == _IOC_NR(PIDFD_GET_INFO)) > return pidfd_info(file, cmd, arg); > > static long pidfd_info(struct file *file, unsigned int cmd, unsigned long arg) > { > struct pidfd_info __user *uinfo = (struct pidfd_info __user *)arg; > <snip> > size_t usize = _IOC_SIZE(cmd); > struct pidfd_info kinfo = {}; > > if (!uinfo) > return -EINVAL; > if (usize < PIDFD_INFO_SIZE_VER0) > return -EINVAL; /* First version, no smaller struct possible */ > > pidfs uses a mask field to allow request-response modification: Thanks for the detailed feedback — very helpful. For now, I'll keep it simple and skip adding a mask field since all fields in the struct are always returned. > (Only requirement is that a zero value means "no info", i.e., can't be a > valid value. If you want zero to be a valid value then a mask member > might be helpful where the info that was available is raised.) To clarify on the zero values: the fields in this struct are capability fields, where a zero value indicates that the hardware doesn’t support the corresponding feature. None of the fields have zero as a valid value when the feature is supported, so a mask isn’t necessary. I sent another version [1] with your feedback applied. Please see if it aligns with what you had in mind. [1] https://lore.kernel.org/linux-block/20250618055153.48823-1-anuj20.g@xxxxxxxxxxx/ -- Anuj Gupta