ConfigureMMap implements vfs.FileDescriptionImpl.ConfigureMMap.
(ctx context.Context, opts *memmap.MMapOpts)
| 84 | |
| 85 | // ConfigureMMap implements vfs.FileDescriptionImpl.ConfigureMMap. |
| 86 | func (fd *zeroFD) ConfigureMMap(ctx context.Context, opts *memmap.MMapOpts) error { |
| 87 | if opts.Private || !opts.MaxPerms.Write { |
| 88 | // This mapping will never permit writing to the "underlying file" (in |
| 89 | // Linux terms, it isn't VM_SHARED), so implement it as an anonymous |
| 90 | // mapping, but back it with fd; this is what Linux does, and is |
| 91 | // actually application-visible because the resulting VMA will show up |
| 92 | // in /proc/[pid]/maps with fd.vfsfd.VirtualDentry()'s path rather than |
| 93 | // "/dev/zero (deleted)". |
| 94 | opts.Offset = 0 |
| 95 | opts.MappingIdentity = &fd.vfsfd |
| 96 | opts.SentryOwnedContent = true |
| 97 | opts.MappingIdentity.IncRef() |
| 98 | return nil |
| 99 | } |
| 100 | tmpfsFD, err := tmpfs.NewZeroFile(ctx, auth.CredentialsFromContext(ctx), kernel.KernelFromContext(ctx).ShmMount(), opts.Length) |
| 101 | if err != nil { |
| 102 | return err |
| 103 | } |
| 104 | defer tmpfsFD.DecRef(ctx) |
| 105 | return tmpfsFD.ConfigureMMap(ctx, opts) |
| 106 | } |
nothing calls this directly
no test coverage detected