code: func setupAppImage(cfg RunConfig, appName types.ACName, img types.Hash, cdir string, useOverlay bool) error {
  	ad := common.AppPath(cdir, appName)
  	if useOverlay {
  		err := os.MkdirAll(ad, common.DefaultRegularDirPerm)
  		if err != nil {
  			return errwrap.Wrap(errors.New("error creating image directory"), err)
  		}
  		treeStoreID, err := ioutil.ReadFile(common.AppTreeStoreIDPath(cdir, appName))
  		if err != nil {
  			return err
  		}
  		if err := copyAppManifest(cdir, appName, ad); err != nil {
  			return err
  		}
  		if err := overlayRender(cfg, string(treeStoreID), cdir, ad, appName.String()); err != nil {
  			return errwrap.Wrap(errors.New("error rendering overlay filesystem"), err)
  		}
  	}
  	return ensureMtabExists(filepath.Join(ad, "rootfs"))
  }
docs: // setupAppImage mounts the overlay filesystem for the app image that
  // corresponds to the given hash if useOverlay is true.
  // It also creates an mtab file in the application's rootfs if one is not
  // present.