Giacomo Travaglini has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/51548 )
Change subject: sim-se, kern: Add flags parameter to unlinkat
......................................................................
sim-se, kern: Add flags parameter to unlinkat
The unlinkat syscall expects a "third" flags parameter [1].
It is using it to implement a sort of rmdirat (in case the parameter
includes the AT_REMOVEDIR flag)
[1]: https://man7.org/linux/man-pages/man2/unlink.2.html
Signed-off-by: Giacomo Travaglini <giacomo.travagl...@arm.com>
Change-Id: I38dd9268ae4de0f289abe779c4da03e969248065
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51548
Reviewed-by: Jason Lowe-Power <power...@gmail.com>
Maintainer: Jason Lowe-Power <power...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/kern/linux/linux.hh
M src/sim/syscall_emul.hh
M src/kern/solaris/solaris.hh
M src/kern/freebsd/freebsd.hh
4 files changed, 70 insertions(+), 5 deletions(-)
Approvals:
Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/kern/freebsd/freebsd.hh b/src/kern/freebsd/freebsd.hh
index 232d707..abbf32b 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 <b...@bsdpad.com>
* All rights reserved.
*
@@ -116,7 +128,8 @@
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 6232f61..19fb9b2 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 @@
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 0e6b72a..9b58813 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 @@
};
// 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 77cdf58..0f9b7b0 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -911,7 +911,8 @@
/// Target unlinkat() handler.
template <class OS>
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 @@
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
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/51548
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I38dd9268ae4de0f289abe779c4da03e969248065
Gerrit-Change-Number: 51548
Gerrit-PatchSet: 2
Gerrit-Owner: Giacomo Travaglini <giacomo.travagl...@arm.com>
Gerrit-Reviewer: Giacomo Travaglini <giacomo.travagl...@arm.com>
Gerrit-Reviewer: Jason Lowe-Power <power...@gmail.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s