mirror of
https://github.com/vbatts/go-mtree.git
synced 2024-12-22 13:56:30 +00:00
keywords: obtain all permission bits
Fixes #7. Upper 3 bits are 'special' mode bits, and are not included when calling info.Mode().Perm(). Need to mask the info.Mode() with the corresponding mode bit defined by the go library to see if these bits are set or not. Signed-off-by: Stephen Chung <schung@redhat.com>
This commit is contained in:
parent
a29236e678
commit
e29b993aa2
1 changed files with 11 additions and 1 deletions
12
keywords.go
12
keywords.go
|
@ -166,7 +166,17 @@ var (
|
|||
|
||||
var (
|
||||
modeKeywordFunc = func(path string, info os.FileInfo) (string, error) {
|
||||
return fmt.Sprintf("mode=%#o", info.Mode().Perm()), nil
|
||||
permissions := info.Mode().Perm()
|
||||
if os.ModeSetuid&info.Mode() > 0 {
|
||||
permissions |= (1 << 11)
|
||||
}
|
||||
if os.ModeSetgid&info.Mode() > 0 {
|
||||
permissions |= (1 << 10)
|
||||
}
|
||||
if os.ModeSticky&info.Mode() > 0 {
|
||||
permissions |= (1 << 9)
|
||||
}
|
||||
return fmt.Sprintf("mode=%#o", permissions), nil
|
||||
}
|
||||
sizeKeywordFunc = func(path string, info os.FileInfo) (string, error) {
|
||||
return fmt.Sprintf("size=%d", info.Size()), nil
|
||||
|
|
Loading…
Reference in a new issue