MCPcopy
hub / github.com/google/gvisor / Open

Method Open

pkg/sentry/devices/ttydev/ttydev.go:38–51  ·  view source on GitHub ↗

Open implements vfs.Device.Open.

(ctx context.Context, mnt *vfs.Mount, vfsd *vfs.Dentry, opts vfs.OpenOptions)

Source from the content-addressed store, hash-verified

36
37// Open implements vfs.Device.Open.
38func (ttyDevice) Open(ctx context.Context, mnt *vfs.Mount, vfsd *vfs.Dentry, opts vfs.OpenOptions) (*vfs.FileDescription, error) {
39 t := kernel.TaskFromContext(ctx)
40 if t == nil {
41 return nil, linuxerr.ENXIO
42 }
43 tty := t.ThreadGroup().TTY()
44 if tty == nil {
45 return nil, linuxerr.ENXIO
46 }
47 // Opening /dev/tty does not set the controlling terminal. See Linux
48 // tty_open().
49 opts.Flags |= linux.O_NOCTTY
50 return tty.OpenTTY(ctx, mnt, vfsd, opts)
51}
52
53// Register registers all devices implemented by this package in vfsObj.
54func Register(vfsObj *vfs.VirtualFilesystem) error {

Callers

nothing calls this directly

Calls 4

TaskFromContextFunction · 0.92
OpenTTYMethod · 0.65
TTYMethod · 0.45
ThreadGroupMethod · 0.45

Tested by

no test coverage detected