mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-11-03 23:40:03 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			34 lines
		
	
	
		
			612 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			612 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package hcsshim
 | 
						|
 | 
						|
import (
 | 
						|
	"io"
 | 
						|
	"syscall"
 | 
						|
 | 
						|
	"github.com/Microsoft/go-winio"
 | 
						|
)
 | 
						|
 | 
						|
// makeOpenFiles calls winio.MakeOpenFile for each handle in a slice but closes all the handles
 | 
						|
// if there is an error.
 | 
						|
func makeOpenFiles(hs []syscall.Handle) (_ []io.ReadWriteCloser, err error) {
 | 
						|
	fs := make([]io.ReadWriteCloser, len(hs))
 | 
						|
	for i, h := range hs {
 | 
						|
		if h != syscall.Handle(0) {
 | 
						|
			if err == nil {
 | 
						|
				fs[i], err = winio.MakeOpenFile(h)
 | 
						|
			}
 | 
						|
			if err != nil {
 | 
						|
				syscall.Close(h)
 | 
						|
			}
 | 
						|
		}
 | 
						|
	}
 | 
						|
	if err != nil {
 | 
						|
		for _, f := range fs {
 | 
						|
			if f != nil {
 | 
						|
				f.Close()
 | 
						|
			}
 | 
						|
		}
 | 
						|
		return nil, err
 | 
						|
	}
 | 
						|
	return fs, nil
 | 
						|
}
 |