commit
b2662f21a2
@ -103,15 +103,18 @@ func createIO(ctx context.Context, id string, ioUID, ioGID int, stdio proc.Stdio
|
|||||||
case "binary":
|
case "binary":
|
||||||
pio.io, err = NewBinaryIO(ctx, id, u)
|
pio.io, err = NewBinaryIO(ctx, id, u)
|
||||||
case "file":
|
case "file":
|
||||||
if err := os.MkdirAll(filepath.Dir(u.Path), 0755); err != nil {
|
filePath := u.Path
|
||||||
|
if err := os.MkdirAll(filepath.Dir(filePath), 0755); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var f *os.File
|
var f *os.File
|
||||||
f, err = os.OpenFile(u.Path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
f, err = os.OpenFile(filePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
f.Close()
|
f.Close()
|
||||||
|
pio.stdio.Stdout = filePath
|
||||||
|
pio.stdio.Stderr = filePath
|
||||||
pio.copy = true
|
pio.copy = true
|
||||||
pio.io, err = runc.NewPipeIO(ioUID, ioGID, withConditionalIO(stdio))
|
pio.io, err = runc.NewPipeIO(ioUID, ioGID, withConditionalIO(stdio))
|
||||||
default:
|
default:
|
||||||
@ -179,10 +182,10 @@ func copyPipes(ctx context.Context, rio runc.IO, stdin, stdout, stderr string, w
|
|||||||
)
|
)
|
||||||
if ok {
|
if ok {
|
||||||
if fw, err = fifo.OpenFifo(ctx, i.name, syscall.O_WRONLY, 0); err != nil {
|
if fw, err = fifo.OpenFifo(ctx, i.name, syscall.O_WRONLY, 0); err != nil {
|
||||||
return fmt.Errorf("containerd-shim: opening %s failed: %s", i.name, err)
|
return errors.Wrapf(err, "containerd-shim: opening w/o fifo %q failed", i.name)
|
||||||
}
|
}
|
||||||
if fr, err = fifo.OpenFifo(ctx, i.name, syscall.O_RDONLY, 0); err != nil {
|
if fr, err = fifo.OpenFifo(ctx, i.name, syscall.O_RDONLY, 0); err != nil {
|
||||||
return fmt.Errorf("containerd-shim: opening %s failed: %s", i.name, err)
|
return errors.Wrapf(err, "containerd-shim: opening r/o fifo %q failed", i.name)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if sameFile != nil {
|
if sameFile != nil {
|
||||||
@ -191,7 +194,7 @@ func copyPipes(ctx context.Context, rio runc.IO, stdin, stdout, stderr string, w
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if fw, err = os.OpenFile(i.name, syscall.O_WRONLY|syscall.O_APPEND, 0); err != nil {
|
if fw, err = os.OpenFile(i.name, syscall.O_WRONLY|syscall.O_APPEND, 0); err != nil {
|
||||||
return fmt.Errorf("containerd-shim: opening %s failed: %s", i.name, err)
|
return errors.Wrapf(err, "containerd-shim: opening file %q failed", i.name)
|
||||||
}
|
}
|
||||||
if stdout == stderr {
|
if stdout == stderr {
|
||||||
sameFile = &countingWriteCloser{
|
sameFile = &countingWriteCloser{
|
||||||
|
Loading…
Reference in New Issue
Block a user