//go:build linux package migration import ( "errors" "fmt" "os" "path/filepath" "strings" ) func privateDirectories(path string) error { if !filepath.IsAbs(path) { return errors.New("directory path must be absolute") } current := "/" for _, component := range strings.Split(strings.TrimPrefix(filepath.Clean(path), "/"), "/") { if component == "" { continue } current = filepath.Join(current, component) if err := os.Mkdir(current, 0700); err != nil && !errors.Is(err, os.ErrExist) { return err } st, err := os.Lstat(current) if err != nil { return err } if !st.IsDir() { return fmt.Errorf("directory contains a symlink or non-directory: %s", current) } } return nil }