// overlayRender renders the image that corresponds to the given hash using the
// overlay filesystem. It mounts an overlay filesystem from the cached tree of
// the image as rootfs.
344001
func overlayRender(cfg RunConfig, treeStoreID string, cdir string, dest string, appName string) error {
	cachedTreePath := cfg.TreeStore.GetRootFS(treeStoreID)
	mc, err := prepareOverlay(cachedTreePath, treeStoreID, cdir, dest, appName, cfg.MountLabel,
		cfg.RktGid, common.DefaultRegularDirPerm)
	if err != nil {
		return errwrap.Wrap(errors.New("problem preparing overlay directories"), err)
	}
	if err = overlay.Mount(mc); err != nil {
		return errwrap.Wrap(errors.New("problem mounting overlay filesystem"), err)
	}

	return nil
}
116321
func (v *Value_Float) JSONRender() string {
	ret, err := json.Marshal(v.Float)
	if err != nil {
		panic(err)
	}
	return string(ret)
}
1157449
func (v *View) Render(m ...string) trees.Markup {
	if len(m) <= 0 {
		m = []string{"."}
	}

	v.Engine().All(m[0])

	if v.rview == nil {
		return elems.Div()
	}

	dom := v.rview.Render(m...)

	if dom == nil {
		return elems.Div()
	}

	// // swap the uid for the new dom
	// // to ensure we keep the sync between backend and frontend in sync.
	v.backdoor.M = dom
	v.backdoor.SwapUID(v.uid)
	v.backdoor.M = nil

	if v.liveMarkup != nil {
		dom.Reconcile(v.liveMarkup)
	}

	dom.UseEventManager(v.events)
	v.events.LoadUpEvents()
	v.liveMarkup = dom

	return dom
}
1342383
func (t *TemplateRenderable) RenderHTML(_ ...string) template.HTML {
	return template.HTML(t.Render())
}
951847
func XMLRender(status int, indent bool, data interface{}, prefix []byte) *XML {
	return &XML{
		Indent: indent,
		Prefix: prefix,
		Data:   data,
		Head: &Head{
			Status:  status,
			Content: ContentXML,
		},
	}
}
180017
func renderRegion(data result.AggData, y int) int {
	x := 0
	renderString(x, y, "Region: ", termbox.ColorWhite, termbox.ColorBlue)
	x += 8
	regionStr := fmt.Sprintf("%s", data.Region)
	renderString(x, y, regionStr, termbox.ColorWhite|termbox.AttrBold, termbox.ColorBlue)
	x = 0
	y++
	headingStr := "   TotReqs   TotBytes    AvgTime    AvgReq/s  (post)unzip"
	renderString(x, y, headingStr, coldef|termbox.AttrBold, coldef)
	y++
	resultStr := fmt.Sprintf("%10d %10s   %7.3fs  %10.2f %10s/s", data.TotalReqs, humanize.Bytes(uint64(data.TotBytesRead)), float64(data.AveTimeForReq)/nano, data.AveReqPerSec, humanize.Bytes(uint64(data.AveKBytesPerSec)))
	renderString(x, y, resultStr, coldef, coldef)
	y++
	headingStr = "   Slowest    Fastest   Timeouts  TotErrors"
	renderString(x, y, headingStr, coldef|termbox.AttrBold, coldef)
	y++
	resultStr = fmt.Sprintf("  %7.3fs   %7.3fs %10d %10d", float64(data.Slowest)/nano, float64(data.Fastest)/nano, data.TotalTimedOut, totErrors(data))
	renderString(x, y, resultStr, coldef, coldef)
	y++

	return y
}
263060
func (_ *MirrorKeystore) Render(c *fi.Context, a, e, changes *MirrorKeystore) error {
	keystore := c.Keystore

	return keystore.MirrorTo(e.MirrorPath)
}
656710
func SupportsOverlay() error {
	// ignore exec.Command error, modprobe may not be present on the system,
	// or the kernel module will fail to load.
	// we'll find out by reading the side effect in /proc/filesystems
	_ = exec.Command("modprobe", "overlay").Run()

	f, err := os.Open("/proc/filesystems")
	if err != nil {
		// don't use errwrap so consumers can type-check on ErrOverlayUnsupported
		return ErrOverlayUnsupported(fmt.Sprintf("cannot open /proc/filesystems: %v", err))
	}
	defer f.Close()

	s := bufio.NewScanner(f)
	for s.Scan() {
		if s.Text() == "nodev\toverlay" {
			return nil
		}
	}

	return ErrOverlayUnsupported("overlay entry not present in /proc/filesystems")
}
737449
func (s *SequenceRenderer) Render(m ...string) trees.Markup {
	root := trees.NewElement(s.Tag, false)

	attrs.Class(strings.Join(s.Class, " ")).Apply(root)
	attrs.ID(s.ID).Apply(root)

	for _, st := range s.stack {
		st.Render(m...).Apply(root)
	}

	return root
}
283575
func CreateRenderer(window *Window, index int, flags uint32) (*Renderer, error) {
	renderer := C.SDL_CreateRenderer(window.cptr(), C.int(index), C.Uint32(flags))
	if renderer == nil {
		return nil, GetError()
	}
	return (*Renderer)(unsafe.Pointer(renderer)), nil
}
285007
func (renderer *HTMLTemplateRenderer) Render(template string, model Model) error {
	templates, err := renderer.provider.Provide()
	if err != nil {
		renderer.errorf(template, err)
		return err
	}
	setContentType(renderer.writer, ContentHTML)
	err = templates.ExecuteTemplate(renderer.writer, template, model)
	if err != nil {
		renderer.errorf(template, err)
		return err
	}
	return nil
}
669968
func (renderer *Renderer) Render(response *plugins.Response, files []string) (err error) {
	for _, filename := range files {
		file := &plugins.File{Name: filename}
		switch filename {
		case "client.go":
			file.Data, err = renderer.RenderClient()
		case "types.go":
			file.Data, err = renderer.RenderTypes()
		case "provider.go":
			file.Data, err = renderer.RenderProvider()
		case "server.go":
			file.Data, err = renderer.RenderServer()
		case "constants.go":
			file.Data, err = renderer.RenderConstants()
		default:
			file.Data = nil
		}
		if err != nil {
			response.Errors = append(response.Errors, fmt.Sprintf("ERROR %v", err))
		}
		// run generated Go files through imports pkg
		if filepath.Ext(file.Name) == ".go" {
			file.Data, err = imports.Process(file.Name, file.Data, nil)
		}
		response.Files = append(response.Files, file)
	}
	return
}
107821
func NewRenderRenderer(dir string, extensions []string, funcs []template.FuncMap, dev bool) *RenderRenderer {
	opts := render.Options{
		Directory:     dir,
		Extensions:    extensions,
		Funcs:         funcs,
		IsDevelopment: dev,
	}
	return &RenderRenderer{r: render.New(opts)}
}
841841
func renderBackground(svg *svg.SVG, x, y, w, h int) {
	svg.Rect(x, y, w, h, "fill:#eee") // TODO: Theme.
}
1346351
func prepareOverlay(lower, treeStoreID, cdir, dest, appName, lbl string,
	gid int, fm os.FileMode) (*overlay.MountCfg, error) {
	fi, err := os.Stat(lower)
	if err != nil {
		return nil, err
	}
	imgMode := fi.Mode()

	dst := path.Join(dest, "rootfs")
	if err := os.MkdirAll(dst, imgMode); err != nil {
		return nil, err
	}

	overlayDir := path.Join(cdir, "overlay")
	if err := os.MkdirAll(overlayDir, fm); err != nil {
		return nil, err
	}

	// Since the parent directory (rkt/pods/$STATE/$POD_UUID) has the 'S_ISGID' bit, here
	// we need to explicitly turn the bit off when creating this overlay
	// directory so that it won't inherit the bit. Otherwise the files
	// created by users within the pod will inherit the 'S_ISGID' bit
	// as well.
	if err := os.Chmod(overlayDir, fm); err != nil {
		return nil, err
	}

	imgDir := path.Join(overlayDir, treeStoreID)
	if err := os.MkdirAll(imgDir, fm); err != nil {
		return nil, err
	}
	// Also make 'rkt/pods/$STATE/$POD_UUID/overlay/$IMAGE_ID' to be readable by 'rkt' group
	// As 'rkt' status will read the 'rkt/pods/$STATE/$POD_UUID/overlay/$IMAGE_ID/upper/rkt/status/$APP'
	// to get exgid
	if err := os.Chown(imgDir, -1, gid); err != nil {
		return nil, err
	}

	upper := path.Join(imgDir, "upper", appName)
	if err := os.MkdirAll(upper, imgMode); err != nil {
		return nil, err
	}
	if err := label.SetFileLabel(upper, lbl); err != nil {
		return nil, err
	}

	work := path.Join(imgDir, "work", appName)
	if err := os.MkdirAll(work, fm); err != nil {
		return nil, err
	}
	if err := label.SetFileLabel(work, lbl); err != nil {
		return nil, err
	}

	return &overlay.MountCfg{lower, upper, work, dst, lbl}, nil
}
780148
func renderComponent(next Component, prev ComponentOrHTML) (nextHTML *HTML, skip bool, pendingMounts []Mounter) {
	// If we had a component last render, and it's of compatible type, operate
	// on the previous instance.
	if prevComponent, ok := prev.(Component); ok && sameType(next, prevComponent) {
		// Copy `vecty:"prop"` fields from the newly rendered component (next)
		// into the persistent component instance (prev) so that it is aware of
		// what properties the parent has specified during SkipRender/Render
		// below.
		copyProps(next, prevComponent)
		// Persist the previous component across renders.
		next = prevComponent
	}

	// Before rendering, consult the Component's SkipRender method to see if we
	// should skip rendering or not.
	if rs, ok := next.(RenderSkipper); ok {
		prevRenderComponent := next.Context().prevRenderComponent
		if prevRenderComponent != nil {
			if next == prevRenderComponent {
				panic("vecty: internal error (SkipRender called with identical prev component)")
			}
			if rs.SkipRender(prevRenderComponent) {
				return nil, true, nil
			}
		}
	}

	// Render the component into HTML, handling nil renders.
	nextRender := next.Render()
	prevRender := next.Context().prevRender
	if nextRender == nil {
		// nil renders are translated into noscript tags.
		nextRender = Tag("noscript")
	}

	switch v := nextRender.(type) {
	case Component:
		nextHTML, skip, pendingMounts = renderComponent(v, prevRender)
		if skip {
			return nextHTML, skip, pendingMounts
		}
		if prevComponent, ok := prevRender.(Component); ok && sameType(v, prevComponent) {
			nextRender = prevRender
		}
	case *HTML:
		if v == nil {
			// nil renders are translated into noscript tags.
			v = Tag("noscript")
		}
		nextHTML = v
		// Reconcile the actual rendered HTML.
		pendingMounts = nextHTML.reconcile(extractHTML(prev))
	default:
		panic("vecty: internal error (unexpected ComponentOrHTML type " + reflect.TypeOf(v).String() + ")")
	}

	m := mountUnmount(nextRender, prevRender)
	if m != nil {
		pendingMounts = append(pendingMounts, m)
	}

	// Update the context to consider this render.
	next.Context().prevRender = nextRender
	next.Context().prevRenderComponent = copyComponent(next)
	next.Context().unmounted = false
	return nextHTML, false, pendingMounts
}
1214969
func baseShader(c *Canvas) {
	gs := &glShader{
		vf: defaultCanvasVertexFormat,
		vs: baseCanvasVertexShader,
		fs: baseCanvasFragmentShader,
	}

	gs.setUniform("uTransform", &gs.uniformDefaults.transform)
	gs.setUniform("uColorMask", &gs.uniformDefaults.colormask)
	gs.setUniform("uBounds", &gs.uniformDefaults.bounds)
	gs.setUniform("uTexBounds", &gs.uniformDefaults.texbounds)

	c.shader = gs
}