Skip to content
Permalink
Browse files

Merge pull request #116 from ross-spencer/master

Ensure that SF doesn't hang w/o user read perms; resolves #113
  • Loading branch information...
richardlehane committed May 25, 2018
2 parents 4738f91 + a3cf617 commit ea5300d3639d741a451522958e8b99912f7d639d
Showing with 19 additions and 1 deletion.
  1. +5 −0 cmd/sf/longpath.go
  2. +14 −1 cmd/sf/sf.go
@@ -55,6 +55,11 @@ func identify(ctxts chan *context, root, orig string, coerr, norecurse, droid bo
printFile(ctxts, gf(path, "", info.ModTime().Format(time.RFC3339), info.Size()), ModeError(info.Mode()))
return nil
}
// zero user read permissions mask, octal 400 (decimal 256)
if info.Mode()&(256) == 0 {
printFile(ctxts, gf(path, "", info.ModTime().Format(time.RFC3339), info.Size()), ModeError(info.Mode()))
return nil
}
identifyFile(gf(path, "", info.ModTime().Format(time.RFC3339), info.Size()), ctxts, gf)
return nil
}
@@ -70,8 +70,18 @@ var (

type ModeError os.FileMode

func declarative_lookup(dtyp int, typ string) string {
decl := "file is of type %s; only regular files can be scanned"
switch {
case dtyp == 1:
decl = "file does not have %s; and cannot be scanned"
}
return fmt.Sprintf(decl, typ)
}

func (me ModeError) Error() string {
typ := "unknown"
dtyp := 0
switch {
case os.FileMode(me)&os.ModeDir == os.ModeDir:
typ = "directory"
@@ -83,8 +93,11 @@ func (me ModeError) Error() string {
typ = "socket"
case os.FileMode(me)&os.ModeDevice == os.ModeDevice:
typ = "device"
case os.FileMode(me)&(256) == 0:
typ = "user read permissions"
dtyp = 1
}
return fmt.Sprintf("file is of type %s; only regular files can be scanned", typ)
return declarative_lookup(dtyp, typ)
}

type WalkError struct {

0 comments on commit ea5300d

Please sign in to comment.
You can’t perform that action at this time.