From f59a74eb644ad60f419be455498a183bcd1e1f4f Mon Sep 17 00:00:00 2001 From: Iain Macdonald Date: Mon, 10 Jun 2024 15:01:48 -0700 Subject: [PATCH] Add inode.Initialized() for checking if an inode has been initialized or not. --- fs/inode.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/inode.go b/fs/inode.go index c91e029d8..6d6b0e61f 100644 --- a/fs/inode.go +++ b/fs/inode.go @@ -248,6 +248,14 @@ func unlockNodes(ns ...*Inode) { } } +// Initialized returns true if this inode has been initialized and added to the +// filesystem tree. +func (n *Inode) Initialized() bool { + n.mu.Lock() + defer n.mu.Unlock() + return n.changeCounter > 0 +} + // Forgotten returns true if the kernel holds no references to this // inode. This can be used for background cleanup tasks, since the // kernel has no way of reviving forgotten nodes by its own