MCPcopy
hub / github.com/containerd/containerd / new

Function new

pkg/fifosync/fifo_unix.go:66–87  ·  view source on GitHub ↗

New creates a new FIFO if it does not already exist. Use AsTrigger or AsWaiter to convert the new FIFO to a Trigger or Waiter.

(name string, mode uint32)

Source from the content-addressed store, hash-verified

64// New creates a new FIFO if it does not already exist. Use AsTrigger or AsWaiter to convert the new FIFO to a Trigger
65// or Waiter.
66func new(name string, mode uint32) (*fifo, error) {
67 s, err := os.Stat(name)
68 exist := true
69 if err != nil {
70 if !errors.Is(err, os.ErrNotExist) {
71 return nil, fmt.Errorf("fifo: failed to stat %q: %w", name, err)
72 }
73 exist = false
74 }
75 if s != nil && s.Mode()&os.ModeNamedPipe == 0 {
76 return nil, fmt.Errorf("fifo: not a named pipe: %q", name)
77 }
78 if !exist {
79 err = unix.Mkfifo(name, mode)
80 if err != nil && !errors.Is(err, unix.EEXIST) {
81 return nil, fmt.Errorf("fifo: failed to create %q: %w", name, err)
82 }
83 }
84 return &fifo{
85 name: name,
86 }, nil
87}
88
89func (f *fifo) Name() string {
90 return f.name

Callers 15

setupLogFunction · 0.85
TestGCFunction · 0.85
TestInfoFunction · 0.85
TestInfoSystemMountsFunction · 0.85
newPipeWriterFunction · 0.85
doBearerAuthMethod · 0.85
NewTriggerFunction · 0.85
NewWaiterFunction · 0.85
TestNewAttachFunction · 0.85

Calls 2

StatMethod · 0.65
ModeMethod · 0.45

Tested by 8

TestGCFunction · 0.68
TestInfoFunction · 0.68
TestInfoSystemMountsFunction · 0.68
TestNewAttachFunction · 0.68