Re: [PATCH v9 02/17] fs: add generic FS_IOC_SHUTDOWN definitions

David Timber
2026-02-21T06:17:47Z

> +/*
> + * Shutdown the filesystem.
> + */
> +#define FS_IOC_SHUTDOWN _IOR('X', 125, __u32)
Should've been _IOW, not _IOR. This is rather unfortunate.

Documentation/userspace-api/ioctl/ioctl-number.rst:
>     ====== ===========================
>     macro  parameters
>     ====== ===========================
>     _IO    none
>     _IOW   write (read from userspace)
>     _IOR   read (write to userspace)
>     _IOWR  write and read
>     ====== ===========================
>
> 'Write' and 'read' are from the user's point of view, just like the
> system calls 'write' and 'read'.  For example, a SET_FOO ioctl would
> be _IOW, although the kernel would actually read data from user space;
> a GET_FOO ioctl would be _IOR, although the kernel would actually write
> data to user space.
All the *_ioctl_shutdown() do get_user(..., arg).