-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96b29c5
commit 8411183
Showing
7 changed files
with
96 additions
and
156 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package sftp | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
) | ||
|
||
var EBADF = syscall.NewError("fd out of range or not open") | ||
|
||
func wrapPathError(filepath string, err error) error { | ||
if errno, ok := err.(syscall.ErrorString); ok { | ||
return &os.PathError{Path: filepath, Err: errno} | ||
} | ||
return err | ||
} | ||
|
||
// translateErrno translates a syscall error number to a SFTP error code. | ||
func translateErrno(errno syscall.ErrorString) uint32 { | ||
switch errno { | ||
case "": | ||
return sshFxOk | ||
case syscall.ENOENT: | ||
return sshFxNoSuchFile | ||
case syscall.EPERM: | ||
return sshFxPermissionDenied | ||
} | ||
|
||
return sshFxFailure | ||
} | ||
|
||
func translateSyscallError(err error) (uint32, bool) { | ||
switch e := err.(type) { | ||
case syscall.ErrorString: | ||
return translateErrno(e), true | ||
case *os.PathError: | ||
debug("statusFromError,pathError: error is %T %#v", e.Err, e.Err) | ||
if errno, ok := e.Err.(syscall.ErrorString); ok { | ||
return translateErrno(errno), true | ||
} | ||
} | ||
return 0, false | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//go:build !plan9 | ||
// +build !plan9 | ||
|
||
package sftp | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
) | ||
|
||
const EBADF = syscall.EBADF | ||
|
||
func wrapPathError(filepath string, err error) error { | ||
if errno, ok := err.(syscall.Errno); ok { | ||
return &os.PathError{Path: filepath, Err: errno} | ||
} | ||
return err | ||
} | ||
|
||
// translateErrno translates a syscall error number to a SFTP error code. | ||
func translateErrno(errno syscall.Errno) uint32 { | ||
switch errno { | ||
case 0: | ||
return sshFxOk | ||
case syscall.ENOENT: | ||
return sshFxNoSuchFile | ||
case syscall.EACCES, syscall.EPERM: | ||
return sshFxPermissionDenied | ||
} | ||
|
||
return sshFxFailure | ||
} | ||
|
||
func translateSyscallError(err error) (uint32, bool) { | ||
switch e := err.(type) { | ||
case syscall.Errno: | ||
return translateErrno(e), true | ||
case *os.PathError: | ||
debug("statusFromError,pathError: error is %T %#v", e.Err, e.Err) | ||
if errno, ok := e.Err.(syscall.Errno); ok { | ||
return translateErrno(errno), true | ||
} | ||
} | ||
return 0, false | ||
} |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.