aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Branco <rbranco@suse.de>2025-12-08 22:30:31 +0000
committerEd Maste <emaste@FreeBSD.org>2025-12-11 17:32:10 +0000
commitfe21dbf70aa8c6dfd2010f30dd2d09f7b743e77d (patch)
treea4a661aa52107cc90486d8d8a35e05b72fbadce6
parentdbac191956f9b51069617b09fd0a24ca0e7bfc12 (diff)
linux: Implement F_DUPFD_QUERY fcntl with kcmp(2) KCMP_FILE
Signed-off-by: Ricardo Branco <rbranco@suse.de> Reviewed by: kib Pull Request: https://github.com/freebsd/freebsd-src/pull/1920
-rw-r--r--sys/compat/linux/linux_file.c8
-rw-r--r--sys/compat/linux/linux_file.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c
index a4be5313aa96..daddafa325ad 100644
--- a/sys/compat/linux/linux_file.c
+++ b/sys/compat/linux/linux_file.c
@@ -1457,6 +1457,14 @@ fcntl_common(struct thread *td, struct linux_fcntl_args *args)
fdrop(fp, td);
return (0);
+ case LINUX_F_DUPFD_QUERY:
+ error = kern_kcmp(td, td->td_proc->p_pid, td->td_proc->p_pid,
+ KCMP_FILE, args->fd, args->arg);
+ if (error != 0)
+ return (error);
+ td->td_retval[0] = (td->td_retval[0] == 0) ? 1 : 0;
+ return (0);
+
default:
linux_msg(td, "unsupported fcntl cmd %d", args->cmd);
return (EINVAL);
diff --git a/sys/compat/linux/linux_file.h b/sys/compat/linux/linux_file.h
index 7448dc597230..0b6ca536be7d 100644
--- a/sys/compat/linux/linux_file.h
+++ b/sys/compat/linux/linux_file.h
@@ -127,6 +127,7 @@
#define LINUX_F_SETLEASE (LINUX_F_SPECIFIC_BASE + 0)
#define LINUX_F_GETLEASE (LINUX_F_SPECIFIC_BASE + 1)
+#define LINUX_F_DUPFD_QUERY (LINUX_F_SPECIFIC_BASE + 3)
#define LINUX_F_CANCELLK (LINUX_F_SPECIFIC_BASE + 5)
#define LINUX_F_DUPFD_CLOEXEC (LINUX_F_SPECIFIC_BASE + 6)
#define LINUX_F_NOTIFY (LINUX_F_SPECIFIC_BASE + 2)