summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fsimpl/tmpfs/tmpfs.go
diff options
context:
space:
mode:
authorDean Deng <deandeng@google.com>2020-05-29 12:27:15 -0700
committergVisor bot <gvisor-bot@google.com>2020-05-29 12:28:49 -0700
commitccf69bdd7e05a4e5f404fbef89a7f49f218645e2 (patch)
treea3ceba80d016b650cea25791c5fd9fbe36a702b9 /pkg/sentry/fsimpl/tmpfs/tmpfs.go
parent0baba92ad9fc3c92347cada47364514a85603462 (diff)
Implement IN_EXCL_UNLINK inotify option in vfs2.
Limited to tmpfs. Inotify support in other filesystem implementations to follow. Updates #1479 PiperOrigin-RevId: 313828648
Diffstat (limited to 'pkg/sentry/fsimpl/tmpfs/tmpfs.go')
-rw-r--r--pkg/sentry/fsimpl/tmpfs/tmpfs.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/pkg/sentry/fsimpl/tmpfs/tmpfs.go b/pkg/sentry/fsimpl/tmpfs/tmpfs.go
index 1d83b6840..f0e098702 100644
--- a/pkg/sentry/fsimpl/tmpfs/tmpfs.go
+++ b/pkg/sentry/fsimpl/tmpfs/tmpfs.go
@@ -163,6 +163,11 @@ type dentry struct {
// filesystem.mu.
name string
+ // unlinked indicates whether this dentry has been unlinked from its parent.
+ // It is only set to true on an unlink operation, and never set from true to
+ // false. unlinked is protected by filesystem.mu.
+ unlinked bool
+
// dentryEntry (ugh) links dentries into their parent directory.childList.
dentryEntry
@@ -202,7 +207,7 @@ func (d *dentry) DecRef() {
}
// InotifyWithParent implements vfs.DentryImpl.InotifyWithParent.
-func (d *dentry) InotifyWithParent(events uint32, cookie uint32) {
+func (d *dentry) InotifyWithParent(events uint32, cookie uint32, et vfs.EventType) {
if d.inode.isDir() {
events |= linux.IN_ISDIR
}
@@ -211,9 +216,9 @@ func (d *dentry) InotifyWithParent(events uint32, cookie uint32) {
if d.parent != nil {
// Note that d.parent or d.name may be stale if there is a concurrent
// rename operation. Inotify does not provide consistency guarantees.
- d.parent.inode.watches.Notify(d.name, events, cookie)
+ d.parent.inode.watches.NotifyWithExclusions(d.name, events, cookie, et, d.unlinked)
}
- d.inode.watches.Notify("", events, cookie)
+ d.inode.watches.Notify("", events, cookie, et)
}
// Watches implements vfs.DentryImpl.Watches.
@@ -676,9 +681,8 @@ func (fd *fileDescription) SetStat(ctx context.Context, opts vfs.SetStatOptions)
return err
}
- // Generate inotify events.
if ev := vfs.InotifyEventFromStatMask(opts.Stat.Mask); ev != 0 {
- d.InotifyWithParent(ev, 0)
+ d.InotifyWithParent(ev, 0, vfs.InodeEvent)
}
return nil
}
@@ -701,7 +705,7 @@ func (fd *fileDescription) Setxattr(ctx context.Context, opts vfs.SetxattrOption
}
// Generate inotify events.
- d.InotifyWithParent(linux.IN_ATTRIB, 0)
+ d.InotifyWithParent(linux.IN_ATTRIB, 0, vfs.InodeEvent)
return nil
}
@@ -713,7 +717,7 @@ func (fd *fileDescription) Removexattr(ctx context.Context, name string) error {
}
// Generate inotify events.
- d.InotifyWithParent(linux.IN_ATTRIB, 0)
+ d.InotifyWithParent(linux.IN_ATTRIB, 0, vfs.InodeEvent)
return nil
}