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
}
Example #2
0
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
}