diff --git a/src/kern/freebsd/freebsd.hh b/src/kern/freebsd/freebsd.hh index 232d707143..abbf32bdce 100644 --- a/src/kern/freebsd/freebsd.hh +++ b/src/kern/freebsd/freebsd.hh @@ -1,4 +1,16 @@ /* + * Copyright (c) 2021 Arm Limited + * All rights reserved + * + * The license below extends only to copyright in the software and shall + * not be construed as granting a license to any other intellectual + * property including but not limited to intellectual property relating + * to a hardware implementation of the functionality of the software + * licensed hereunder. You may use the software subject to the license + * terms below provided that you ensure that this notice is replicated + * unmodified and in its entirety in all distributions of the software, + * modified or unmodified, in source code or in binary form. + * * Copyright (c) 2015 Ruslan Bukin * All rights reserved. * @@ -116,7 +128,8 @@ class FreeBSD : public OperatingSystem static const int TGT_RUSAGE_THREAD = 1; // for *at syscalls - static const int TGT_AT_FDCWD = -100; + static const int TGT_AT_FDCWD = -100; + static const int TGT_AT_REMOVEDIR = 0x800; }; // class FreeBSD diff --git a/src/kern/linux/linux.hh b/src/kern/linux/linux.hh index 6232f619cc..19fb9b2d0f 100644 --- a/src/kern/linux/linux.hh +++ b/src/kern/linux/linux.hh @@ -1,4 +1,16 @@ /* + * Copyright (c) 2021 Arm Limited + * All rights reserved + * + * The license below extends only to copyright in the software and shall + * not be construed as granting a license to any other intellectual + * property including but not limited to intellectual property relating + * to a hardware implementation of the functionality of the software + * licensed hereunder. You may use the software subject to the license + * terms below provided that you ensure that this notice is replicated + * unmodified and in its entirety in all distributions of the software, + * modified or unmodified, in source code or in binary form. + * * Copyright (c) 2004-2009 The Regents of The University of Michigan * All rights reserved. * @@ -283,7 +295,8 @@ class Linux : public OperatingSystem static const unsigned TGT_FUTEX_OP_CMP_GE = 5; // for *at syscalls - static const int TGT_AT_FDCWD = -100; + static const int TGT_AT_FDCWD = -100; + static const int TGT_AT_REMOVEDIR = 0x200; // for MREMAP static const unsigned TGT_MREMAP_MAYMOVE = 0x1; diff --git a/src/kern/solaris/solaris.hh b/src/kern/solaris/solaris.hh index 0e6b72aed4..9b58813d4f 100644 --- a/src/kern/solaris/solaris.hh +++ b/src/kern/solaris/solaris.hh @@ -1,4 +1,16 @@ /* + * Copyright (c) 2021 Arm Limited + * All rights reserved + * + * The license below extends only to copyright in the software and shall + * not be construed as granting a license to any other intellectual + * property including but not limited to intellectual property relating + * to a hardware implementation of the functionality of the software + * licensed hereunder. You may use the software subject to the license + * terms below provided that you ensure that this notice is replicated + * unmodified and in its entirety in all distributions of the software, + * modified or unmodified, in source code or in binary form. + * * Copyright (c) 2004-2005 The Regents of The University of Michigan * All rights reserved. * @@ -120,7 +132,8 @@ class Solaris : public OperatingSystem }; // for *at syscalls - static const int TGT_AT_FDCWD = -100; + static const int TGT_AT_FDCWD = -100; + static const int TGT_AT_REMOVEDIR = 0x800; }; // class Solaris diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index 77cdf582c6..0f9b7b0bab 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -911,7 +911,8 @@ openFunc(SyscallDesc *desc, ThreadContext *tc, /// Target unlinkat() handler. template SyscallReturn -unlinkatFunc(SyscallDesc *desc, ThreadContext *tc, int dirfd, VPtr<> pathname) +unlinkatFunc(SyscallDesc *desc, ThreadContext *tc, + int dirfd, VPtr<> pathname, int flags) { std::string path; if (!SETranslatingPortProxy(tc).tryReadString(path, pathname)) @@ -922,7 +923,11 @@ unlinkatFunc(SyscallDesc *desc, ThreadContext *tc, int dirfd, VPtr<> pathname) return res; } - return unlinkImpl(desc, tc, path); + if (flags & OS::TGT_AT_REMOVEDIR) { + return rmdirImpl(desc, tc, path); + } else { + return unlinkImpl(desc, tc, path); + } } /// Target facessat() handler