diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2026-02-26 19:21:08 +0000 |
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2026-03-05 23:46:53 +0000 |
| commit | 8feb8d221cfb842ee11d744d22571baec6c18cd8 (patch) | |
| tree | 76731c3b7967f15ac13d881aae8942fa7a427761 | |
| parent | 7a1217ff3bbdd1ef40d1b94170c53611fadeb026 (diff) | |
linuxolator: translate LINUX_RENAME_NOREPLACE into our AT_RENAME_NOREPLACE
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D55539
| -rw-r--r-- | sys/compat/linux/linux_file.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index 43ccac0308d3..30e79a53ad2a 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -833,23 +833,34 @@ int linux_renameat2(struct thread *td, struct linux_renameat2_args *args) { int olddfd, newdfd; + u_int atflags; - if (args->flags != 0) { - if (args->flags & ~(LINUX_RENAME_EXCHANGE | - LINUX_RENAME_NOREPLACE | LINUX_RENAME_WHITEOUT)) - return (EINVAL); - if (args->flags & LINUX_RENAME_EXCHANGE && - args->flags & (LINUX_RENAME_NOREPLACE | - LINUX_RENAME_WHITEOUT)) + atflags = 0; + if ((args->flags & ~(LINUX_RENAME_EXCHANGE | + LINUX_RENAME_NOREPLACE | LINUX_RENAME_WHITEOUT)) != 0) + return (EINVAL); + if ((args->flags & LINUX_RENAME_EXCHANGE) != 0 && + (args->flags & (LINUX_RENAME_NOREPLACE | + LINUX_RENAME_WHITEOUT)) != 0) + return (EINVAL); + if ((args->flags & LINUX_RENAME_NOREPLACE) != 0) { + if ((args->flags & (LINUX_RENAME_EXCHANGE | + LINUX_RENAME_WHITEOUT)) != 0) return (EINVAL); -#if 0 + args->flags &= ~LINUX_RENAME_NOREPLACE; + atflags |= AT_RENAME_NOREPLACE; + } + + if (args->flags != 0) { /* * This spams the console on Ubuntu Focal. * - * What's needed here is a general mechanism to let users know - * about missing features without hogging the system. + * What's needed here is a general mechanism to let + * users know about missing features without hogging + * the system. */ - linux_msg(td, "renameat2 unsupported flags 0x%x", +#if 0 + linux_msg(td, "renameat2 unsupported flags %#x", args->flags); #endif return (EINVAL); @@ -858,7 +869,7 @@ linux_renameat2(struct thread *td, struct linux_renameat2_args *args) olddfd = (args->olddfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->olddfd; newdfd = (args->newdfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->newdfd; return (kern_renameat(td, olddfd, args->oldname, newdfd, - args->newname, UIO_USERSPACE, 0)); + args->newname, UIO_USERSPACE, atflags)); } #ifdef LINUX_LEGACY_SYSCALLS |
