2011-04-07 19:09:10 +02:00
|
|
|
// Copyright 2011 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package os
|
|
|
|
|
2011-12-03 03:17:34 +01:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"syscall"
|
|
|
|
)
|
2011-04-07 19:09:10 +02:00
|
|
|
|
|
|
|
// SyscallError records an error from a specific system call.
|
|
|
|
type SyscallError struct {
|
|
|
|
Syscall string
|
|
|
|
Err string
|
|
|
|
}
|
|
|
|
|
2011-12-03 03:17:34 +01:00
|
|
|
func (e *SyscallError) Error() string { return e.Syscall + ": " + e.Err }
|
2011-04-07 19:09:10 +02:00
|
|
|
|
2011-12-03 03:17:34 +01:00
|
|
|
// NewSyscallError returns, as an error, a new SyscallError
|
2011-04-07 19:09:10 +02:00
|
|
|
// with the given system call name and error details.
|
|
|
|
// As a convenience, if err is nil, NewSyscallError returns nil.
|
2011-12-13 00:40:51 +01:00
|
|
|
func NewSyscallError(syscall string, err error) error {
|
2011-04-07 19:09:10 +02:00
|
|
|
if err == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2011-12-07 02:11:29 +01:00
|
|
|
return &SyscallError{syscall, err.Error()}
|
2011-04-07 19:09:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
2011-12-03 03:17:34 +01:00
|
|
|
Eshortstat = errors.New("stat buffer too small")
|
|
|
|
Ebadstat = errors.New("malformed stat buffer")
|
|
|
|
Ebadfd = errors.New("fd out of range or not open")
|
|
|
|
Ebadarg = errors.New("bad arg in system call")
|
|
|
|
Enotdir = errors.New("not a directory")
|
|
|
|
Enonexist = errors.New("file does not exist")
|
|
|
|
Eexist = errors.New("file already exists")
|
|
|
|
Eio = errors.New("i/o error")
|
|
|
|
Eperm = errors.New("permission denied")
|
2011-04-07 19:09:10 +02:00
|
|
|
|
|
|
|
EINVAL = Ebadarg
|
|
|
|
ENOTDIR = Enotdir
|
|
|
|
ENOENT = Enonexist
|
|
|
|
EEXIST = Eexist
|
|
|
|
EIO = Eio
|
2011-05-20 02:18:15 +02:00
|
|
|
EACCES = Eperm
|
2011-09-16 17:47:21 +02:00
|
|
|
EPERM = Eperm
|
2011-05-20 02:18:15 +02:00
|
|
|
EISDIR = syscall.EISDIR
|
2011-04-07 19:09:10 +02:00
|
|
|
|
2011-12-03 03:17:34 +01:00
|
|
|
EBADF = errors.New("bad file descriptor")
|
|
|
|
ENAMETOOLONG = errors.New("file name too long")
|
|
|
|
ERANGE = errors.New("math result not representable")
|
|
|
|
EPIPE = errors.New("Broken Pipe")
|
|
|
|
EPLAN9 = errors.New("not supported by plan 9")
|
2011-04-07 19:09:10 +02:00
|
|
|
)
|