Last active
November 20, 2020 07:22
-
-
Save ezr/6218179038b9ce7b9b2bcabcc83249d1 to your computer and use it in GitHub Desktop.
Like "getfattr -d"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"os" | |
"github.com/pkg/xattr" | |
) | |
func handleError(e error) { | |
if e != nil { | |
log.Fatal(e) | |
} | |
} | |
func main() { | |
if len(os.Args) < 2 { | |
fmt.Println("error - must provide the path to a file or directory") | |
os.Exit(1) | |
} | |
paths := os.Args[1:] | |
for _, path := range paths { | |
list, err := xattr.List(path) | |
handleError(err) | |
if len(list) == 0 { | |
continue | |
} | |
fmt.Println(path) | |
for _, attr := range list { | |
val, err := xattr.Get(path, attr) | |
handleError(err) | |
fmt.Printf(" %s: %s\n", attr, val) | |
} | |
fmt.Println() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
getfattr -d
only lists attributes in the user namespace. This will dump all extended attributes for a file.