diff options
author | gVisor bot <gvisor-bot@google.com> | 2019-07-17 18:36:39 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-07-17 18:36:39 +0000 |
commit | 63156e9362711cda638238009fea833589f5f5a1 (patch) | |
tree | 69b0ea6fae3735960d3833f74befb9a93d37650f /pkg/sentry/fs/dev/dev.go | |
parent | 67b38012014bbc8774e04dd2942d6111b8e9f401 (diff) | |
parent | 682fd2d68f78c65beb11437087987c854fc67121 (diff) |
Merge 682fd2d6 (automated)
Diffstat (limited to 'pkg/sentry/fs/dev/dev.go')
-rw-r--r-- | pkg/sentry/fs/dev/dev.go | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/pkg/sentry/fs/dev/dev.go b/pkg/sentry/fs/dev/dev.go index d4bbd9807..f739c476c 100644 --- a/pkg/sentry/fs/dev/dev.go +++ b/pkg/sentry/fs/dev/dev.go @@ -38,12 +38,20 @@ const ( urandomDevMinor uint32 = 9 ) -func newCharacterDevice(ctx context.Context, iops fs.InodeOperations, msrc *fs.MountSource) *fs.Inode { +// TTY major device number comes from include/uapi/linux/major.h. +const ( + ttyDevMinor = 0 + ttyDevMajor = 5 +) + +func newCharacterDevice(ctx context.Context, iops fs.InodeOperations, msrc *fs.MountSource, major uint16, minor uint32) *fs.Inode { return fs.NewInode(ctx, iops, msrc, fs.StableAttr{ - DeviceID: devDevice.DeviceID(), - InodeID: devDevice.NextIno(), - BlockSize: usermem.PageSize, - Type: fs.CharacterDevice, + DeviceID: devDevice.DeviceID(), + InodeID: devDevice.NextIno(), + BlockSize: usermem.PageSize, + Type: fs.CharacterDevice, + DeviceFileMajor: major, + DeviceFileMinor: minor, }) } @@ -114,6 +122,8 @@ func New(ctx context.Context, msrc *fs.MountSource) *fs.Inode { // If no devpts is mounted, this will simply be a dangling // symlink, which is fine. "ptmx": newSymlink(ctx, "pts/ptmx", msrc), + + "tty": newCharacterDevice(ctx, newTTYDevice(ctx, fs.RootOwner, 0666), msrc, ttyDevMajor, ttyDevMinor), } iops := ramfs.NewDir(ctx, contents, fs.RootOwner, fs.FilePermsFromMode(0555)) |