diff options
author | Kevin <kevinkrakauer@gmail.com> | 2019-07-11 21:24:27 -0700 |
---|---|---|
committer | Kevin <kevinkrakauer@gmail.com> | 2019-07-11 21:24:27 -0700 |
commit | 44427d8e267b4c4445c1c217637d802f71e9bf52 (patch) | |
tree | 46c6a306d7508f4e7551e0eeb0c3da4455b2b51e /pkg/sentry/fs/dev/dev.go | |
parent | 2eeca68900eeb57a679eccc08fe172b1d9ddf97f (diff) |
Add a stub for /dev/tty.
Actual implementation to follow, but this will satisfy applications that
want it to just exist.
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)) |