// restores the TTY to the original state
189365
func restore() (err error) {
	if _, err = stty("echo"); err != nil {
		return
	}

	if _, err = stty(originalState); err != nil {
		return
	}

	return
}
305694
func (r *AllocationBitmap) Restore(rangeSpec string, data []byte) error {
	r.lock.Lock()
	defer r.lock.Unlock()

	if r.rangeSpec != rangeSpec {
		return errors.New("the provided range does not match the current range")
	}

	r.allocated = big.NewInt(0).SetBytes(data)
	r.count = countBits(r.allocated)

	return nil
}
1332305
func (s *StateStore) Restore() (*StateRestore, error) {
	txn := s.db.Txn(true)
	r := &StateRestore{
		txn: txn,
	}
	return r, nil
}
976781
func SaveState(fd uintptr) (*State, error) {
	var oldState State
	if err := tcget(fd, &oldState.termios); err != 0 {
		return nil, err
	}

	return &oldState, nil
}
702059
func (t *ContainerVolumeTracker) Restore(containerID string, client *docker.Client) error {
	if t == nil {
		return nil
	}
	for dest, archivePath := range t.paths {
		if len(archivePath) == 0 {
			return fmt.Errorf("path %s does not have an archive and cannot be restored", dest)
		}
		glog.V(4).Infof("Restoring contents of %s from %s", dest, archivePath)
		if !strings.HasSuffix(dest, "/") {
			dest = dest + "/"
		}
		exec, err := client.CreateExec(docker.CreateExecOptions{
			Container: containerID,
			Cmd:       []string{"/bin/sh", "-c", "rm -rf $@", "", dest + "*"},
			User:      "0",
		})
		if err != nil {
			return fmt.Errorf("unable to setup clearing preserved path %s: %v", dest, err)
		}
		if err := client.StartExec(exec.ID, docker.StartExecOptions{}); err != nil {
			return fmt.Errorf("unable to clear preserved path %s: %v", dest, err)
		}
		var status *docker.ExecInspect
		for status == nil {
			status, err = client.InspectExec(exec.ID)
			if err != nil {
				break
			}
			if !status.Running {
				break
			}
			status = nil
		}
		if err != nil {
			return fmt.Errorf("clearing preserved path %s did not succeed: %v", dest, err)
		}
		if status.ExitCode != 0 {
			return fmt.Errorf("clearing preserved path %s failed with exit code %d", dest, status.ExitCode)
		}
		err = func() error {
			f, err := os.Open(archivePath)
			if err != nil {
				return fmt.Errorf("unable to open archive %s for preserved path %s: %v", archivePath, dest, err)
			}
			defer f.Close()
			if err := client.UploadToContainer(containerID, docker.UploadToContainerOptions{
				InputStream: f,
				Path:        dest,
			}); err != nil {
				return fmt.Errorf("unable to upload preserved contents from %s to %s: %v", archivePath, dest, err)
			}
			return nil
		}()
		if err != nil {
			return err
		}
	}
	return nil
}
839332
func restore(store string) {
	files, rderr := ioutil.ReadDir(store)
	chkerr(rderr)
	for _, f := range files {
		fname := f.Name()
		if len(fname) > 4 {
			if fname[len(fname)-4:] == bkpExt {
				key := fname[0 : len(fname)-4]
				fulp := fullpath(store, key)
				msg, cerr := os.Create(fulp)
				chkerr(cerr)
				bkpp := path.Join(store, fname)
				bkp, oerr := os.Open(bkpp)
				chkerr(oerr)
				n, cerr := io.Copy(msg, bkp)
				chkerr(cerr)
				chkcond(n > 0)
				clmerr := msg.Close()
				chkerr(clmerr)
				clberr := bkp.Close()
				chkerr(clberr)
				remerr := os.Remove(bkpp)
				chkerr(remerr)
			}
		}
	}
}
770373
func (p *Process) Restore(r io.Reader) error {
	p.mtx.Lock()
	defer p.mtx.Unlock()

	logger := p.Logger.New("fn", "Restore")
	logger.Info("begin restore")

	// Stop if running.
	if p.running {
		logger.Info("stopping process")
		if err := p.stop(); err != nil {
			logger.Error("error stopping process", "err", err)
			return err
		}
	}

	// Create dump file in data directory.
	logger.Info("copying dump.rdb")
	if err := func() error {
		f, err := os.Create(filepath.Join(p.DataDir, "dump.rdb"))
		if err != nil {
			logger.Error("error creating dump file", "err", err)
			return err
		}
		defer f.Close()

		// Copy from reader to dump file.
		n, err := io.Copy(f, r)
		if err != nil {
			logger.Error("error creating dump file", "err", err)
			return err
		}
		logger.Info("copy completed", "n", n)

		return nil
	}(); err != nil {
		return err
	}

	// Restart process.
	if err := p.start(); err != nil {
		logger.Error("error restarting process", "err", err)
		return err
	}

	return nil
}
951032
func (p *port) restoreTermios() {
	if p.oldTermios == nil {
		return
	}
	if err := tcsetattr(p.fd, p.oldTermios); err != nil {
		// Warning only.
		log.Printf("serial: could not restore setting: %v\n", err)
		return
	}
	p.oldTermios = nil
}
57405
func (cr *Context) Restore() {
	C.cairo_restore(cr.Ptr)
	if err := cr.status(); err != nil {
		panic(err)
	}
}
449508
func (i *FSTIterator) Reset(f *FST,
	startKeyInclusive, endKeyExclusive []byte, aut Automaton) error {
	if aut == nil {
		aut = alwaysMatchAutomaton
	}

	i.f = f
	i.startKeyInclusive = startKeyInclusive
	i.endKeyExclusive = endKeyExclusive
	i.aut = aut

	return i.pointTo(startKeyInclusive)
}
1172347
func (t *Term) Restore() error {
	return termios.Tcsetattr(uintptr(t.fd), termios.TCIOFLUSH, &t.orig)
}
1084234
func (fsm *SimpleFSM) Restore(rc io.ReadCloser) error {
	defer rc.Close()
	var logs [][]byte
	if err := gob.NewDecoder(rc).Decode(&logs); err != nil {
		return err
	}
	fsm.mu.Lock()
	fsm.logs = logs
	fsm.mu.Unlock()
	return nil
}
1334614
func Restore(fd int, state *State) error {
	_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&state.termios)), 0, 0, 0)
	return err
}
502563
func (b *Bytes) Reset() {
	b.fixed.reset()
	b.bytes = b.fixed
}
1360184
func tty() string {
	dest, err := os.Readlink(fd0)
	if err != nil {
		return ""
	}
	return dest
}
962617
func (n *ParamMarkerExpr) Restore(ctx *format.RestoreCtx) error {
	ctx.WritePlain("?")
	return nil
}
1036020
func (_m *DFS) Restore(r io.Reader, version int) error {
	ret := _m.Called(r, version)

	var r0 error
	if rf, ok := ret.Get(0).(func(io.Reader, int) error); ok {
		r0 = rf(r, version)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}