From ecdf381dd9b78b27b81048caa3eabe83342a8a38 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Thu, 17 Mar 2016 16:29:24 -0400 Subject: [PATCH] keywords: add mode= (only octal first) Signed-off-by: Vincent Batts --- keywords.go | 10 ++++++++++ keywords_linux.go | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/keywords.go b/keywords.go index db19f2f..1cfc4ac 100644 --- a/keywords.go +++ b/keywords.go @@ -27,10 +27,16 @@ var ( "type", "uid", "gid", + "mode", "link", "nlink", "time", } + SetKeywords = []string{ + "uid", + "gid", + "mode", + } // KeywordFuncs is the map of all keywords (and the functions to produce them) KeywordFuncs = map[string]KeywordFunc{ "size": sizeKeywordFunc, // The size, in bytes, of the file @@ -41,6 +47,7 @@ var ( "gid": gidKeywordFunc, // The file group as a numeric value "nlink": nlinkKeywordFunc, // The number of hard links the file is expected to have "uname": unameKeywordFunc, // The file owner as a symbolic name + "mode": modeKeywordFunc, // The current file's permissions as a numeric (octal) or symbolic value "cksum": cksumKeywordFunc, // The checksum of the file using the default algorithm specified by the cksum(1) utility "md5": hasherKeywordFunc("md5", md5.New), // The MD5 message digest of the file "md5digest": hasherKeywordFunc("md5digest", md5.New), // A synonym for `md5` @@ -65,6 +72,9 @@ var ( ) var ( + modeKeywordFunc = func(path string, info os.FileInfo) (string, error) { + return fmt.Sprintf("mode=%#o", info.Mode()), nil + } sizeKeywordFunc = func(path string, info os.FileInfo) (string, error) { return fmt.Sprintf("size=%d", info.Size()), nil } diff --git a/keywords_linux.go b/keywords_linux.go index fd59f7f..4427a09 100644 --- a/keywords_linux.go +++ b/keywords_linux.go @@ -45,7 +45,6 @@ var ( if err != nil { return "", err } - println(string(data)) klist[i] = fmt.Sprintf("xattr.%s=%x", xlist[i], sha1.Sum(data)) } return strings.Join(klist, " "), nil