summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/vfs/filesystem_impl_util.go
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/vfs/filesystem_impl_util.go
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/vfs/filesystem_impl_util.go')
-rw-r--r--pkg/sentry/vfs/filesystem_impl_util.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/pkg/sentry/vfs/filesystem_impl_util.go b/pkg/sentry/vfs/filesystem_impl_util.go
index 465e610e0..2620cf975 100644
--- a/pkg/sentry/vfs/filesystem_impl_util.go
+++ b/pkg/sentry/vfs/filesystem_impl_util.go
@@ -16,6 +16,9 @@ package vfs
import (
"strings"
+
+ "gvisor.dev/gvisor/pkg/abi/linux"
+ "gvisor.dev/gvisor/pkg/usermem"
)
// GenericParseMountOptions parses a comma-separated list of options of the
@@ -41,3 +44,13 @@ func GenericParseMountOptions(str string) map[string]string {
}
return m
}
+
+// GenericStatFS returns a statfs struct filled with the common fields for a
+// general filesystem. This is analogous to Linux's fs/libfs.cs:simple_statfs().
+func GenericStatFS(fsMagic uint64) linux.Statfs {
+ return linux.Statfs{
+ Type: fsMagic,
+ BlockSize: usermem.PageSize,
+ NameLength: linux.NAME_MAX,
+ }
+}