summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fsimpl/ext/regular_file.go
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2020-06-11 14:55:04 -0700
committergVisor bot <gvisor-bot@google.com>2020-06-11 14:56:19 -0700
commitd58d57606a460d49b8870d2c48cb75f662f65fda (patch)
tree7fa549398a35c24b45210d3f206e50b64bfc9edb /pkg/sentry/fsimpl/ext/regular_file.go
parent11dc95e6c557a6ab50f2a7acb5d253e056b6fc11 (diff)
Don't copy structs with sync.Mutex during initialization
During inititalization inode struct was copied around, but it isn't great pratice to copy it around since it contains ref count and sync.Mutex. Updates #1480 PiperOrigin-RevId: 315983788
Diffstat (limited to 'pkg/sentry/fsimpl/ext/regular_file.go')
-rw-r--r--pkg/sentry/fsimpl/ext/regular_file.go17
1 files changed, 4 insertions, 13 deletions
diff --git a/pkg/sentry/fsimpl/ext/regular_file.go b/pkg/sentry/fsimpl/ext/regular_file.go
index f7015c44f..152036b2e 100644
--- a/pkg/sentry/fsimpl/ext/regular_file.go
+++ b/pkg/sentry/fsimpl/ext/regular_file.go
@@ -43,28 +43,19 @@ type regularFile struct {
// newRegularFile is the regularFile constructor. It figures out what kind of
// file this is and initializes the fileReader.
-func newRegularFile(inode inode) (*regularFile, error) {
- regFile := regularFile{
- inode: inode,
- }
-
- inodeFlags := inode.diskInode.Flags()
-
- if inodeFlags.Extents {
- file, err := newExtentFile(regFile)
+func newRegularFile(args inodeArgs) (*regularFile, error) {
+ if args.diskInode.Flags().Extents {
+ file, err := newExtentFile(args)
if err != nil {
return nil, err
}
-
- file.regFile.inode.impl = &file.regFile
return &file.regFile, nil
}
- file, err := newBlockMapFile(regFile)
+ file, err := newBlockMapFile(args)
if err != nil {
return nil, err
}
- file.regFile.inode.impl = &file.regFile
return &file.regFile, nil
}