// sockets recursively finds all unix sockets under the path provided func (r *Registry) sockets(path string) ([]string, error) { var ( result []string statT syscall.Stat_t ) // TODO: use of fs.Stat (which is syscall.Stat) here makes this linux specific. if err := fs.Stat(path, &statT); err != nil { return nil, err } switch statT.Mode & syscall.S_IFMT { case syscall.S_IFDIR: files, err := fs.ReadDir(path) if err != nil { return nil, err } for _, file := range files { fpath := filepath.Join(path, file.Name()) s, err := r.sockets(fpath) if err != nil { log.Warningf("plugins: error loading path %s: %v", fpath, err) } result = append(result, s...) } case syscall.S_IFSOCK: result = append(result, path) } return result, nil }
func (p dir) ReadDir(path string) ([]os.FileInfo, error) { if path == "/" { result := []os.FileInfo{} for _, v := range p.entries { result = append(result, v) } return result, nil } head, tail := split(path) fs, ok := p.entries[head] if !ok { return nil, fmt.Errorf("Not found: %s", path) } return fs.ReadDir(tail) }