code: func prepareTempDir(rootDir string, rootIdentity idtools.Identity) (string, error) {
  	var tmpDir string
  	if tmpDir = os.Getenv("DOCKER_TMPDIR"); tmpDir == "" {
  		tmpDir = filepath.Join(rootDir, "tmp")
  		newName := tmpDir + "-old"
  		if err := os.Rename(tmpDir, newName); err == nil {
  			go func() {
  				if err := os.RemoveAll(newName); err != nil {
  					logrus.Warnf("failed to delete old tmp directory: %s", newName)
  				}
  			}()
  		} else if !os.IsNotExist(err) {
  			logrus.Warnf("failed to rename %s for background deletion: %s. Deleting synchronously", tmpDir, err)
  			if err := os.RemoveAll(tmpDir); err != nil {
  				logrus.Warnf("failed to delete old tmp directory: %s", tmpDir)
  			}
  		}
  	}
  	// We don't remove the content of tmpdir if it's not the default,
  	// it may hold things that do not belong to us.
  	return tmpDir, idtools.MkdirAllAndChown(tmpDir, 0700, rootIdentity)
  }
docs: // prepareTempDir prepares and returns the default directory to use
  // for temporary files.
  // If it doesn't exist, it is created. If it exists, its content is removed.