summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/gofer
diff options
context:
space:
mode:
authorGoogler <noreply@google.com>2019-02-13 12:06:20 -0800
committerShentubot <shentubot@google.com>2019-02-13 12:07:34 -0800
commit7aaa6cf22594cfc7eff2070191c0077bfd58046a (patch)
treef67f13952444ba3f66ca61e7c5be2c672e03aa48 /pkg/sentry/fs/gofer
parent2c7488454e7fcbf98c00bcdceb70cb8e2fa98c96 (diff)
Internal change.
PiperOrigin-RevId: 233802562 Change-Id: I40e1b13fd571daaf241b00f8df4bcedd034dc3f1
Diffstat (limited to 'pkg/sentry/fs/gofer')
-rw-r--r--pkg/sentry/fs/gofer/file.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/pkg/sentry/fs/gofer/file.go b/pkg/sentry/fs/gofer/file.go
index 2bb25daf1..7a6dabba8 100644
--- a/pkg/sentry/fs/gofer/file.go
+++ b/pkg/sentry/fs/gofer/file.go
@@ -31,7 +31,13 @@ import (
"gvisor.googlesource.com/gvisor/pkg/waiter"
)
-var openedWX = metric.MustCreateNewUint64Metric("/gofer/opened_write_execute_file", true /* sync */, "Number of times a writable+executable file was opened from a gofer.")
+var (
+ opensWX = metric.MustCreateNewUint64Metric("/gofer/opened_write_execute_file", true /* sync */, "Number of times a writable+executable file was opened from a gofer.")
+ opens9P = metric.MustCreateNewUint64Metric("/gofer/opens_9p", false /* sync */, "Number of times a 9P file was opened from a gofer.")
+ opensHost = metric.MustCreateNewUint64Metric("/gofer/opens_host", false /* sync */, "Number of times a host file was opened from a gofer.")
+ reads9P = metric.MustCreateNewUint64Metric("/gofer/reads_9p", false /* sync */, "Number of 9P file reads from a gofer.")
+ readsHost = metric.MustCreateNewUint64Metric("/gofer/reads_host", false /* sync */, "Number of host file reads from a gofer.")
+)
// fileOperations implements fs.FileOperations for a remote file system.
//
@@ -91,10 +97,15 @@ func NewFile(ctx context.Context, dirent *fs.Dirent, name string, flags fs.FileF
}
if flags.Write {
if err := dirent.Inode.CheckPermission(ctx, fs.PermMask{Execute: true}); err == nil {
- openedWX.Increment()
+ opensWX.Increment()
log.Warningf("Opened a writable executable: %q", name)
}
}
+ if handles.Host != nil {
+ opensHost.Increment()
+ } else {
+ opens9P.Increment()
+ }
return fs.NewFile(ctx, dirent, flags, f)
}
@@ -227,6 +238,11 @@ func (f *fileOperations) Read(ctx context.Context, file *fs.File, dst usermem.IO
// Not all remote file systems enforce this so this client does.
return 0, syserror.EISDIR
}
+ if f.handles.Host != nil {
+ readsHost.Increment()
+ } else {
+ reads9P.Increment()
+ }
if f.inodeOperations.session().cachePolicy.useCachingInodeOps(file.Dirent.Inode) {
return f.inodeOperations.cachingInodeOps.Read(ctx, file, dst, offset)