summaryrefslogtreecommitdiff
path: root/jni/node-inl.h
diff options
context:
space:
mode:
author Alessio Balsini <balsini@google.com> 2022-01-17 15:21:49 +0000
committer Alessio Balsini <balsini@google.com> 2022-01-19 00:07:48 +0000
commit6e7d59404f2fe877623f34027be5c62dc43d7263 (patch)
treeec329f9fc77967546bdbde04474afc70d57f1e25 /jni/node-inl.h
parente899e1f358459d56ae1b691736b5273fe0ffd061 (diff)
pf_move returns EXDEV if node not tracked
This returns EXDEV if we rename, but the second id isn't tracked. This is likely because it was set up via fuse-bpf. Until we have a better tracking method, we can fall back on EXDEV to handle this situation with a copy/delete. Bug: 202785178 Test: CtsAppSecurityHostTestCases Test: mv /sdcard/DCIM/file /storage/emulated/0/Android/data/<pkg>/ Signed-off-by: Daniel Rosenberg <drosen@google.com> Signed-off-by: Alessio Balsini <balsini@google.com> Change-Id: I6e4311a75f641fc019bfad7fa26bd23398cbf252
Diffstat (limited to 'jni/node-inl.h')
-rw-r--r--jni/node-inl.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/jni/node-inl.h b/jni/node-inl.h
index 01d6cbabb..c2bb2607b 100644
--- a/jni/node-inl.h
+++ b/jni/node-inl.h
@@ -90,6 +90,14 @@ class NodeTracker {
public:
explicit NodeTracker(std::recursive_mutex* lock) : lock_(lock) {}
+ bool Exists(__u64 ino) const {
+ if (kEnableInodeTracking) {
+ const node* node = reinterpret_cast<const class node*>(ino);
+ std::lock_guard<std::recursive_mutex> guard(*lock_);
+ return active_nodes_.find(node) != active_nodes_.end();
+ }
+ }
+
void CheckTracked(__u64 ino) const {
if (kEnableInodeTracking) {
const node* node = reinterpret_cast<const class node*>(ino);
@@ -158,6 +166,12 @@ class node {
return reinterpret_cast<node*>(static_cast<uintptr_t>(ino));
}
+ // TODO(b/215235604)
+ static inline node* FromInodeNoThrow(__u64 ino, const NodeTracker* tracker) {
+ if (!tracker->Exists(ino)) return nullptr;
+ return reinterpret_cast<node*>(static_cast<uintptr_t>(ino));
+ }
+
// Maps a node to its associated inode.
static __u64 ToInode(node* node) {
return static_cast<__u64>(reinterpret_cast<uintptr_t>(node));