rust: kernel: ioctl returns ENOTTY if not implemented
RFC 1/1 rust: kernel: ioctl returns ENOTTY if not implemented
From: Gioh Kim <[email protected]>
According to fs/ioctl.c, ioctl system call first test the cmd value with do_vfs_ioctl. If the cmd is not supported command, it calls vfs_ioctl. Then vfs_ioctl returns ENOTTY if ioctl is not implemented.
--- rust/kernel/file_operations.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
rust/kernel/file_operations.rs +2 -2
@@ -662,7 +662,7 @@ pub trait FileOperations: Send + Sync + Sized { _file: &File, _cmd: &mut IoctlCommand, ) -> Result<i32> { -Err (Error ::EINVAL ) +Err (Error ::ENOTTY ) }/// Performs 32-bit IO control operations on that are specific to the file on 64-bit kernels.
@@ -673,7 +673,7 @@ pub trait FileOperations: Send + Sync + Sized { _file: &File, _cmd: &mut IoctlCommand, ) -> Result<i32> { -Err (Error ::EINVAL ) +Err (Error ::ENOTTY ) }/// Syncs pending changes to this file.
Signature · 1 line
2.25.1
Quoted 8 lines · Gioh Kim
From: Gioh Kim <[email protected]>
According to
fs/ioctl.c, ioctl system call first test the cmd value withdo_vfs_ioctl. If the cmd is not supported command, it callsvfs_ioctl. Thenvfs_ioctlreturns ENOTTY if ioctl is not implemented.Signed-off-by Gioh Kim <[email protected]>
FWIW:
Quoted 29 lines
--- rust/kernel/file_operations.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)rust/kernel/file_operations.rs +2
-2@@ -662,7 +662,7 @@ pub trait FileOperations: Send + Sync + Sized { _file: &File, _cmd: &mut IoctlCommand, ) -> Result<i32> { -Err (Error ::EINVAL ) +Err (Error ::ENOTTY ) }/// Performs 32-bit IO control operations on that are specific to the file on 64-bit kernels. @@ -673,7 +673,7 @@ pub trait FileOperations: Send + Sync + Sized { _file: &File, _cmd: &mut IoctlCommand, ) -> Result<i32> { -Err (Error ::EINVAL ) +Err (Error ::ENOTTY ) }/// Syncs pending changes to this file. Signature · 1 line
2.25.1
Hi Gioh,
Quoted 9 lines · Gioh Kim
From: Gioh Kim <[email protected]>
According to
fs/ioctl.c, ioctl system call first test the cmd value withdo_vfs_ioctl. If the cmd is not supported command, it callsvfs_ioctl. Thenvfs_ioctlreturns ENOTTY if ioctl is not implemented.Signed-off-by Gioh Kim <[email protected]>
Thanks! Applying it.
(By the way, always try to match the From -- I understand you are sending this as a personal contribution vs. your other commits in the kernel).
Cheers,
Miguel