summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fsimpl/sys
diff options
context:
space:
mode:
authorRahat Mahmood <rahat@google.com>2020-08-28 14:29:16 -0700
committerAndrei Vagin <avagin@gmail.com>2020-09-09 17:53:10 -0700
commit8d75fc4883ca8c10fb615203993d56d33a9e36b6 (patch)
tree47f5daf4cca625193e58799c2701e0f69e02f02d /pkg/sentry/fsimpl/sys
parent91e81aaf69ac5fc4cd7b677139c6a23801eabb02 (diff)
Implement StatFS for various VFS2 filesystems.
This mainly involved enabling kernfs' client filesystems to provide a StatFS implementation. Fixes #3411, #3515. PiperOrigin-RevId: 329009864
Diffstat (limited to 'pkg/sentry/fsimpl/sys')
-rw-r--r--pkg/sentry/fsimpl/sys/kcov.go3
-rw-r--r--pkg/sentry/fsimpl/sys/sys.go14
2 files changed, 16 insertions, 1 deletions
diff --git a/pkg/sentry/fsimpl/sys/kcov.go b/pkg/sentry/fsimpl/sys/kcov.go
index 92710d877..73f3d3309 100644
--- a/pkg/sentry/fsimpl/sys/kcov.go
+++ b/pkg/sentry/fsimpl/sys/kcov.go
@@ -39,8 +39,9 @@ func (fs *filesystem) newKcovFile(ctx context.Context, creds *auth.Credentials)
type kcovInode struct {
kernfs.InodeAttrs
kernfs.InodeNoopRefCount
- kernfs.InodeNotSymlink
kernfs.InodeNotDirectory
+ kernfs.InodeNotSymlink
+ implStatFS
}
func (i *kcovInode) Open(ctx context.Context, rp *vfs.ResolvingPath, vfsd *vfs.Dentry, opts vfs.OpenOptions) (*vfs.FileDescription, error) {
diff --git a/pkg/sentry/fsimpl/sys/sys.go b/pkg/sentry/fsimpl/sys/sys.go
index ea30a4ec2..39952d2d0 100644
--- a/pkg/sentry/fsimpl/sys/sys.go
+++ b/pkg/sentry/fsimpl/sys/sys.go
@@ -163,9 +163,16 @@ func (d *dir) DecRef(context.Context) {
d.dirRefs.DecRef(d.Destroy)
}
+// StatFS implements kernfs.Inode.StatFS.
+func (d *dir) StatFS(ctx context.Context, fs *vfs.Filesystem) (linux.Statfs, error) {
+ return vfs.GenericStatFS(linux.SYSFS_MAGIC), nil
+}
+
// cpuFile implements kernfs.Inode.
type cpuFile struct {
+ implStatFS
kernfs.DynamicBytesFile
+
maxCores uint
}
@@ -182,3 +189,10 @@ func (fs *filesystem) newCPUFile(creds *auth.Credentials, maxCores uint, mode li
d.Init(c)
return d
}
+
+type implStatFS struct{}
+
+// StatFS implements kernfs.Inode.StatFS.
+func (*implStatFS) StatFS(context.Context, *vfs.Filesystem) (linux.Statfs, error) {
+ return vfs.GenericStatFS(linux.SYSFS_MAGIC), nil
+}