Skip to content

Commit

Permalink
Merge pull request #63 from thaJeztah/unify_zos
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelkarp authored Oct 7, 2022
2 parents 21ccd90 + 0c7a244 commit f6c071f
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 166 deletions.
4 changes: 2 additions & 2 deletions console_unix.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build darwin || freebsd || linux || netbsd || openbsd
// +build darwin freebsd linux netbsd openbsd
//go:build darwin || freebsd || linux || netbsd || openbsd || zos
// +build darwin freebsd linux netbsd openbsd zos

/*
Copyright The containerd Authors.
Expand Down
164 changes: 0 additions & 164 deletions console_zos.go

This file was deleted.

43 changes: 43 additions & 0 deletions pty_zos.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//go:build zos
// +build zos

/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package console

import (
"fmt"
"os"
)

// openpt allocates a new pseudo-terminal by opening the first available /dev/ptypXX device
func openpt() (*os.File, error) {
var f *os.File
var err error
for i := 0; ; i++ {
ptyp := fmt.Sprintf("/dev/ptyp%04d", i)
f, err = os.OpenFile(ptyp, os.O_RDWR, 0600)
if err == nil {
break
}
if os.IsNotExist(err) {
return nil, err
}
// else probably Resource Busy
}
return f, nil
}
13 changes: 13 additions & 0 deletions tc_zos.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,23 @@
package console

import (
"os"
"strings"

"golang.org/x/sys/unix"
)

const (
cmdTcGet = unix.TCGETS
cmdTcSet = unix.TCSETS
)

// unlockpt is a no-op on zos.
func unlockpt(_ *os.File) error {
return nil
}

// ptsname retrieves the name of the first available pts for the given master.
func ptsname(f *os.File) (string, error) {
return "/dev/ttyp" + strings.TrimPrefix(f.Name(), "/dev/ptyp"), nil
}

0 comments on commit f6c071f

Please sign in to comment.