diff options
author | Fabricio Voznika <fvoznika@google.com> | 2020-01-28 16:42:05 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-01-28 16:53:55 -0800 |
commit | 3d046fef06ece6ba20770fa62e0a21569226adaa (patch) | |
tree | de0d4ad6b0c25d3c423dc2e57df8b78c04666082 /pkg/sentry/kernel | |
parent | 431ff52768c2300e15cba609c2be4f507fd30d5b (diff) |
Changes missing in last submit
Updates #1487
Updates #1623
PiperOrigin-RevId: 292040835
Diffstat (limited to 'pkg/sentry/kernel')
-rw-r--r-- | pkg/sentry/kernel/fd_table.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/pkg/sentry/kernel/fd_table.go b/pkg/sentry/kernel/fd_table.go index 56b70ce96..23b88f7a6 100644 --- a/pkg/sentry/kernel/fd_table.go +++ b/pkg/sentry/kernel/fd_table.go @@ -15,9 +15,9 @@ package kernel import ( - "bytes" "fmt" "math" + "strings" "sync/atomic" "syscall" @@ -221,24 +221,24 @@ func (f *FDTable) forEach(fn func(fd int32, file *fs.File, fileVFS2 *vfs.FileDes // String is a stringer for FDTable. func (f *FDTable) String() string { - var b bytes.Buffer + var buf strings.Builder f.forEach(func(fd int32, file *fs.File, fileVFS2 *vfs.FileDescription, flags FDFlags) { switch { case file != nil: n, _ := file.Dirent.FullName(nil /* root */) - b.WriteString(fmt.Sprintf("\tfd:%d => name %s\n", fd, n)) + fmt.Fprintf(&buf, "\tfd:%d => name %s\n", fd, n) case fileVFS2 != nil: - fs := fileVFS2.VirtualDentry().Mount().Filesystem().VirtualFilesystem() - // TODO(gvisor.dev/issue/1623): We have no context nor root. Will this work? - name, err := fs.PathnameWithDeleted(context.Background(), vfs.VirtualDentry{}, fileVFS2.VirtualDentry()) + vfsObj := fileVFS2.Mount().Filesystem().VirtualFilesystem() + name, err := vfsObj.PathnameWithDeleted(context.Background(), vfs.VirtualDentry{}, fileVFS2.VirtualDentry()) if err != nil { - b.WriteString(fmt.Sprintf("<err: %v>\n", err)) + fmt.Fprintf(&buf, "<err: %v>\n", err) + return } - b.WriteString(fmt.Sprintf("\tfd:%d => name %s\n", fd, name)) + fmt.Fprintf(&buf, "\tfd:%d => name %s\n", fd, name) } }) - return b.String() + return buf.String() } // NewFDs allocates new FDs guaranteed to be the lowest number available |