[lxc-devel] [lxd/master] terminals: update terminology again

brauner on Github lxc-bot at linuxcontainers.org
Mon Jul 6 11:16:09 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 437 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200706/9a4963ed/attachment.bin>
-------------- next part --------------
From 2dae58f6c01b5dc56c0efdb0a2edf64441f0eff2 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Mon, 6 Jul 2020 13:10:23 +0200
Subject: [PATCH] terminals: update terminology again

The ptmx and pts abbreviations contain their problematic terminology.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 doc/rest-api.md                     |  4 ++--
 lxd/instance/drivers/driver_lxc.go  | 14 +++++------
 lxd/instance/drivers/qmp/monitor.go |  6 ++---
 shared/util_linux.go                | 36 ++++++++++++++---------------
 4 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/doc/rest-api.md b/doc/rest-api.md
index 37ada1eee4..5d56d994b2 100644
--- a/doc/rest-api.md
+++ b/doc/rest-api.md
@@ -959,7 +959,7 @@ Input (run bash):
     "environment": {},              // Optional extra environment variables to set
     "wait-for-websocket": false,    // Whether to wait for a connection before starting the process
     "record-output": false,         // Whether to store stdout and stderr (only valid with wait-for-websocket=false) (requires API extension container_exec_recording)
-    "interactive": true,            // Whether to allocate a pts device instead of PIPEs
+    "interactive": true,            // Whether to allocate a pty device instead of PIPEs
     "width": 80,                    // Initial width of the terminal (optional)
     "height": 25,                   // Initial height of the terminal (optional)
     "user": 1000,                   // User to run the command as (optional)
@@ -977,7 +977,7 @@ stderr. That's unless record-output is set to true, in which case,
 stdout and stderr will be redirected to a log file.
 
 If interactive is set to true, a single websocket is returned and is mapped to a
-pts device for stdin, stdout and stderr of the execed process.
+pty device for stdin, stdout and stderr of the execed process.
 
 If interactive is set to false (default), three pipes will be setup, one
 for each of stdin, stdout and stderr.
diff --git a/lxd/instance/drivers/driver_lxc.go b/lxd/instance/drivers/driver_lxc.go
index ecb6336787..6481b1a066 100644
--- a/lxd/instance/drivers/driver_lxc.go
+++ b/lxd/instance/drivers/driver_lxc.go
@@ -5556,7 +5556,7 @@ func (c *lxc) Console() (*os.File, chan error, error) {
 		rootUID, rootGID = idmapset.ShiftIntoNs(0, 0)
 	}
 
-	ptmx, pts, err := shared.OpenPty(rootUID, rootGID)
+	ptx, pty, err := shared.OpenPty(rootUID, rootGID)
 	if err != nil {
 		return nil, nil, err
 	}
@@ -5564,9 +5564,9 @@ func (c *lxc) Console() (*os.File, chan error, error) {
 	cmd := exec.Cmd{}
 	cmd.Path = c.state.OS.ExecPath
 	cmd.Args = args
-	cmd.Stdin = pts
-	cmd.Stdout = pts
-	cmd.Stderr = pts
+	cmd.Stdin = pty
+	cmd.Stdout = pty
+	cmd.Stderr = pty
 
 	err = cmd.Start()
 	if err != nil {
@@ -5575,8 +5575,8 @@ func (c *lxc) Console() (*os.File, chan error, error) {
 
 	go func() {
 		err = cmd.Wait()
-		ptmx.Close()
-		pts.Close()
+		ptx.Close()
+		pty.Close()
 	}()
 
 	go func() {
@@ -5584,7 +5584,7 @@ func (c *lxc) Console() (*os.File, chan error, error) {
 		cmd.Process.Kill()
 	}()
 
-	return ptmx, chDisconnect, nil
+	return ptx, chDisconnect, nil
 }
 
 // ConsoleLog returns console log.
diff --git a/lxd/instance/drivers/qmp/monitor.go b/lxd/instance/drivers/qmp/monitor.go
index b592ea6dd7..fb4bacf2eb 100644
--- a/lxd/instance/drivers/qmp/monitor.go
+++ b/lxd/instance/drivers/qmp/monitor.go
@@ -227,14 +227,14 @@ func (m *Monitor) Console(target string) (*os.File, error) {
 	// Look for the requested console.
 	for _, v := range respDecoded.Return {
 		if v.Label == target {
-			ptsPath := strings.TrimPrefix(v.Filename, "pty:")
+			ptyPath := strings.TrimPrefix(v.Filename, "pty:")
 
-			if !shared.PathExists(ptsPath) {
+			if !shared.PathExists(ptyPath) {
 				continue
 			}
 
 			// Open the PTS device
-			console, err := os.OpenFile(ptsPath, os.O_RDWR, 0600)
+			console, err := os.OpenFile(ptyPath, os.O_RDWR, 0600)
 			if err != nil {
 				return nil, err
 			}
diff --git a/shared/util_linux.go b/shared/util_linux.go
index ad391f3ed1..fcbc898d07 100644
--- a/shared/util_linux.go
+++ b/shared/util_linux.go
@@ -401,56 +401,56 @@ func OpenPty(uid, gid int64) (*os.File, *os.File, error) {
 	revert := true
 
 	// Create a PTS pair.
-	ptmx, err := os.OpenFile("/dev/ptmx", os.O_RDWR|unix.O_CLOEXEC, 0)
+	ptx, err := os.OpenFile("/dev/ptmx", os.O_RDWR|unix.O_CLOEXEC, 0)
 	if err != nil {
 		return nil, nil, err
 	}
 	defer func() {
 		if revert {
-			ptmx.Close()
+			ptx.Close()
 		}
 	}()
 
-	// Unlock the ptmx and pts.
+	// Unlock the ptx and pty.
 	val := 0
-	_, _, errno := unix.Syscall(unix.SYS_IOCTL, uintptr(ptmx.Fd()), unix.TIOCSPTLCK, uintptr(unsafe.Pointer(&val)))
+	_, _, errno := unix.Syscall(unix.SYS_IOCTL, uintptr(ptx.Fd()), unix.TIOCSPTLCK, uintptr(unsafe.Pointer(&val)))
 	if errno != 0 {
 		return nil, nil, unix.Errno(errno)
 	}
 
-	var pts *os.File
-	ptsFd, _, errno := unix.Syscall(unix.SYS_IOCTL, uintptr(ptmx.Fd()), unix.TIOCGPTPEER, uintptr(unix.O_NOCTTY|unix.O_CLOEXEC|os.O_RDWR))
+	var pty *os.File
+	ptyFd, _, errno := unix.Syscall(unix.SYS_IOCTL, uintptr(ptx.Fd()), unix.TIOCGPTPEER, uintptr(unix.O_NOCTTY|unix.O_CLOEXEC|os.O_RDWR))
 	if errno == 0 {
-		// Get the pts side.
+		// Get the pty side.
 		id := 0
-		_, _, errno = unix.Syscall(unix.SYS_IOCTL, uintptr(ptmx.Fd()), unix.TIOCGPTN, uintptr(unsafe.Pointer(&id)))
+		_, _, errno = unix.Syscall(unix.SYS_IOCTL, uintptr(ptx.Fd()), unix.TIOCGPTN, uintptr(unsafe.Pointer(&id)))
 		if errno != 0 {
 			return nil, nil, unix.Errno(errno)
 		}
 
-		pts = os.NewFile(ptsFd, fmt.Sprintf("/dev/pts/%d", id))
+		pty = os.NewFile(ptyFd, fmt.Sprintf("/dev/pts/%d", id))
 	} else {
-		// Get the pts side.
+		// Get the pty side.
 		id := 0
-		_, _, errno = unix.Syscall(unix.SYS_IOCTL, uintptr(ptmx.Fd()), unix.TIOCGPTN, uintptr(unsafe.Pointer(&id)))
+		_, _, errno = unix.Syscall(unix.SYS_IOCTL, uintptr(ptx.Fd()), unix.TIOCGPTN, uintptr(unsafe.Pointer(&id)))
 		if errno != 0 {
 			return nil, nil, unix.Errno(errno)
 		}
 
-		// Open the pts.
-		pts, err = os.OpenFile(fmt.Sprintf("/dev/pts/%d", id), os.O_RDWR|unix.O_NOCTTY, 0)
+		// Open the pty.
+		pty, err = os.OpenFile(fmt.Sprintf("/dev/pts/%d", id), os.O_RDWR|unix.O_NOCTTY, 0)
 		if err != nil {
 			return nil, nil, err
 		}
 	}
 	defer func() {
 		if revert {
-			pts.Close()
+			pty.Close()
 		}
 	}()
 
 	// Configure both sides
-	for _, entry := range []*os.File{ptmx, pts} {
+	for _, entry := range []*os.File{ptx, pty} {
 		// Get termios.
 		t, err := unix.IoctlGetTermios(int(entry.Fd()), unix.TCGETS)
 		if err != nil {
@@ -488,14 +488,14 @@ func OpenPty(uid, gid int64) (*os.File, *os.File, error) {
 		}
 	}
 
-	// Fix the ownership of the pts side.
-	err = unix.Fchown(int(pts.Fd()), int(uid), int(gid))
+	// Fix the ownership of the pty side.
+	err = unix.Fchown(int(pty.Fd()), int(uid), int(gid))
 	if err != nil {
 		return nil, nil, err
 	}
 
 	revert = false
-	return ptmx, pts, nil
+	return ptx, pty, nil
 }
 
 // Extensively commented directly in the code. Please leave the comments!


More information about the lxc-devel mailing list