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.travaglini@arm.com> Change-Id: I38dd9268ae4de0f289abe779c4da03e969248065 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51548 Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -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 <br@bsdpad.com>
|
||||
* 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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -911,7 +911,8 @@ openFunc(SyscallDesc *desc, ThreadContext *tc,
|
||||
/// 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 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user