コード例 #1
0
func makeTestFd(t *testing.T) testFd {
	var tfd testFd
	errno := unix.Pipe(tfd[:])
	if errno != nil {
		t.Fatalf("Failed to create pipe: %v", errno)
	}
	return tfd
}
コード例 #2
0
ファイル: main.go プロジェクト: th3architect/longhorn
func start(name string, rw types.ReaderWriterAt) error {
	if cxt == nil {
		done = make(chan struct{})
		// this is super dirty
		backend = rw
		volume = name
		pipeFds = make([]int, 2)
		if err := unix.Pipe(pipeFds); err != nil {
			return err
		}
		cxt = C.tcmu_init()
		if cxt == nil {
			return errors.New("TCMU ctx is nil")
		}
		// We don't want to poll main fd because devOpen() will be
		// called once for tcmu_init(). We don't need to listen to
		// further events for now.
	}

	return nil
}