code: func findExistingPrefix(base, pathname string) (string, []string, error) {
  	rel, err := filepath.Rel(base, pathname)
  	if err != nil {
  		return base, nil, err
  	}
  	dirs := strings.Split(rel, string(filepath.Separator))
  
  	// Do OpenAt in a loop to find the first non-existing dir. Resolve symlinks.
  	// This should be faster than looping through all dirs and calling os.Stat()
  	// on each of them, as the symlinks are resolved only once with OpenAt().
  	currentPath := base
  	fd, err := syscall.Open(currentPath, syscall.O_RDONLY, 0)
  	if err != nil {
  		return pathname, nil, fmt.Errorf("error opening %s: %s", currentPath, err)
  	}
  	defer func() {
  		if err = syscall.Close(fd); err != nil {
  			klog.V(4).Infof("Closing FD %v failed for findExistingPrefix(%v): %v", fd, pathname, err)
  		}
  	}()
  	for i, dir := range dirs {
  		// Using O_PATH here will prevent hangs in case user replaces directory with
  		// fifo
  		childFD, err := syscall.Openat(fd, dir, unix.O_PATH, 0)
  		if err != nil {
  			if os.IsNotExist(err) {
  				return currentPath, dirs[i:], nil
  			}
  			return base, nil, err
  		}
  		if err = syscall.Close(fd); err != nil {
  			klog.V(4).Infof("Closing FD %v failed for findExistingPrefix(%v): %v", fd, pathname, err)
  		}
  		fd = childFD
  		currentPath = filepath.Join(currentPath, dir)
  	}
  	return pathname, []string{}, nil
  }
docs: // findExistingPrefix finds prefix of pathname that exists. In addition, it
  // returns list of remaining directories that don't exist yet.